Skip to content
Snippets Groups Projects
Unverified Commit a8688f46 authored by Luca Moser's avatar Luca Moser
Browse files

adds assets volume to integration test containers

parent 3e31f5c9
Branches
No related tags found
No related merge requests found
Showing
with 130 additions and 9 deletions
...@@ -43,7 +43,7 @@ func TestLoadSnapshot(t *testing.T) { ...@@ -43,7 +43,7 @@ func TestLoadSnapshot(t *testing.T) {
} }
func TestSnapshotMarshalUnmarshal(t *testing.T) { func TestSnapshotMarshalUnmarshal(t *testing.T) {
const genesisBalance = 3333 const genesisBalance = 1000000000
seed := wallet.NewSeed() seed := wallet.NewSeed()
genesisAddr := seed.Address(GENESIS) genesisAddr := seed.Address(GENESIS)
......
File added
#!/bin/bash
echo "copying assets into shared volume..."
rm -rf /assets/*
cp -rp /tmp/assets/* /assets
chmod 777 /assets/*
echo "assets:"
ls /assets
echo "running tests..."
go test ./tests/"${TEST_NAME}" -v -timeout 30m
#!/bin/bash #!/bin/bash
TEST_NAMES='autopeering common drng message' TEST_NAMES='consensus'
echo "Build GoShimmer image" echo "Build GoShimmer image"
docker build -t iotaledger/goshimmer ../../. docker build -t iotaledger/goshimmer ../../.
...@@ -10,8 +10,6 @@ docker pull angelocapossele/drand:latest ...@@ -10,8 +10,6 @@ docker pull angelocapossele/drand:latest
docker pull gaiaadm/pumba:latest docker pull gaiaadm/pumba:latest
docker pull gaiadocker/iproute2:latest docker pull gaiadocker/iproute2:latest
echo "Run integration tests"
for name in $TEST_NAMES for name in $TEST_NAMES
do do
TEST_NAME=$name docker-compose -f tester/docker-compose.yml up --abort-on-container-exit --exit-code-from tester --build TEST_NAME=$name docker-compose -f tester/docker-compose.yml up --abort-on-container-exit --exit-code-from tester --build
......
...@@ -5,13 +5,19 @@ services: ...@@ -5,13 +5,19 @@ services:
container_name: tester container_name: tester
image: golang:1.14 image: golang:1.14
working_dir: /tmp/goshimmer/tools/integration-tests/tester working_dir: /tmp/goshimmer/tools/integration-tests/tester
entrypoint: go test ./tests/${TEST_NAME} -v -mod=readonly -timeout 30m command: /tmp/assets/entrypoint.sh
environment:
- TEST_NAME=${TEST_NAME}
volumes: volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro - /var/run/docker.sock:/var/run/docker.sock:ro
- ../../..:/tmp/goshimmer:ro - ../../..:/tmp/goshimmer:rw
- ../logs:/tmp/logs - ../logs:/tmp/logs
- ../assets:/tmp/assets
- goshimmer-testing-cache:/go - goshimmer-testing-cache:/go
- goshimmer-testing-assets:/assets
volumes: volumes:
goshimmer-testing-cache: goshimmer-testing-cache:
name: goshimmer-testing-cache name: goshimmer-testing-cache
goshimmer-testing-assets:
name: goshimmer-testing-assets
\ No newline at end of file
...@@ -94,6 +94,7 @@ func (d *DockerContainer) CreateGoShimmerPeer(config GoShimmerConfig) error { ...@@ -94,6 +94,7 @@ func (d *DockerContainer) CreateGoShimmerPeer(config GoShimmerConfig) error {
} }
return strings.Join(plugins[:], ",") return strings.Join(plugins[:], ",")
}()), }()),
fmt.Sprintf("--valueLayer.snapshot.file=%s", config.SnapshotFilePath),
fmt.Sprintf("--bootstrap.initialIssuance.timePeriodSec=%d", config.BootstrapInitialIssuanceTimePeriodSec), fmt.Sprintf("--bootstrap.initialIssuance.timePeriodSec=%d", config.BootstrapInitialIssuanceTimePeriodSec),
"--webapi.bindAddress=0.0.0.0:8080", "--webapi.bindAddress=0.0.0.0:8080",
fmt.Sprintf("--autopeering.seed=base58:%s", config.Seed), fmt.Sprintf("--autopeering.seed=base58:%s", config.Seed),
...@@ -105,7 +106,9 @@ func (d *DockerContainer) CreateGoShimmerPeer(config GoShimmerConfig) error { ...@@ -105,7 +106,9 @@ func (d *DockerContainer) CreateGoShimmerPeer(config GoShimmerConfig) error {
}, },
} }
return d.CreateContainer(config.Name, containerConfig) return d.CreateContainer(config.Name, containerConfig, &container.HostConfig{
Binds: []string{"goshimmer-testing-assets:/assets:rw"},
})
} }
// CreateDrandMember creates a new container with the drand configuration. // CreateDrandMember creates a new container with the drand configuration.
......
...@@ -100,6 +100,7 @@ func (n *Network) CreatePeer(c GoShimmerConfig) (*Peer, error) { ...@@ -100,6 +100,7 @@ func (n *Network) CreatePeer(c GoShimmerConfig) (*Peer, error) {
config.EntryNodeHost = n.namePrefix(containerNameEntryNode) config.EntryNodeHost = n.namePrefix(containerNameEntryNode)
config.EntryNodePublicKey = n.entryNodePublicKey() config.EntryNodePublicKey = n.entryNodePublicKey()
config.DisabledPlugins = disabledPluginsPeer config.DisabledPlugins = disabledPluginsPeer
config.SnapshotFilePath = snapshotFilePath
// create wallet // create wallet
var nodeWallet *wallet.Wallet var nodeWallet *wallet.Wallet
......
...@@ -19,8 +19,8 @@ const ( ...@@ -19,8 +19,8 @@ const (
disabledPluginsEntryNode = "portcheck,dashboard,analysis-client,profiling,gossip,drng,issuer,sync,metrics,valuetransfers,testsnapshots,messagelayer,webapi,webapibroadcastdataendpoint,webapifindtransactionhashesendpoint,webapigetneighborsendpoint,webapigettransactionobjectsbyhashendpoint,webapigettransactiontrytesbyhashendpoint" disabledPluginsEntryNode = "portcheck,dashboard,analysis-client,profiling,gossip,drng,issuer,sync,metrics,valuetransfers,testsnapshots,messagelayer,webapi,webapibroadcastdataendpoint,webapifindtransactionhashesendpoint,webapigetneighborsendpoint,webapigettransactionobjectsbyhashendpoint,webapigettransactiontrytesbyhashendpoint"
disabledPluginsPeer = "portcheck,dashboard,analysis-client,profiling" disabledPluginsPeer = "portcheck,dashboard,analysis-client,profiling"
snapshotFilePath = "/assets/7R1itJx5hVuo9w9hjg5cwKFmek4HMSoBDgJZN8hKGxih.bin"
dockerLogsPrefixLen = 8 dockerLogsPrefixLen = 8
dkgMaxTries = 50 dkgMaxTries = 50
...@@ -39,6 +39,7 @@ type GoShimmerConfig struct { ...@@ -39,6 +39,7 @@ type GoShimmerConfig struct {
EntryNodeHost string EntryNodeHost string
EntryNodePublicKey string EntryNodePublicKey string
DisabledPlugins string DisabledPlugins string
SnapshotFilePath string
Bootstrap bool Bootstrap bool
BootstrapInitialIssuanceTimePeriodSec int BootstrapInitialIssuanceTimePeriodSec int
......
...@@ -11,6 +11,7 @@ require ( ...@@ -11,6 +11,7 @@ require (
github.com/drand/drand v0.8.1 github.com/drand/drand v0.8.1
github.com/iotaledger/goshimmer v0.1.3 github.com/iotaledger/goshimmer v0.1.3
github.com/iotaledger/hive.go v0.0.0-20200610104211-d603429af242 github.com/iotaledger/hive.go v0.0.0-20200610104211-d603429af242
github.com/mr-tron/base58 v1.1.3
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/stretchr/testify v1.5.1 github.com/stretchr/testify v1.5.1
) )
......
package autopeering
import (
"testing"
"time"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address/signaturescheme"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/wallet"
"github.com/iotaledger/goshimmer/tools/integration-tests/tester/tests"
"github.com/mr-tron/base58/base58"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// TestConsensusNoConflicts issues valid non-conflicting value objects and then checks
// whether the ledger of every peer reflects the same correct state.
func TestConsensusNoConflicts(t *testing.T) {
n, err := f.CreateNetwork("consensus_TestConsensusNoConflicts", 4, 2)
require.NoError(t, err)
defer tests.ShutdownNetwork(t, n)
time.Sleep(5 * time.Second)
// genesis wallet
genesisSeedBytes, err := base58.Decode("7R1itJx5hVuo9w9hjg5cwKFmek4HMSoBDgJZN8hKGxih")
require.NoError(t, err, "couldn't decode genesis seed from base58 seed")
const genesisBalance = 1000000000
genesisWallet := wallet.New(genesisSeedBytes)
genesisAddr := genesisWallet.Seed().Address(0)
genesisOutputID := transaction.NewOutputID(genesisAddr, transaction.GenesisID)
w := wallet.New()
addr1 := w.Seed().Address(0)
addr2 := w.Seed().Address(1)
const deposit = genesisBalance / 2
// issue transaction spending from the genesis output
tx := transaction.New(
transaction.NewInputs(genesisOutputID),
transaction.NewOutputs(map[address.Address][]*balance.Balance{
addr1: {{Value: deposit, Color: balance.ColorIOTA}},
addr2: {{Value: deposit, Color: balance.ColorIOTA}},
}),
)
tx = tx.Sign(signaturescheme.ED25519(*genesisWallet.Seed().KeyPair(0)))
txID, err := n.Peers()[0].SendTransaction(tx.Bytes())
require.NoError(t, err)
// wait for the transaction to be propagated through the network
time.Sleep(10 * time.Second)
// check that each node has the same perception
for _, p := range n.Peers() {
// check existence of the transaction we just created
res, err := p.GetTransactionByID(txID)
assert.NoError(t, err)
assert.Len(t, res.Error, 0, "there shouldn't be any error from submitting the valid transaction")
assert.Len(t, res.Transaction.Inputs, 1)
assert.Equal(t, genesisOutputID.String(), res.Transaction.Inputs[0])
// check that genesis UTXO is spent
utxos, err := p.GetUnspentOutputs([]string{genesisAddr.String()})
assert.NoError(t, err)
assert.Len(t, utxos.UnspentOutputs, 0, "genesis address should not have any UTXOs")
// check UTXOs
utxos, err = p.GetUnspentOutputs([]string{addr1.String(), addr2.String()})
assert.Len(t, utxos.UnspentOutputs, 2, "addresses should have UTXOs")
assert.Equal(t, addr1.String(), utxos.UnspentOutputs[0].Address)
assert.Equal(t, deposit, utxos.UnspentOutputs[0].OutputIDs[0].Balances[0].Value)
assert.Equal(t, addr2.String(), utxos.UnspentOutputs[1].Address)
assert.Equal(t, deposit, utxos.UnspentOutputs[1].OutputIDs[0].Balances[0].Value)
}
}
package autopeering
import (
"os"
"testing"
"github.com/iotaledger/goshimmer/tools/integration-tests/tester/framework"
)
var f *framework.Framework
// TestMain gets called by the test utility and is executed before any other test in this package.
// It is therefore used to initialize the integration testing framework.
func TestMain(m *testing.M) {
var err error
f, err = framework.Instance()
if err != nil {
panic(err)
}
// call the tests
os.Exit(m.Run())
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment