diff --git a/Dockerfile b/Dockerfile index 0df4a2947139217273586781e007f62c9a9cb0a8..ea398c08f8f67d1d4564ecf03bb3d59133627a9c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # Build ############################ # golang:1.14.0-buster -FROM golang@sha256:fc7e7c9c4b0f6d2d5e8611ee73b9d1d3132750108878517bbf988aa772359ae4 AS build +FROM golang:1.14.4@sha256:afc8698cebd731cc3f98923ceb697093d378b9de7bd2e9365cb675f863660eea AS build # Ensure ca-certficates are up to date RUN update-ca-certificates diff --git a/dapps/valuetransfers/dapp.go b/dapps/valuetransfers/dapp.go index 658601ad211c278ead0939dba84942479e7a1abe..e929205d15da32a27021d5a2656ef750e6cf0617 100644 --- a/dapps/valuetransfers/dapp.go +++ b/dapps/valuetransfers/dapp.go @@ -1,13 +1,12 @@ package valuetransfers import ( + "github.com/iotaledger/goshimmer/plugins/config" + flag "github.com/spf13/pflag" "os" "sync" "time" - "github.com/iotaledger/goshimmer/plugins/config" - flag "github.com/spf13/pflag" - "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/consensus" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/payload" valuepayload "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/payload" @@ -29,15 +28,19 @@ const ( // PluginName contains the human readable name of the plugin. PluginName = "ValueTransfers" - // AverageNetworkDelay contains the average time it takes for a network to propagate through gossip. - AverageNetworkDelay = 5 * time.Second + // DefaultAverageNetworkDelay contains the default average time it takes for a network to propagate through gossip. + DefaultAverageNetworkDelay = 5 * time.Second // CfgValueLayerSnapshotFile is the path to the snapshot file. CfgValueLayerSnapshotFile = "valueLayer.snapshot.file" + + // CfgValueLayerFCOBAverageNetworkDelay is the avg. network delay to use for FCoB rules + CfgValueLayerFCOBAverageNetworkDelay = "valueLayer.fcob.averageNetworkDelay" ) func init() { flag.String(CfgValueLayerSnapshotFile, "", "the path to the snapshot file") + flag.Int(CfgValueLayerFCOBAverageNetworkDelay, 5, "the avg. network delay to use for FCoB rules") } var ( @@ -103,7 +106,9 @@ func configure(_ *node.Plugin) { })) // configure FCOB consensus rules - FCOB = consensus.NewFCOB(Tangle, AverageNetworkDelay) + cfgAvgNetworkDelay := config.Node.GetInt(CfgValueLayerFCOBAverageNetworkDelay) + log.Infof("avg. network delay configured to %d seconds", cfgAvgNetworkDelay) + FCOB = consensus.NewFCOB(Tangle, time.Duration(cfgAvgNetworkDelay)*time.Second) FCOB.Events.Vote.Attach(events.NewClosure(func(id string, initOpn vote.Opinion) { if err := voter.Vote(id, initOpn); err != nil { log.Error(err) diff --git a/go.mod b/go.mod index 4b05e611d047983c908b2a603743a1258a59113c..8f9efb1a924e256a9863f5104127c82741d9c1a2 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,14 @@ module github.com/iotaledger/goshimmer go 1.14 require ( + github.com/Microsoft/go-winio v0.4.14 // indirect github.com/coreos/bbolt v1.3.3 // indirect github.com/dgraph-io/badger/v2 v2.0.2 github.com/dgrijalva/jwt-go v3.2.0+incompatible + github.com/docker/distribution v2.7.1+incompatible // indirect + github.com/docker/docker v1.13.1 // indirect + github.com/docker/go-connections v0.4.0 // indirect + github.com/docker/go-units v0.4.0 // indirect github.com/drand/drand v0.8.1 github.com/drand/kyber v1.0.1-0.20200331114745-30e90cc60f99 github.com/gobuffalo/packr/v2 v2.7.1 @@ -18,11 +23,12 @@ require ( github.com/labstack/gommon v0.3.0 github.com/magiconair/properties v1.8.1 github.com/mr-tron/base58 v1.1.3 + github.com/opencontainers/go-digest v1.0.0 // indirect github.com/panjf2000/ants/v2 v2.2.2 github.com/pkg/errors v0.9.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.6.2 - github.com/stretchr/testify v1.5.1 + github.com/stretchr/testify v1.6.1 github.com/valyala/fasttemplate v1.1.0 // indirect go.dedis.ch/kyber/v3 v3.0.12 go.uber.org/atomic v1.6.0 diff --git a/go.sum b/go.sum index 9c42f9931e730418d427d98e5494e91cb4f68212..433d06b27a7425c6c47d24af579b43b41e9711ac 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,8 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DataDog/zstd v1.4.1 h1:3oxKN3wbHibqx897utPC2LTQU4J+IHWWJO+glkAkpFM= github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= +github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU= +github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs= @@ -61,6 +63,14 @@ github.com/dgryski/go-farm v0.0.0-20190323231341-8198c7b169ec/go.mod h1:SqUrOPUn github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug= +github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/docker v1.13.1 h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo= +github.com/docker/docker v1.13.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= +github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= +github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/drand/bls12-381 v0.3.2 h1:RImU8Wckmx8XQx1tp1q04OV73J9Tj6mmpQLYDP7V1XE= github.com/drand/bls12-381 v0.3.2/go.mod h1:dtcLgPtYT38L3NO6mPDYH0nbpc5tjPassDqiniuAt4Y= github.com/drand/drand v0.8.1 h1:wAGnZKa+HbyNvRQOwLGIVnJR14o9kS/0+w9VroJ1AO0= @@ -211,6 +221,8 @@ github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/panjf2000/ants/v2 v2.2.2 h1:TWzusBjq/IflXhy+/S6u5wmMLCBdJnB9tPIx9Zmhvok= github.com/panjf2000/ants/v2 v2.2.2/go.mod h1:1GFm8bV8nyCQvU5K4WvBCTG1/YBFOD2VzjffD8fV55A= github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo= @@ -261,6 +273,7 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/simia-tech/env v0.1.0/go.mod h1:eVRQ7W5NXXHifpPAcTJ3r5EmoGgMn++dXfSVbZv3Opo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= @@ -297,6 +310,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= @@ -410,6 +425,7 @@ golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -491,6 +507,8 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= diff --git a/plugins/autopeering/parameters.go b/plugins/autopeering/parameters.go index 01022ef352e2ae927b2841f399dd20c8a366607f..0cd2088fb04e0ace1c5dd58df51241a8a252c512 100644 --- a/plugins/autopeering/parameters.go +++ b/plugins/autopeering/parameters.go @@ -7,8 +7,12 @@ import ( const ( // CfgEntryNodes defines the config flag of the entry nodes. CfgEntryNodes = "autopeering.entryNodes" + + // CfgOutboundUpdateIntervalMs time after which out neighbors are updated. + CfgOutboundUpdateIntervalMs = "autopeering.outboundUpdateIntervalMs" ) func init() { flag.StringSlice(CfgEntryNodes, []string{"V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626"}, "list of trusted entry nodes for auto peering") + flag.Int(CfgOutboundUpdateIntervalMs, 10, "time after which out neighbors are updated") } diff --git a/tools/integration-tests/assets/entrypoint.sh b/tools/integration-tests/assets/entrypoint.sh old mode 100644 new mode 100755 diff --git a/tools/integration-tests/tester/framework/docker.go b/tools/integration-tests/tester/framework/docker.go index 506c10d1b097e2464381cd8d26f37f04811132ba..7b901ce4ff033a1bc438663a9bdb8f9f99275db7 100644 --- a/tools/integration-tests/tester/framework/docker.go +++ b/tools/integration-tests/tester/framework/docker.go @@ -82,6 +82,8 @@ func (d *DockerContainer) CreateGoShimmerPeer(config GoShimmerConfig) error { Cmd: strslice.StrSlice{ "--skip-config=true", "--logger.level=debug", + fmt.Sprintf("--valueLayer.fcob.averageNetworkDelay=%d", ParaFCoBAverageNetworkDelay), + fmt.Sprintf("--autopeering.outboundUpdateIntervalMs=%d", ParaOutboundUpdateIntervalMs), fmt.Sprintf("--node.disablePlugins=%s", config.DisabledPlugins), fmt.Sprintf("--node.enablePlugins=%s", func() string { var plugins []string diff --git a/tools/integration-tests/tester/framework/framework.go b/tools/integration-tests/tester/framework/framework.go index 4c19cc4ac861bf931af96574c19e1b94b2ee70dc..fa1a80a90f48784f4931dff730fb1bbfbd15476f 100644 --- a/tools/integration-tests/tester/framework/framework.go +++ b/tools/integration-tests/tester/framework/framework.go @@ -80,7 +80,12 @@ func (f *Framework) CreateNetwork(name string, peers int, minimumNeighbors int, // create peers/GoShimmer nodes for i := 0; i < peers; i++ { config := GoShimmerConfig{ - Bootstrap: true, + Bootstrap: func(i int) bool { + if ParaBootstrapOnEveryNode { + return true + } + return i == 0 + }(i), BootstrapInitialIssuanceTimePeriodSec: bootstrapInitialIssuanceTimePeriodSec, Faucet: i == 0, } @@ -128,7 +133,12 @@ func (f *Framework) CreateNetworkWithPartitions(name string, peers, partitions, // create peers/GoShimmer nodes for i := 0; i < peers; i++ { - config := GoShimmerConfig{Bootstrap: true} + config := GoShimmerConfig{Bootstrap: func(i int) bool { + if ParaBootstrapOnEveryNode { + return true + } + return i == 0 + }(i)} if _, err = network.CreatePeer(config); err != nil { return nil, err } @@ -234,7 +244,12 @@ func (f *Framework) CreateDRNGNetwork(name string, members, peers, minimumNeighb // create peers/GoShimmer nodes for i := 0; i < peers; i++ { - config.Bootstrap = i == 0 + config.Bootstrap = func(i int) bool { + if ParaBootstrapOnEveryNode { + return true + } + return i == 0 + }(i) config.Seed = privKeys[i].Seed().String() if _, err = drng.CreatePeer(config, pubKeys[i]); err != nil { return nil, err diff --git a/tools/integration-tests/tester/framework/parameters.go b/tools/integration-tests/tester/framework/parameters.go index ed820a976893a6b9a4b4415a044da5dbb67806d7..9b88366083f9aed1e0d03198b4029efff86ec613 100644 --- a/tools/integration-tests/tester/framework/parameters.go +++ b/tools/integration-tests/tester/framework/parameters.go @@ -27,6 +27,16 @@ const ( exitStatusSuccessful = 0 ) +// Parameters to override before calling any peer creation function. +var ( + // ParaFCoBAverageNetworkDelay defines the configured avg. network delay (in seconds) for the FCOB rules. + ParaFCoBAverageNetworkDelay = 5 + // ParaOutboundUpdateIntervalMs the autopeering outbound update interval in milliseconds. + ParaOutboundUpdateIntervalMs = 100 + // ParaBootstrapOnEveryNode whether to enable the bootstrap plugin on every node. + ParaBootstrapOnEveryNode = false +) + var ( faucetSeed = []byte{251, 163, 190, 98, 92, 82, 164, 79, 74, 48, 203, 162, 247, 119, 140, 76, 33, 100, 148, 204, 244, 248, 232, 18, 132, 217, 85, 31, 246, 83, 193, 193} diff --git a/tools/integration-tests/tester/go.mod b/tools/integration-tests/tester/go.mod index 6b1a07c6b278e4e2d5f257601111fd368c254353..fb23805656004ff35923f67605f823ac705c6c07 100644 --- a/tools/integration-tests/tester/go.mod +++ b/tools/integration-tests/tester/go.mod @@ -12,8 +12,7 @@ require ( github.com/iotaledger/goshimmer v0.1.3 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/stretchr/testify v1.5.1 + github.com/stretchr/testify v1.6.1 ) replace github.com/iotaledger/goshimmer => ../../.. diff --git a/tools/integration-tests/tester/go.sum b/tools/integration-tests/tester/go.sum index dcd5ef8f8d50ea0a9d8c12f8ff8040b4e3171a6c..8d1d03b6fd96ca2ba969cd7d6285a4dbb9ad53d1 100644 --- a/tools/integration-tests/tester/go.sum +++ b/tools/integration-tests/tester/go.sum @@ -204,6 +204,8 @@ github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/panjf2000/ants/v2 v2.2.2 h1:TWzusBjq/IflXhy+/S6u5wmMLCBdJnB9tPIx9Zmhvok= github.com/panjf2000/ants/v2 v2.2.2/go.mod h1:1GFm8bV8nyCQvU5K4WvBCTG1/YBFOD2VzjffD8fV55A= github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo= @@ -287,6 +289,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= @@ -478,6 +482,8 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= diff --git a/tools/integration-tests/tester/tests/consensus/consensus_conflicts_test.go b/tools/integration-tests/tester/tests/consensus/consensus_conflicts_test.go index feee165c21cd6f0b47eec6570d068411fe544966..9d24e9670164bdd080892a2debd35d0264c04571 100644 --- a/tools/integration-tests/tester/tests/consensus/consensus_conflicts_test.go +++ b/tools/integration-tests/tester/tests/consensus/consensus_conflicts_test.go @@ -1,11 +1,11 @@ package consensus import ( + "github.com/iotaledger/goshimmer/tools/integration-tests/tester/framework" "log" "testing" "time" - "github.com/iotaledger/goshimmer/dapps/valuetransfers" "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" @@ -22,12 +22,16 @@ import ( // then issues valid value objects spending the genesis in both, deletes the partitions (and lets them merge) // and then checks that the conflicts are resolved via FPC. func TestConsensusFiftyFiftyOpinionSplit(t *testing.T) { - n, err := f.CreateNetworkWithPartitions("fiftyfifty", 6, 2, 2) + + // override avg. network delay to accustom integration test slowness + framework.ParaFCoBAverageNetworkDelay = 60 + framework.ParaBootstrapOnEveryNode = true + + // create two partitions with their own peers + n, err := f.CreateNetworkWithPartitions("abc", 6, 2, 2) require.NoError(t, err) defer tests.ShutdownNetwork(t, n) - time.Sleep(10 * time.Second) - // split the network for i, partition := range n.Partitions() { log.Printf("partition %d peers:", i) @@ -89,7 +93,9 @@ func TestConsensusFiftyFiftyOpinionSplit(t *testing.T) { } // sleep the avg. network delay so both partitions prefer their own first seen transaction - time.Sleep(valuetransfers.AverageNetworkDelay) + log.Printf("waiting %d seconds avg. network delay to make the transactions "+ + "preferred in their corresponding partition", framework.ParaFCoBAverageNetworkDelay) + time.Sleep(time.Duration(framework.ParaFCoBAverageNetworkDelay) * time.Second) // check that each partition is preferring its corresponding transaction log.Println("checking that each partition likes its corresponding transaction before the conflict:") @@ -149,6 +155,16 @@ func TestConsensusFiftyFiftyOpinionSplit(t *testing.T) { Solid: tests.True(), }) + // wait until the voting has finalized + awaitFinalization := map[string]tests.ExpectedInclusionState{} + for _, conflictingTx := range conflictingTxs { + awaitFinalization[conflictingTx.ID().String()] = tests.ExpectedInclusionState{ + Finalized: tests.True(), + } + } + err = tests.AwaitTransactionInclusionState(n.Peers(), awaitFinalization, 2*time.Minute) + assert.NoError(t, err) + // now all transactions must be finalized and at most one must be confirmed var confirmedOverConflictSet int for _, conflictingTx := range conflictingTxIDs { diff --git a/tools/integration-tests/tester/tests/consensus/consensus_noconflicts_test.go b/tools/integration-tests/tester/tests/consensus/consensus_noconflicts_test.go index 720334b2c3c2b83ea4dac783622047cacb542ad7..b9f5528d5238f3e45007c6a6c350ebef98d574f7 100644 --- a/tools/integration-tests/tester/tests/consensus/consensus_noconflicts_test.go +++ b/tools/integration-tests/tester/tests/consensus/consensus_noconflicts_test.go @@ -60,7 +60,7 @@ func TestConsensusNoConflicts(t *testing.T) { // wait for the transaction to be propagated through the network // and it becoming preferred, finalized and confirmed - time.Sleep(valuetransfers.AverageNetworkDelay*2 + valuetransfers.AverageNetworkDelay/2) + time.Sleep(valuetransfers.DefaultAverageNetworkDelay*2 + valuetransfers.DefaultAverageNetworkDelay/2) // since we just issued a transaction spending the genesis output, there // shouldn't be any UTXOs on the genesis address anymore @@ -105,7 +105,7 @@ func TestConsensusNoConflicts(t *testing.T) { } // wait again some network delays for the transactions to materialize - time.Sleep(valuetransfers.AverageNetworkDelay*2 + valuetransfers.AverageNetworkDelay/2) + time.Sleep(valuetransfers.DefaultAverageNetworkDelay*2 + valuetransfers.DefaultAverageNetworkDelay/2) tests.CheckAddressOutputsFullyConsumed(t, n.Peers(), firstReceiverAddresses) tests.CheckTransactions(t, n.Peers(), secondReceiverExpectedTransactions, true, tests.ExpectedInclusionState{ diff --git a/tools/integration-tests/tester/tests/testutil.go b/tools/integration-tests/tester/tests/testutil.go index d0b6e75f4270b3bcc15ed012bd6130a78047bcbf..215c4438c93bc1cc1ff5e4d97e367e063683fe8b 100644 --- a/tools/integration-tests/tester/tests/testutil.go +++ b/tools/integration-tests/tester/tests/testutil.go @@ -23,6 +23,7 @@ import ( var ( ErrTransactionNotAvailableInTime = errors.New("transaction was not available in time") + ErrTransactionStateNotSameInTime = errors.New("transaction state did not materialize in time") ) // DataMessageSent defines a struct to identify from which issuer a data message was sent. @@ -510,6 +511,59 @@ func AwaitTransactionAvailability(peers []*framework.Peer, transactionIDs []stri return missing, ErrTransactionNotAvailableInTime } +// AwaitTransactionInclusionState awaits on all given peers until the specified transactions +// have the expected state or max duration is reached. This function does not gracefully +// handle the transactions not existing on the given peers, therefore it must be ensured +// the the transactions exist beforehand. +func AwaitTransactionInclusionState(peers []*framework.Peer, transactionIDs map[string]ExpectedInclusionState, maxAwait time.Duration) error { + s := time.Now() + for ; time.Since(s) < maxAwait; time.Sleep(1 * time.Second) { + var wg sync.WaitGroup + wg.Add(len(peers)) + counter := int32(len(peers) * len(transactionIDs)) + for _, p := range peers { + go func(p *framework.Peer) { + defer wg.Done() + for txID := range transactionIDs { + tx, err := p.GetTransactionByID(txID) + if err != nil { + continue + } + expInclState := transactionIDs[txID] + if expInclState.Confirmed != nil && *expInclState.Confirmed != tx.InclusionState.Confirmed { + continue + } + if expInclState.Conflict != nil && *expInclState.Conflict != tx.InclusionState.Conflict { + continue + } + if expInclState.Finalized != nil && *expInclState.Finalized != tx.InclusionState.Finalized { + continue + } + if expInclState.Liked != nil && *expInclState.Liked != tx.InclusionState.Liked { + continue + } + if expInclState.Preferred != nil && *expInclState.Preferred != tx.InclusionState.Preferred { + continue + } + if expInclState.Rejected != nil && *expInclState.Rejected != tx.InclusionState.Rejected { + continue + } + if expInclState.Solid != nil && *expInclState.Solid != tx.InclusionState.Solid { + continue + } + atomic.AddInt32(&counter, -1) + } + }(p) + } + wg.Wait() + if counter == 0 { + // everything available + return nil + } + } + return ErrTransactionStateNotSameInTime +} + // ShutdownNetwork shuts down the network and reports errors. func ShutdownNetwork(t *testing.T, n Shutdowner) { err := n.Shutdown()