From 4a8ae412a7bd4bc87a18b8746bf2dab1760db14e Mon Sep 17 00:00:00 2001 From: Gustavo Chain Date: Fri, 16 Aug 2019 13:39:01 +0200 Subject: [PATCH 01/19] Integration Test Suite against testnet --- packages/go-kosu/abci/app.go | 4 +- packages/go-kosu/abci/client.go | 42 ++-- packages/go-kosu/abci/witness.go | 2 +- packages/go-kosu/cmd/kosu-cli/main.go | 8 +- packages/go-kosu/cmd/kosud/main.go | 7 +- packages/go-kosu/rpc/cmd.go | 8 +- packages/go-kosu/rpc/rpc_test.go | 7 +- .../go-kosu/testnet/node0/config/config.toml | 2 +- .../go-kosu/testnet/node0/config/genesis.json | 3 +- .../go-kosu/testnet/node1/config/genesis.json | 3 +- .../go-kosu/testnet/node2/config/genesis.json | 3 +- .../go-kosu/testnet/node3/config/genesis.json | 3 +- packages/go-kosu/tests/helpers.go | 25 +++ packages/go-kosu/tests/order_test.go | 149 +++++++------ packages/go-kosu/tests/rebalance_test.go | 91 ++------ packages/go-kosu/tests/run_test.go | 13 -- packages/go-kosu/tests/specs_test.go | 207 ++++++++++++++++++ packages/go-kosu/tests/suite_test.go | 57 ----- packages/go-kosu/tests/validators_test.go | 63 ++++++ packages/go-kosu/tests/witness_test.go | 166 ++++---------- 20 files changed, 494 insertions(+), 369 deletions(-) create mode 100644 packages/go-kosu/tests/helpers.go delete mode 100644 packages/go-kosu/tests/run_test.go create mode 100644 packages/go-kosu/tests/specs_test.go create mode 100644 packages/go-kosu/tests/validators_test.go diff --git a/packages/go-kosu/abci/app.go b/packages/go-kosu/abci/app.go index bcda8d7b..fba19ba4 100644 --- a/packages/go-kosu/abci/app.go +++ b/packages/go-kosu/abci/app.go @@ -71,7 +71,7 @@ func (app *App) NewClient() (*Client, error) { return nil, err } - return NewHTTPClient(url, key), nil + return NewHTTPClient(url, key) } // Query queries the application state using the store.Query method @@ -301,5 +301,5 @@ func (app *App) DeliverTx(req []byte) abci.ResponseDeliverTx { fmt.Printf("Unknown Tx: %t", tx.GetData()) } - return abci.ResponseDeliverTx{Code: 1, Info: "Unknown Transaction type"} + return abci.ResponseDeliverTx{Code: 1, Log: "Unknown Transaction type"} } diff --git a/packages/go-kosu/abci/client.go b/packages/go-kosu/abci/client.go index 573a79a2..36abf89b 100644 --- a/packages/go-kosu/abci/client.go +++ b/packages/go-kosu/abci/client.go @@ -32,9 +32,13 @@ func NewClient(c client.Client, key []byte) *Client { } // NewHTTPClient calls NewClient using a HTTPClient as ABCClient -func NewHTTPClient(addr string, key []byte) *Client { +func NewHTTPClient(addr string, key []byte) (*Client, error) { c := client.NewHTTP(addr, "/websocket") - return NewClient(c, key) + if err := c.Start(); err != nil { + return nil, err + } + + return NewClient(c, key), nil } // BroadcastTxAsync will return right away without waiting to hear if the transaction is even valid @@ -90,24 +94,13 @@ func (c *Client) Subscribe(ctx context.Context, q string) (<-chan rpctypes.Resul return nil, nil, err } - // Start WS if not yet - if httpC, ok := c.Client.(*client.HTTP); ok { - if !httpC.IsRunning() { - if err := httpC.Start(); err != nil { - return nil, nil, err - } - } - } - ch, err := c.Client.Subscribe(ctx, "kosu", q) if err != nil { return nil, nil, err } closer := func() { - if httpC, ok := c.Client.(*client.HTTP); ok { - _ = httpC.Stop() - } + _ = c.Client.Unsubscribe(ctx, "kosu", q) } return ch, closer, nil @@ -138,6 +131,27 @@ func (c *Client) QueryConsensusParams() (*types.ConsensusParams, error) { return &pb, nil } +// QueryLastEvent performs a ABCI Query to "/lastevent". +// `lastevent` keeps track of the last block height recorded from the Ethereum chain +func (c *Client) QueryLastEvent() (uint64, error) { + out, err := c.ABCIQuery("/chain/key", []byte("lastevent")) + if err != nil { + return 0, err + } + res := out.Response + + if res.IsErr() { + return 0, errors.New(res.GetLog()) + } + + if len(res.Value) == 0 { + return 0, nil + } + + buf := proto.NewBuffer(res.Value) + return buf.DecodeFixed64() +} + // QueryPoster performs a ABCI Query to "/posters/" func (c *Client) QueryPoster(addr string) (*types.Poster, error) { var pb types.Poster diff --git a/packages/go-kosu/abci/witness.go b/packages/go-kosu/abci/witness.go index 4e04357f..516054c3 100644 --- a/packages/go-kosu/abci/witness.go +++ b/packages/go-kosu/abci/witness.go @@ -33,8 +33,8 @@ func (app *App) deliverWitnessTx(tx *types.TransactionWitness, nodeID []byte) ab } func (app *App) pruneWitnessTxs(block uint64) { + params := app.store.ConsensusParams() fn := func(tx *types.TransactionWitness) { - params := app.store.ConsensusParams() if block-tx.Block >= params.BlocksBeforePruning { app.log.Debug("Pruning tx", "id", hex.EncodeToString(tx.Id)) app.store.DeleteWitnessTx(tx.Id) diff --git a/packages/go-kosu/cmd/kosu-cli/main.go b/packages/go-kosu/cmd/kosu-cli/main.go index b27635f4..2be0149e 100644 --- a/packages/go-kosu/cmd/kosu-cli/main.go +++ b/packages/go-kosu/cmd/kosu-cli/main.go @@ -15,7 +15,7 @@ import ( ) func main() { - var client abci.Client + var client *abci.Client rootCmd := &cobra.Command{ Use: "kosu-cli", @@ -45,11 +45,11 @@ func main() { addr := cmd.Flag("abci").Value.String() // update the client - client = *abci.NewHTTPClient(addr, key) - return nil + client, err = abci.NewHTTPClient(addr, key) + return err } - abci := cli.New(&client) + abci := cli.New(client) tx := &cobra.Command{ Use: "tx", diff --git a/packages/go-kosu/cmd/kosud/main.go b/packages/go-kosu/cmd/kosud/main.go index ab7588db..ab0ad3ec 100644 --- a/packages/go-kosu/cmd/kosud/main.go +++ b/packages/go-kosu/cmd/kosud/main.go @@ -42,9 +42,12 @@ func newDB(dir string, debug bool) (db.DB, error) { } func startWitness(ctx context.Context, ethAddr string, nodeAddr string, key []byte, logger log.Logger) error { - client := abci.NewHTTPClient(nodeAddr, key) - p, err := witness.NewEthereumProvider(ethAddr) + client, err := abci.NewHTTPClient(nodeAddr, key) + if err != nil { + return nil + } + p, err := witness.NewEthereumProvider(ethAddr) if err != nil { return err } diff --git a/packages/go-kosu/rpc/cmd.go b/packages/go-kosu/rpc/cmd.go index 7acd75e6..9ccb1d0a 100644 --- a/packages/go-kosu/rpc/cmd.go +++ b/packages/go-kosu/rpc/cmd.go @@ -49,8 +49,11 @@ func NewCommand() *cobra.Command { return nil }, - Run: func(cmd *cobra.Command, args []string) { - client := abci.NewHTTPClient(url, key) + RunE: func(cmd *cobra.Command, args []string) error { + client, err := abci.NewHTTPClient(url, key) + if err != nil { + return err + } srv := NewServer(client) wg := sync.WaitGroup{} @@ -74,6 +77,7 @@ func NewCommand() *cobra.Command { }() } wg.Wait() + return nil }, } diff --git a/packages/go-kosu/rpc/rpc_test.go b/packages/go-kosu/rpc/rpc_test.go index ec5ba0dc..ee3f0f3c 100644 --- a/packages/go-kosu/rpc/rpc_test.go +++ b/packages/go-kosu/rpc/rpc_test.go @@ -28,13 +28,8 @@ func newServerClient(t *testing.T) (*abci.App, *rpc.Client, func()) { } func TestRPCLatestHeight(t *testing.T) { - _, closer := tests.StartServer(t, db.NewMemDB()) + _, client, closer := newServerClient(t) defer closer() - client := rpc.DialInProc( - NewServer( - abci.NewHTTPClient("http://localhost:26657", nil), - ), - ) var latest uint64 // Get the initial (prior the first block is mined) diff --git a/packages/go-kosu/testnet/node0/config/config.toml b/packages/go-kosu/testnet/node0/config/config.toml index c2c74d20..6ebcdec1 100644 --- a/packages/go-kosu/testnet/node0/config/config.toml +++ b/packages/go-kosu/testnet/node0/config/config.toml @@ -22,7 +22,7 @@ db_backend = "leveldb" db_dir = "data" # Output level for logging, including package level options -log_level = "app:info,*:error" +log_level = "app:debug,*:error" # Output format: 'plain' (colored text) or 'json' log_format = "plain" diff --git a/packages/go-kosu/testnet/node0/config/genesis.json b/packages/go-kosu/testnet/node0/config/genesis.json index c4a3e84b..48ba7f39 100644 --- a/packages/go-kosu/testnet/node0/config/genesis.json +++ b/packages/go-kosu/testnet/node0/config/genesis.json @@ -43,7 +43,8 @@ "app_state": { "ConsensusParams": { "PeriodLimit": 100000, - "PeriodLength": 10 + "PeriodLength": 10, + "BlocksBeforePruning": 10 } } } diff --git a/packages/go-kosu/testnet/node1/config/genesis.json b/packages/go-kosu/testnet/node1/config/genesis.json index c4a3e84b..48ba7f39 100644 --- a/packages/go-kosu/testnet/node1/config/genesis.json +++ b/packages/go-kosu/testnet/node1/config/genesis.json @@ -43,7 +43,8 @@ "app_state": { "ConsensusParams": { "PeriodLimit": 100000, - "PeriodLength": 10 + "PeriodLength": 10, + "BlocksBeforePruning": 10 } } } diff --git a/packages/go-kosu/testnet/node2/config/genesis.json b/packages/go-kosu/testnet/node2/config/genesis.json index c4a3e84b..48ba7f39 100644 --- a/packages/go-kosu/testnet/node2/config/genesis.json +++ b/packages/go-kosu/testnet/node2/config/genesis.json @@ -43,7 +43,8 @@ "app_state": { "ConsensusParams": { "PeriodLimit": 100000, - "PeriodLength": 10 + "PeriodLength": 10, + "BlocksBeforePruning": 10 } } } diff --git a/packages/go-kosu/testnet/node3/config/genesis.json b/packages/go-kosu/testnet/node3/config/genesis.json index c4a3e84b..48ba7f39 100644 --- a/packages/go-kosu/testnet/node3/config/genesis.json +++ b/packages/go-kosu/testnet/node3/config/genesis.json @@ -43,7 +43,8 @@ "app_state": { "ConsensusParams": { "PeriodLimit": 100000, - "PeriodLength": 10 + "PeriodLength": 10, + "BlocksBeforePruning": 10 } } } diff --git a/packages/go-kosu/tests/helpers.go b/packages/go-kosu/tests/helpers.go new file mode 100644 index 00000000..ff9fdcbd --- /dev/null +++ b/packages/go-kosu/tests/helpers.go @@ -0,0 +1,25 @@ +package tests + +import ( + "math/rand" + "os" + "testing" +) + +func envOrSkip(t *testing.T, env string) string { + v := os.Getenv(env) + if v == "" { + t.Skipf("Integration test suite requires '%s' to be exported", env) + } + return v +} + +func randomHex(size int) string { + var alphabet = []rune("abcdefABCDEF0123456789") + + b := make([]rune, size) + for i := range b { + b[i] = alphabet[rand.Intn(len(alphabet))] + } + return string(b) +} diff --git a/packages/go-kosu/tests/order_test.go b/packages/go-kosu/tests/order_test.go index f369bf2d..e7d1593d 100644 --- a/packages/go-kosu/tests/order_test.go +++ b/packages/go-kosu/tests/order_test.go @@ -8,77 +8,90 @@ import ( "go-kosu/abci/types" "go-kosu/rpc" - . "github.com/smartystreets/goconvey/convey" "github.com/stretchr/testify/require" ) -func (s *Suite) TestOrderTx() { - addr := "0xe3ec7592166d0145b9677f5f45dd1bd95ffe6596" - order := `{"subContract":"0xebe8fdf63db77e3b41b0aec8208c49fa46569606","maker":"0xe3ec7592166d0145b9677f5f45dd1bd95ffe6596","arguments":{"maker":[{"datatype":"address","name":"signer"},{"datatype":"address","name":"signerToken"},{"datatype":"uint","name":"signerTokenCount"},{"datatype":"address","name":"buyerToken"},{"datatype":"uint","name":"buyerTokenCount"},{"datatype":"signature","name":"signature","signatureFields":[0,1,2,3,4]}],"taker":[{"datatype":"uint","name":"tokensToBuy"}]},"makerValues":{"signer":"0xe3ec7592166d0145b9677f5f45dd1bd95ffe6596","signerToken":"0xbFB972996fd7658099a95E6290e8B0fa46b9BDd5","signerTokenCount":"1000","buyer":"0xbcd1c49f4e54cca1a0a59ac21b7eb90f07970a3a","buyerToken":"0x92cBc0Bec2121f55E84bC331f096b7dAAe5A5ddA","buyerTokenCount":"1000","signature":"0xce84772cbbbe5a844c9002e6d54e53d72830b890ff1ea1521cbd86faada28aa136997b5cd3cafd85e887a9d6fc25bb2bfbe03fc6319d371b2c976f3374bcd8c300"},"makerSignature":"0xce84772cbbbe5a844c9002e6d54e53d72830b890ff1ea1521cbd86faada28aa136997b5cd3cafd85e887a9d6fc25bb2bfbe03fc6319d371b2c976f3374bcd8c300","posterSignature":"0xc3550b7ceab610e638dfb1b33e5cf7aaf9490854197328eadbe8ac049adef7510a07a0ea046fa1d410c5cc1048828152b9368a8d8925f8f0072192ebfe1bbb3101"}` // nolint:lll - +func NewOrderTx(t *testing.T) *types.TransactionOrder { + order := `{ + "subContract":"0xebe8fdf63db77e3b41b0aec8208c49fa46569606", + "maker":"0xe3ec7592166d0145b9677f5f45dd1bd95ffe6596", + "arguments":{"maker":[{"datatype":"address","name":"signer"},{"datatype":"address","name":"signerToken"},{"datatype":"uint","name":"signerTokenCount"},{"datatype":"address","name":"buyerToken"},{"datatype":"uint","name":"buyerTokenCount"},{"datatype":"signature","name":"signature","signatureFields":[0,1,2,3,4]}],"taker":[{"datatype":"uint","name":"tokensToBuy"}]}, + "makerValues":{ + "signer":"0xe3ec7592166d0145b9677f5f45dd1bd95ffe6596", + "signerToken":"0xbFB972996fd7658099a95E6290e8B0fa46b9BDd5", + "signerTokenCount":"1000", + "buyer":"0xbcd1c49f4e54cca1a0a59ac21b7eb90f07970a3a", + "buyerToken":"0x92cBc0Bec2121f55E84bC331f096b7dAAe5A5ddA", + "buyerTokenCount":"1000", + "signature":"0xce84772cbbbe5a844c9002e6d54e53d72830b890ff1ea1521cbd86faada28aa136997b5cd3cafd85e887a9d6fc25bb2bfbe03fc6319d371b2c976f3374bcd8c300" + }, + "makerSignature":"0xce84772cbbbe5a844c9002e6d54e53d72830b890ff1ea1521cbd86faada28aa136997b5cd3cafd85e887a9d6fc25bb2bfbe03fc6319d371b2c976f3374bcd8c300","posterSignature":"0xc3550b7ceab610e638dfb1b33e5cf7aaf9490854197328eadbe8ac049adef7510a07a0ea046fa1d410c5cc1048828152b9368a8d8925f8f0072192ebfe1bbb3101"} + ` tx := &types.TransactionOrder{} - require.NoError(s.T(), json.Unmarshal([]byte(order), tx)) - - GivenABCIServer(s.T(), s, func(t *testing.T) { - Convey("And an existing poster with Limit > 0", func() { - posterTx := &types.TransactionWitness{ - Subject: types.TransactionWitness_POSTER, - Address: addr, - Amount: types.NewBigIntFromInt(10), - } - BroadcastTxCommit(t, s.client, posterTx) - - BroadcastNextRebalance(t, s.client) - - Convey("When sending an OrderTx", func() { - poster, err := s.client.QueryPoster(addr) - require.NoError(t, err) - BroadcastTxCommit(t, s.client, tx) - - Convey("Limit should be decremented by 1", func() { - found, err := s.client.QueryPoster(addr) - require.NoError(t, err) - - So(poster.Limit, ShouldEqual, found.Limit+1) - }) - }) - - Convey("When a RPC subscription is active", func() { - client := rpc.DialInProc( - rpc.NewServer(s.client), - ) - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - ch := make(chan *types.TransactionOrder) - defer close(ch) - - sub, err := client.Subscribe(ctx, "kosu", ch, "newOrders") - require.NoError(t, err) - defer sub.Unsubscribe() - - Convey("And a OrderTx is sent", func() { - BroadcastTxSync(t, s.client, tx) - - Convey("Event should be sent and matches the Broadcasted Tx", func() { - event := <-ch - So(event.String(), ShouldEqual, tx.String()) - }) - }) - }) - - Convey("And a non existing poster", func() { - tx.Maker = "0x404" - - Convey("When sending an OrderTx", func() { - res, err := s.client.BroadcastTxSync(tx) - require.NoError(t, err) - - Convey("Tx should be rejected", func() { - So(res.Code, ShouldNotEqual, 0) - }) - }) - }) - }) + err := json.Unmarshal([]byte(order), tx) + require.NoError(t, err) + + // this is used to avoid TM complains about duplicated tx in cache + tx.MakerValues["nonce"] = randomHex(128) + return tx +} + +func (suite *IntegrationTestSuite) TestOrders() { + tx := NewOrderTx(suite.T()) + + last, err := suite.Client().QueryLastEvent() + suite.Require().NoError(err) + + // setup a poster with a balance + posterTx := &types.TransactionWitness{ + Subject: types.TransactionWitness_POSTER, + Address: tx.Maker, + Amount: types.NewBigIntFromInt(10), + Block: last + 1, + } + suite.WithConfirmations(posterTx) + suite.WaitForNewBlock() + suite.BroadcastNextRebalance() + + poster, err := suite.Client().QueryPoster(tx.Maker) + suite.Require().NoError(err) + + suite.Run("LimitUpdate", func() { + suite.BroadcastTxCommit(tx) + + found, err := suite.Client().QueryPoster(tx.Maker) + suite.Require().NoError(err) + + suite.Equal(poster.Limit, found.Limit+1) }) + + suite.Run("UnknownPoster", func() { + tx := NewOrderTx(suite.T()) + tx.Maker = "0x404" + res, err := suite.Client().BroadcastTxSync(tx) + suite.Require().NoError(err) + + suite.NotEqual(0, res.Code) + }) + + suite.Run("RPCEvents", func() { + tx := NewOrderTx(suite.T()) + rpcClient := rpc.DialInProc( + rpc.NewServer(suite.Client()), + ) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + ch := make(chan *types.TransactionOrder) + sub, err := rpcClient.Subscribe(ctx, "kosu", ch, "newOrders") + suite.Require().NoError(err) + defer sub.Unsubscribe() + + suite.BroadcastTxSync(tx) + + event := <-ch + suite.Equal(tx.String(), event.String()) + }) + } diff --git a/packages/go-kosu/tests/rebalance_test.go b/packages/go-kosu/tests/rebalance_test.go index a7a4388b..1d787d51 100644 --- a/packages/go-kosu/tests/rebalance_test.go +++ b/packages/go-kosu/tests/rebalance_test.go @@ -1,91 +1,32 @@ package tests import ( - "context" "go-kosu/abci/types" - "go-kosu/witness" - "testing" - - . "github.com/smartystreets/goconvey/convey" - "github.com/stretchr/testify/require" ) -func (s *Suite) TestRebalance() { - GivenABCIServer(s.T(), s, func(t *testing.T) { - Convey("And an initial Rebalance Tx", func() { - tx := &types.TransactionRebalance{ - RoundInfo: &types.RoundInfo{ - Number: 1, - StartsAt: 100, - EndsAt: 110, - }, - } - - BroadcastTxCommit(t, s.client, tx) - - Convey("RoundInfo should be updated", func() { - info, err := s.client.QueryRoundInfo() - So(err, ShouldBeNil) - - So(info.Number, ShouldEqual, tx.RoundInfo.Number) - So(info.StartsAt, ShouldEqual, tx.RoundInfo.StartsAt) - So(info.EndsAt, ShouldEqual, tx.RoundInfo.EndsAt) - }) - }) - - Convey("Next Tx's .RoundInfo.Number gap is > 1 ", func() { - tx := &types.TransactionRebalance{ - RoundInfo: &types.RoundInfo{Number: 10}, - } +func (suite *IntegrationTestSuite) TestRebalance() { + suite.Run("ValidRoundInfo", func() { + tx := &types.TransactionRebalance{ + RoundInfo: suite.NextRoundInfo(), + } + suite.BroadcastTxCommit(tx) - res, err := s.client.BroadcastTxSync(tx) - So(err, ShouldBeNil) + round, err := suite.Client().QueryRoundInfo() + suite.Require().NoError(err) - Convey("Tx should be rejected", func() { - So(res.Code, ShouldEqual, 1) - So(res.Log, ShouldContainSubstring, "proposal rejected") - }) - }) + suite.Equal(tx.RoundInfo.String(), round.String(), "RoundInfo should be updated") }) -} -func (s *Suite) TestRebalanceWitness() { - GivenABCIServer(s.T(), s, func(t *testing.T) { + suite.Run("InvalidRoundInfo", func() { tx := &types.TransactionRebalance{ - RoundInfo: &types.RoundInfo{ - StartsAt: 10, - EndsAt: 20, - }, + RoundInfo: suite.NextRoundInfo(), } + tx.RoundInfo.Number += 10 - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - // Create the witness - w := witness.New(s.client, witness.NewMockProvider(0), witness.DefaultOptions) - require.NoError(t, w.WithLogger(nil).Start(ctx)) - - Convey("When a set of Rebalance Tx are committed", func() { - roundNumber := []uint64{1, 2, 3} - for _, n := range roundNumber { - tx.RoundInfo.Number = n - - BroadcastTxCommit(t, s.client, tx) - - tx.RoundInfo.StartsAt = tx.RoundInfo.EndsAt - tx.RoundInfo.EndsAt += 10 - } - - // Wait until the next block is minted - sub, closer, err := s.client.Subscribe(ctx, "tm.event = 'NewBlock'") - So(err, ShouldBeNil) - defer closer() - - <-sub + res, err := suite.Client().BroadcastTxSync(tx) + suite.Require().NoError(err) - Convey("It should update the local witness state", func() { - So(w.RoundInfo().Number, ShouldEqual, 3) - }) - }) + suite.EqualValues(1, res.Code, "Proposal should be rejected") + suite.Contains(res.Log, "proposal rejected") }) } diff --git a/packages/go-kosu/tests/run_test.go b/packages/go-kosu/tests/run_test.go deleted file mode 100644 index f76b1d48..00000000 --- a/packages/go-kosu/tests/run_test.go +++ /dev/null @@ -1,13 +0,0 @@ -// +build integration - -package tests - -import ( - "testing" - - "github.com/stretchr/testify/suite" -) - -func TestIntegration(t *testing.T) { - suite.Run(t, new(Suite)) -} diff --git a/packages/go-kosu/tests/specs_test.go b/packages/go-kosu/tests/specs_test.go new file mode 100644 index 00000000..6e9b128b --- /dev/null +++ b/packages/go-kosu/tests/specs_test.go @@ -0,0 +1,207 @@ +package tests + +import ( + "context" + "math/rand" + "path/filepath" + "strings" + "testing" + "time" + + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + + "github.com/tendermint/tendermint/config" + "github.com/tendermint/tendermint/privval" + rpctypes "github.com/tendermint/tendermint/rpc/core/types" + tmtypes "github.com/tendermint/tendermint/types" + + "go-kosu/abci" + "go-kosu/abci/types" +) + +func init() { + rand.Seed(time.Now().UnixNano()) +} + +type Node struct { + Client *abci.Client + Config *config.Config + PrivVal privval.FilePVKey +} + +type IntegrationTestSuite struct { + suite.Suite + + // Nodes are populated on SetupSuite based on the KOSU_TEST_NODES environment variable + // KOSU_TEST_NODES is a comma separated list of nodes following this format: + // [@url],... + // is required and points to the node home directory + // is optional and represents the node url, if not specified it will take the url from config.RPC.ListenAddress + Nodes []Node + + // CurrentBlock will be updated on each new test from the suite + CurrentBlock *tmtypes.Block +} + +// Client returns the first client out of the node list. +func (suite *IntegrationTestSuite) Client() *abci.Client { + return suite.Nodes[0].Client +} + +func (suite *IntegrationTestSuite) WaitForNewBlock() *tmtypes.Block { + events, closer, err := suite.Client().Subscribe(context.Background(), "tm.event = 'NewBlock'") + suite.Require().NoError(err) + defer closer() + + event := <-events + return event.Data.(tmtypes.EventDataNewBlock).Block +} + +// IsValidTxCommit performs assertions over a BroadcastTxCommit +func (suite *IntegrationTestSuite) IsValidTxCommit(res *rpctypes.ResultBroadcastTxCommit, err error) { + suite.Require().NoError(err) + suite.Require().True(res.CheckTx.IsOK(), res.CheckTx.Log) + suite.Require().True(res.DeliverTx.IsOK(), res.DeliverTx.Log) +} + +// IsValidTxSync performs assertions over a BroadcastTxSync +func (suite *IntegrationTestSuite) IsValidTxSync(res *rpctypes.ResultBroadcastTx, err error) { + suite.Require().NoError(err) + suite.Require().Zero(res.Code, res.Log) +} + +// BroadcastTxCommit is a helper function to Broadcast a Tx under test +func (suite *IntegrationTestSuite) BroadcastTxCommit(tx interface{}) *rpctypes.ResultBroadcastTxCommit { + res, err := suite.Client().BroadcastTxCommit(tx) + suite.IsValidTxCommit(res, err) + return res +} + +// BroadcastTxSync is a helper function to Broadcast a Tx under test +func (suite *IntegrationTestSuite) BroadcastTxSync(tx interface{}) *rpctypes.ResultBroadcastTx { + res, err := suite.Client().BroadcastTxSync(tx) + suite.IsValidTxSync(res, err) + return res +} + +// WithNode calls fn for every node defined in the node set. +// If fn returns err, the error is returned and the execution stopped. +func (suite *IntegrationTestSuite) WithNode(fn func(*Node) error) error { + for _, node := range suite.Nodes { + if err := fn(&node); err != nil { + return err + } + } + return nil +} + +// WithConfirmations Broadcast a Tx across all the nodes so that we make sure it's confirmed +func (suite *IntegrationTestSuite) WithConfirmations(tx interface{}) { + suite.WithNode(func(node *Node) error { + suite.IsValidTxSync( + node.Client.BroadcastTxSync(tx), + ) + return nil + }) +} + +// NextRoundInfo calculates the next round info based on the current one +func (suite *IntegrationTestSuite) NextRoundInfo() *types.RoundInfo { + round, err := suite.Client().QueryRoundInfo() + suite.Require().NoError(err) + + diff := round.EndsAt - round.StartsAt + round.StartsAt = round.EndsAt + round.EndsAt += diff + round.Number++ + + return round +} + +func (suite *IntegrationTestSuite) BroadcastNextRebalance() { + params, err := suite.Client().QueryConsensusParams() + suite.Require().NoError(err) + + info, err := suite.Client().QueryRoundInfo() + if err != nil { + info = &types.RoundInfo{ + Number: 0, + StartsAt: 1, + EndsAt: 1, + } + } else { + info.StartsAt = info.EndsAt + } + info.Number++ + info.EndsAt += uint64(params.PeriodLength) + + suite.BroadcastTxCommit(&types.TransactionRebalance{RoundInfo: info}) +} + +func newClient(t *testing.T, rootdir, url string) *abci.Client { + key, err := abci.LoadPrivateKey(rootdir) + require.NoError(t, err) + + client, err := abci.NewHTTPClient(url, key) + require.NoError(t, err) + + return client +} + +func (suite *IntegrationTestSuite) addNode(homedir, url string) { + cfg, err := abci.LoadConfig(homedir) + suite.Require().NoError(err) + + priv := privval.LoadFilePV( + cfg.PrivValidatorKeyFile(), + cfg.PrivValidatorStateFile(), + ).Key + + if url == "" { + url = cfg.RPC.ListenAddress + } + + suite.Nodes = append(suite.Nodes, Node{ + Client: newClient(suite.T(), homedir, url), + Config: cfg, + PrivVal: priv, + }) +} + +// SetupSuite setup the test suite +func (suite *IntegrationTestSuite) SetupSuite() { + nodes := envOrSkip(suite.T(), "KOSU_TEST_NODES") + for _, node := range strings.Split(nodes, ",") { + var homedir, url string + split := strings.Split(node, "@") + homedir = split[0] + if len(split) == 2 { + url = split[1] + } + if !filepath.IsAbs(homedir) { + suite.T().Fatalf("home dir must be absolute, got: %s", homedir) + } + + suite.addNode(homedir, url) + } +} + +// SetupTest creates a new subscriptions to `NewBlocks` and waits for a new block before each test +func (suite *IntegrationTestSuite) SetupTest() { + suite.CurrentBlock = suite.WaitForNewBlock() +} + +func (suite *IntegrationTestSuite) TearDownTest() { +} + +func (suite *IntegrationTestSuite) TearDownSuite() { + for _, node := range suite.Nodes { + err := node.Client.Stop() + suite.Require().NoError(err) + } +} + +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} diff --git a/packages/go-kosu/tests/suite_test.go b/packages/go-kosu/tests/suite_test.go index 87310f59..0099a7b9 100644 --- a/packages/go-kosu/tests/suite_test.go +++ b/packages/go-kosu/tests/suite_test.go @@ -2,16 +2,10 @@ package tests import ( "go-kosu/abci" - "go-kosu/abci/types" - "testing" - . "github.com/smartystreets/goconvey/convey" //nolint - "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" cfg "github.com/tendermint/tendermint/config" - "github.com/tendermint/tendermint/libs/db" - rpctypes "github.com/tendermint/tendermint/rpc/core/types" ) type Suite struct { @@ -20,54 +14,3 @@ type Suite struct { client *abci.Client config *cfg.Config } - -// GivenABCIServer a ABCI Server inside a Convey block -func GivenABCIServer(t *testing.T, suite *Suite, fn func(*testing.T)) { - Convey("Given an ABCI Server", t, func() { - app, closer := StartServer(t, db.NewMemDB()) - defer closer() - suite.config = app.Config - - key, err := abci.LoadPrivateKey(app.Config.RootDir) - require.NoError(t, err) - - suite.client = abci.NewHTTPClient("http://localhost:26657", key) - fn(t) - }) -} - -// BroadcastTxSync is a helper function to Broadcast a Tx under test -func BroadcastTxSync(t *testing.T, c *abci.Client, tx interface{}) *rpctypes.ResultBroadcastTx { - res, err := c.BroadcastTxSync(tx) - So(err, ShouldBeNil) - require.Zero(t, res.Code, res.Log) - return res -} - -// BroadcastTxCommit is a helper function to Broadcast a Tx under test -func BroadcastTxCommit(t *testing.T, c *abci.Client, tx interface{}) *rpctypes.ResultBroadcastTxCommit { - res, err := c.BroadcastTxCommit(tx) - So(err, ShouldBeNil) - require.True(t, res.CheckTx.IsOK(), res.CheckTx.Log) - require.True(t, res.DeliverTx.IsOK(), res.DeliverTx.Log) - return res -} - -func BroadcastNextRebalance(t *testing.T, c *abci.Client) { - params, err := c.QueryConsensusParams() - require.NoError(t, err) - - info, err := c.QueryRoundInfo() - if err != nil { - info = &types.RoundInfo{ - Number: 1, - StartsAt: 1, - EndsAt: 1, - } - } else { - info.StartsAt = info.EndsAt - } - info.EndsAt += uint64(params.PeriodLength) - - BroadcastTxCommit(t, c, &types.TransactionRebalance{RoundInfo: info}) -} diff --git a/packages/go-kosu/tests/validators_test.go b/packages/go-kosu/tests/validators_test.go new file mode 100644 index 00000000..10fa580d --- /dev/null +++ b/packages/go-kosu/tests/validators_test.go @@ -0,0 +1,63 @@ +package tests + +import ( + "encoding/hex" + "go-kosu/abci/types" +) + +func (suite *IntegrationTestSuite) TestValidators() { + initial, err := suite.Client().Validators(nil) + suite.Require().NoError(err) + + last, err := suite.Client().QueryLastEvent() + suite.Require().NoError(err) + + pubkey, err := hex.DecodeString(randomHex(64)) + suite.Require().NoError(err) + + tx := &types.TransactionWitness{ + Subject: types.TransactionWitness_VALIDATOR, + Address: randomHex(40), + PublicKey: pubkey, + Block: last, + } + + suite.Run("AddValidator", func() { + tx.Amount = types.NewBigIntFromString("1000000000000000000", 10) + + suite.WithConfirmations(tx) + + // wait for 2 blocks to make sure the validator set is updated + suite.WaitForNewBlock() + suite.WaitForNewBlock() + + res, err := suite.Client().Validators(nil) + suite.Require().NoError(err) + + suite.Equal( + len(initial.Validators)+1, + len(res.Validators), + "validator set should be updated with 1 new validator", + ) + }) + + suite.Run("RemoveValidator", func() { + tx.Block++ + tx.Amount = types.NewBigIntFromInt(0) + + suite.WithConfirmations(tx) + + // wait for 2 blocks to make sure the validator set is updated + suite.WaitForNewBlock() + suite.WaitForNewBlock() + + res, err := suite.Client().Validators(nil) + suite.Require().NoError(err) + + suite.Equal( + len(initial.Validators), + len(res.Validators), + "validator set should be equal to the initial set", + ) + }) +} diff --git a/packages/go-kosu/tests/witness_test.go b/packages/go-kosu/tests/witness_test.go index f0bb8068..a4eeb5da 100644 --- a/packages/go-kosu/tests/witness_test.go +++ b/packages/go-kosu/tests/witness_test.go @@ -1,147 +1,73 @@ package tests import ( - "context" - "testing" - - . "github.com/smartystreets/goconvey/convey" - "github.com/stretchr/testify/require" - - "github.com/tendermint/tendermint/config" - "github.com/tendermint/tendermint/privval" - tmtypes "github.com/tendermint/tendermint/types" - "go-kosu/abci" "go-kosu/abci/types" ) -func buildWitnessTx(cfg *config.Config, tx *types.TransactionWitness) *types.TransactionWitness { - priv := privval.LoadFilePV( - cfg.PrivValidatorKeyFile(), - cfg.PrivValidatorStateFile(), - ).Key - - tx.Address = priv.Address.String() - tx.PublicKey = priv.PubKey.Bytes()[5:] - return tx -} +func (suite *IntegrationTestSuite) TestWitness() { + newTx := func() *types.TransactionWitness { + last, err := suite.Client().QueryLastEvent() + suite.Require().NoError(err) -func (s *Suite) TestWitnessTxPoster() { - GivenABCIServer(s.T(), s, func(t *testing.T) { - tx := buildWitnessTx(s.config, &types.TransactionWitness{ + return &types.TransactionWitness{ Subject: types.TransactionWitness_POSTER, - Block: 10, + Block: last, Amount: types.NewBigIntFromString("1000000000000000000", 10), - }) - - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - ch, closer, err := s.client.Subscribe(ctx, "tm.event = 'Tx'") - So(err, ShouldBeNil) - defer closer() - - Convey("Broadcasting a Witness Tx with enough confirmations", func() { - BroadcastTxSync(t, s.client, tx) - - Convey("Querying Poster by Tx.Address should be found after N confirmations", func() { - <-ch + Address: randomHex(40), + } + } - p, err := s.client.QueryPoster(tx.Address) - So(err, ShouldBeNil) - require.EqualValues(t, p.Balance.BigInt(), tx.Amount.BigInt()) - }) + suite.Run("WithEnoughConfirmations", func() { + tx := newTx() + suite.WithConfirmations(tx) + suite.WaitForNewBlock() - Convey("Broadcasting a Witness Tx with smaller block number should error", func() { - tx.Block-- + poster, err := suite.Client().QueryPoster(tx.Address) + suite.Require().NoError(err) - BroadcastTxSync(t, s.client, tx) - - <-ch // discard the first tx - e := <-ch - txEvent := e.Data.(tmtypes.EventDataTx) - So(txEvent.Result.IsErr(), ShouldBeTrue) - }) - }) + suite.NotNil(poster) + suite.Equal(tx.Amount.String(), poster.Balance.String()) + }) - Convey("Broadcasting a Witness Tx without required confirmations", func() { - BroadcastTxSync(t, s.client, tx) + suite.Run("WithoutEnoughConfirmations", func() { + tx := newTx() + res, err := suite.Client().BroadcastTxCommit(tx) + suite.Require().NoError(err) + suite.Require().True(res.DeliverTx.IsOK(), res.DeliverTx.Log) - Convey("Querying Poster by Tx.Address should NOT be found after N confirmations", func() { - // <-ch + poster, err := suite.Client().QueryPoster(tx.Address) + suite.Require().Equal(abci.ErrNotFound, err) + suite.Nil(poster) - p, err := s.client.QueryPoster(tx.Address) - So(err, ShouldNotBeNil) - So(p, ShouldBeNil) - }) - }) }) -} - -func (s *Suite) TestWitnessValidator() { - GivenABCIServer(s.T(), s, func(t *testing.T) { - tx := buildWitnessTx(s.config, &types.TransactionWitness{ - Subject: types.TransactionWitness_VALIDATOR, - Block: 10, - Amount: types.NewBigIntFromString("1000000000000000000", 10), - }) - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + suite.Run("WithSmallerBlock", func() { + tx := newTx() + tx.Block-- - ch, closer, err := s.client.Subscribe(ctx, "tm.event = 'NewBlock'") - So(err, ShouldBeNil) - defer closer() + res, err := suite.Client().BroadcastTxSync(tx) + suite.Require().NoError(err) - Convey("And an initial number of validators", func() { - res, err := s.client.Validators(nil) - require.NoError(t, err) - So(res.Validators[0].VotingPower, ShouldEqual, 10) + suite.NotEqual(0, res.Code) + }) - Convey("When a Tx is broadcasted", func() { - BroadcastTxSync(t, s.client, tx) - Convey("Validator's voting power should be updated", func() { - // Wait for 2 blocks for validator set to be updated - <-ch - <-ch + suite.Run("Prunning", func() { + tx1 := newTx() + suite.BroadcastTxCommit(tx1) - res, err := s.client.Validators(nil) - require.NoError(t, err) + res, err := suite.Client().ABCIQuery("/witness/key", tx1.Hash()) + suite.Require().NoError(err) + suite.Require().NotNil(res.Response.Value) + suite.Require().NotEmpty(res.Response.Value) - So(res.Validators[0].VotingPower, ShouldEqual, 1) + tx2 := newTx() + tx2.Block = abci.GenesisAppState.ConsensusParams.BlocksBeforePruning + tx1.Block + suite.BroadcastTxCommit(tx2) - }) - }) - }) - }) -} + res, err = suite.Client().ABCIQuery("/witness/key", tx1.Hash()) + suite.Require().NoError(err) -func (s *Suite) TestWitnessTxPruning() { - GivenABCIServer(s.T(), s, func(t *testing.T) { - Convey("When a Tx#1 is broadcasted", func() { - tx := buildWitnessTx(s.config, &types.TransactionWitness{ - Subject: types.TransactionWitness_VALIDATOR, - Block: 10, - Amount: types.NewBigIntFromString("1000000000000000000", 10), - }) - txID := tx.Hash() - - BroadcastTxCommit(t, s.client, tx) - res, err := s.client.ABCIQuery("/witness/key", txID) - require.NoError(t, err) - require.Zero(t, res.Response.Code) - require.NotNil(t, res.Response.Value) - - Convey("And Tx#2 is broadcasted `BlocksBeforePruning` Ethereum blocks later", func() { - tx.Block += abci.GenesisAppState.ConsensusParams.BlocksBeforePruning - BroadcastTxCommit(t, s.client, tx) - - Convey("Tx#1 should not exist", func() { - res, err := s.client.ABCIQuery("/witness/key", txID) - require.NoError(t, err) - require.Zero(t, res.Response.Code) - }) - }) - }) + suite.Empty(res.Response.Value) }) } From f127230d8880ab35a8b77d4c278cc45b1be64b7d Mon Sep 17 00:00:00 2001 From: Gustavo Chain Date: Tue, 20 Aug 2019 13:57:41 +0200 Subject: [PATCH 02/19] go-kosu: integration test cleanup --- packages/go-kosu/tests/order_test.go | 2 + packages/go-kosu/tests/specs_test.go | 207 --------------------------- packages/go-kosu/tests/suite_test.go | 201 +++++++++++++++++++++++++- 3 files changed, 198 insertions(+), 212 deletions(-) delete mode 100644 packages/go-kosu/tests/specs_test.go diff --git a/packages/go-kosu/tests/order_test.go b/packages/go-kosu/tests/order_test.go index e7d1593d..f78631e6 100644 --- a/packages/go-kosu/tests/order_test.go +++ b/packages/go-kosu/tests/order_test.go @@ -12,6 +12,7 @@ import ( ) func NewOrderTx(t *testing.T) *types.TransactionOrder { + // nolint:lll order := `{ "subContract":"0xebe8fdf63db77e3b41b0aec8208c49fa46569606", "maker":"0xe3ec7592166d0145b9677f5f45dd1bd95ffe6596", @@ -27,6 +28,7 @@ func NewOrderTx(t *testing.T) *types.TransactionOrder { }, "makerSignature":"0xce84772cbbbe5a844c9002e6d54e53d72830b890ff1ea1521cbd86faada28aa136997b5cd3cafd85e887a9d6fc25bb2bfbe03fc6319d371b2c976f3374bcd8c300","posterSignature":"0xc3550b7ceab610e638dfb1b33e5cf7aaf9490854197328eadbe8ac049adef7510a07a0ea046fa1d410c5cc1048828152b9368a8d8925f8f0072192ebfe1bbb3101"} ` + tx := &types.TransactionOrder{} err := json.Unmarshal([]byte(order), tx) require.NoError(t, err) diff --git a/packages/go-kosu/tests/specs_test.go b/packages/go-kosu/tests/specs_test.go deleted file mode 100644 index 6e9b128b..00000000 --- a/packages/go-kosu/tests/specs_test.go +++ /dev/null @@ -1,207 +0,0 @@ -package tests - -import ( - "context" - "math/rand" - "path/filepath" - "strings" - "testing" - "time" - - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - - "github.com/tendermint/tendermint/config" - "github.com/tendermint/tendermint/privval" - rpctypes "github.com/tendermint/tendermint/rpc/core/types" - tmtypes "github.com/tendermint/tendermint/types" - - "go-kosu/abci" - "go-kosu/abci/types" -) - -func init() { - rand.Seed(time.Now().UnixNano()) -} - -type Node struct { - Client *abci.Client - Config *config.Config - PrivVal privval.FilePVKey -} - -type IntegrationTestSuite struct { - suite.Suite - - // Nodes are populated on SetupSuite based on the KOSU_TEST_NODES environment variable - // KOSU_TEST_NODES is a comma separated list of nodes following this format: - // [@url],... - // is required and points to the node home directory - // is optional and represents the node url, if not specified it will take the url from config.RPC.ListenAddress - Nodes []Node - - // CurrentBlock will be updated on each new test from the suite - CurrentBlock *tmtypes.Block -} - -// Client returns the first client out of the node list. -func (suite *IntegrationTestSuite) Client() *abci.Client { - return suite.Nodes[0].Client -} - -func (suite *IntegrationTestSuite) WaitForNewBlock() *tmtypes.Block { - events, closer, err := suite.Client().Subscribe(context.Background(), "tm.event = 'NewBlock'") - suite.Require().NoError(err) - defer closer() - - event := <-events - return event.Data.(tmtypes.EventDataNewBlock).Block -} - -// IsValidTxCommit performs assertions over a BroadcastTxCommit -func (suite *IntegrationTestSuite) IsValidTxCommit(res *rpctypes.ResultBroadcastTxCommit, err error) { - suite.Require().NoError(err) - suite.Require().True(res.CheckTx.IsOK(), res.CheckTx.Log) - suite.Require().True(res.DeliverTx.IsOK(), res.DeliverTx.Log) -} - -// IsValidTxSync performs assertions over a BroadcastTxSync -func (suite *IntegrationTestSuite) IsValidTxSync(res *rpctypes.ResultBroadcastTx, err error) { - suite.Require().NoError(err) - suite.Require().Zero(res.Code, res.Log) -} - -// BroadcastTxCommit is a helper function to Broadcast a Tx under test -func (suite *IntegrationTestSuite) BroadcastTxCommit(tx interface{}) *rpctypes.ResultBroadcastTxCommit { - res, err := suite.Client().BroadcastTxCommit(tx) - suite.IsValidTxCommit(res, err) - return res -} - -// BroadcastTxSync is a helper function to Broadcast a Tx under test -func (suite *IntegrationTestSuite) BroadcastTxSync(tx interface{}) *rpctypes.ResultBroadcastTx { - res, err := suite.Client().BroadcastTxSync(tx) - suite.IsValidTxSync(res, err) - return res -} - -// WithNode calls fn for every node defined in the node set. -// If fn returns err, the error is returned and the execution stopped. -func (suite *IntegrationTestSuite) WithNode(fn func(*Node) error) error { - for _, node := range suite.Nodes { - if err := fn(&node); err != nil { - return err - } - } - return nil -} - -// WithConfirmations Broadcast a Tx across all the nodes so that we make sure it's confirmed -func (suite *IntegrationTestSuite) WithConfirmations(tx interface{}) { - suite.WithNode(func(node *Node) error { - suite.IsValidTxSync( - node.Client.BroadcastTxSync(tx), - ) - return nil - }) -} - -// NextRoundInfo calculates the next round info based on the current one -func (suite *IntegrationTestSuite) NextRoundInfo() *types.RoundInfo { - round, err := suite.Client().QueryRoundInfo() - suite.Require().NoError(err) - - diff := round.EndsAt - round.StartsAt - round.StartsAt = round.EndsAt - round.EndsAt += diff - round.Number++ - - return round -} - -func (suite *IntegrationTestSuite) BroadcastNextRebalance() { - params, err := suite.Client().QueryConsensusParams() - suite.Require().NoError(err) - - info, err := suite.Client().QueryRoundInfo() - if err != nil { - info = &types.RoundInfo{ - Number: 0, - StartsAt: 1, - EndsAt: 1, - } - } else { - info.StartsAt = info.EndsAt - } - info.Number++ - info.EndsAt += uint64(params.PeriodLength) - - suite.BroadcastTxCommit(&types.TransactionRebalance{RoundInfo: info}) -} - -func newClient(t *testing.T, rootdir, url string) *abci.Client { - key, err := abci.LoadPrivateKey(rootdir) - require.NoError(t, err) - - client, err := abci.NewHTTPClient(url, key) - require.NoError(t, err) - - return client -} - -func (suite *IntegrationTestSuite) addNode(homedir, url string) { - cfg, err := abci.LoadConfig(homedir) - suite.Require().NoError(err) - - priv := privval.LoadFilePV( - cfg.PrivValidatorKeyFile(), - cfg.PrivValidatorStateFile(), - ).Key - - if url == "" { - url = cfg.RPC.ListenAddress - } - - suite.Nodes = append(suite.Nodes, Node{ - Client: newClient(suite.T(), homedir, url), - Config: cfg, - PrivVal: priv, - }) -} - -// SetupSuite setup the test suite -func (suite *IntegrationTestSuite) SetupSuite() { - nodes := envOrSkip(suite.T(), "KOSU_TEST_NODES") - for _, node := range strings.Split(nodes, ",") { - var homedir, url string - split := strings.Split(node, "@") - homedir = split[0] - if len(split) == 2 { - url = split[1] - } - if !filepath.IsAbs(homedir) { - suite.T().Fatalf("home dir must be absolute, got: %s", homedir) - } - - suite.addNode(homedir, url) - } -} - -// SetupTest creates a new subscriptions to `NewBlocks` and waits for a new block before each test -func (suite *IntegrationTestSuite) SetupTest() { - suite.CurrentBlock = suite.WaitForNewBlock() -} - -func (suite *IntegrationTestSuite) TearDownTest() { -} - -func (suite *IntegrationTestSuite) TearDownSuite() { - for _, node := range suite.Nodes { - err := node.Client.Stop() - suite.Require().NoError(err) - } -} - -func TestIntegrationTestSuite(t *testing.T) { - suite.Run(t, new(IntegrationTestSuite)) -} diff --git a/packages/go-kosu/tests/suite_test.go b/packages/go-kosu/tests/suite_test.go index 0099a7b9..40e58a65 100644 --- a/packages/go-kosu/tests/suite_test.go +++ b/packages/go-kosu/tests/suite_test.go @@ -1,16 +1,207 @@ package tests import ( - "go-kosu/abci" + "context" + "math/rand" + "path/filepath" + "strings" + "testing" + "time" + "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - cfg "github.com/tendermint/tendermint/config" + "github.com/tendermint/tendermint/config" + "github.com/tendermint/tendermint/privval" + rpctypes "github.com/tendermint/tendermint/rpc/core/types" + tmtypes "github.com/tendermint/tendermint/types" + + "go-kosu/abci" + "go-kosu/abci/types" ) -type Suite struct { +func init() { + rand.Seed(time.Now().UnixNano()) +} + +type Node struct { + Client *abci.Client + Config *config.Config + PrivVal privval.FilePVKey +} + +type IntegrationTestSuite struct { suite.Suite - client *abci.Client - config *cfg.Config + // Nodes are populated on SetupSuite based on the KOSU_TEST_NODES environment variable + // KOSU_TEST_NODES is a comma separated list of nodes following this format: + // [@url],... + // is required and points to the node home directory + // is optional and represents the node url, if not specified it will take the url from config.RPC.ListenAddress + Nodes []Node + + // CurrentBlock will be updated on each new test from the suite + CurrentBlock *tmtypes.Block +} + +// Client returns the first client out of the node list. +func (suite *IntegrationTestSuite) Client() *abci.Client { + return suite.Nodes[0].Client +} + +func (suite *IntegrationTestSuite) WaitForNewBlock() *tmtypes.Block { + events, closer, err := suite.Client().Subscribe(context.Background(), "tm.event = 'NewBlock'") + suite.Require().NoError(err) + defer closer() + + event := <-events + return event.Data.(tmtypes.EventDataNewBlock).Block +} + +// IsValidTxCommit performs assertions over a BroadcastTxCommit +func (suite *IntegrationTestSuite) IsValidTxCommit(res *rpctypes.ResultBroadcastTxCommit, err error) { + suite.Require().NoError(err) + suite.Require().True(res.CheckTx.IsOK(), res.CheckTx.Log) + suite.Require().True(res.DeliverTx.IsOK(), res.DeliverTx.Log) +} + +// IsValidTxSync performs assertions over a BroadcastTxSync +func (suite *IntegrationTestSuite) IsValidTxSync(res *rpctypes.ResultBroadcastTx, err error) { + suite.Require().NoError(err) + suite.Require().Zero(res.Code, res.Log) +} + +// BroadcastTxCommit is a helper function to Broadcast a Tx under test +func (suite *IntegrationTestSuite) BroadcastTxCommit(tx interface{}) *rpctypes.ResultBroadcastTxCommit { + res, err := suite.Client().BroadcastTxCommit(tx) + suite.IsValidTxCommit(res, err) + return res +} + +// BroadcastTxSync is a helper function to Broadcast a Tx under test +func (suite *IntegrationTestSuite) BroadcastTxSync(tx interface{}) *rpctypes.ResultBroadcastTx { + res, err := suite.Client().BroadcastTxSync(tx) + suite.IsValidTxSync(res, err) + return res +} + +// WithNode calls fn for every node defined in the node set. +// If fn returns err, the error is returned and the execution stopped. +func (suite *IntegrationTestSuite) WithNode(fn func(*Node) error) error { + for _, node := range suite.Nodes { + if err := fn(&node); err != nil { + return err + } + } + return nil +} + +// WithConfirmations Broadcast a Tx across all the nodes so that we make sure it's confirmed +func (suite *IntegrationTestSuite) WithConfirmations(tx interface{}) { + _ = suite.WithNode(func(node *Node) error { + suite.IsValidTxSync( + node.Client.BroadcastTxSync(tx), + ) + return nil + }) +} + +// NextRoundInfo calculates the next round info based on the current one +func (suite *IntegrationTestSuite) NextRoundInfo() *types.RoundInfo { + round, err := suite.Client().QueryRoundInfo() + suite.Require().NoError(err) + + diff := round.EndsAt - round.StartsAt + round.StartsAt = round.EndsAt + round.EndsAt += diff + round.Number++ + + return round +} + +func (suite *IntegrationTestSuite) BroadcastNextRebalance() { + params, err := suite.Client().QueryConsensusParams() + suite.Require().NoError(err) + + info, err := suite.Client().QueryRoundInfo() + if err != nil { + info = &types.RoundInfo{ + Number: 0, + StartsAt: 1, + EndsAt: 1, + } + } else { + info.StartsAt = info.EndsAt + } + info.Number++ + info.EndsAt += uint64(params.PeriodLength) + + suite.BroadcastTxCommit(&types.TransactionRebalance{RoundInfo: info}) +} + +func newClient(t *testing.T, rootdir, url string) *abci.Client { + key, err := abci.LoadPrivateKey(rootdir) + require.NoError(t, err) + + client, err := abci.NewHTTPClient(url, key) + require.NoError(t, err) + + return client +} + +func (suite *IntegrationTestSuite) addNode(homedir, url string) { + cfg, err := abci.LoadConfig(homedir) + suite.Require().NoError(err) + + priv := privval.LoadFilePV( + cfg.PrivValidatorKeyFile(), + cfg.PrivValidatorStateFile(), + ).Key + + if url == "" { + url = cfg.RPC.ListenAddress + } + + suite.Nodes = append(suite.Nodes, Node{ + Client: newClient(suite.T(), homedir, url), + Config: cfg, + PrivVal: priv, + }) +} + +// SetupSuite setup the test suite +func (suite *IntegrationTestSuite) SetupSuite() { + nodes := envOrSkip(suite.T(), "KOSU_TEST_NODES") + for _, node := range strings.Split(nodes, ",") { + var homedir, url string + split := strings.Split(node, "@") + homedir = split[0] + if len(split) == 2 { + url = split[1] + } + if !filepath.IsAbs(homedir) { + suite.T().Fatalf("home dir must be absolute, got: %s", homedir) + } + + suite.addNode(homedir, url) + } +} + +// SetupTest creates a new subscriptions to `NewBlocks` and waits for a new block before each test +func (suite *IntegrationTestSuite) SetupTest() { + suite.CurrentBlock = suite.WaitForNewBlock() +} + +func (suite *IntegrationTestSuite) TearDownTest() { +} + +func (suite *IntegrationTestSuite) TearDownSuite() { + for _, node := range suite.Nodes { + err := node.Client.Stop() + suite.Require().NoError(err) + } +} + +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) } From a5f851851a05e0d7fa76174dfb3f2d98853b3f8a Mon Sep 17 00:00:00 2001 From: Gustavo Chain Date: Tue, 20 Aug 2019 14:45:07 +0200 Subject: [PATCH 03/19] go-kosu: update drone.yml --- .drone.yml | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/.drone.yml b/.drone.yml index 8718b4e7..c1ec7127 100644 --- a/.drone.yml +++ b/.drone.yml @@ -27,26 +27,6 @@ steps: depends_on: - clone - - name: npm-tests - image: gcr.io/kosu-io/node-lts:latest - pull: always - environment: - WEB3_URI: http://kosu-geth:8545 - commands: - - yarn test:ci - depends_on: - - build-project - - - name: solidity-tests - image: gcr.io/kosu-io/node-lts:latest - pull: always - environment: - WEB3_URI: http://kosu-geth:8545 - commands: - - yarn contracts:test:ci - depends_on: - - build-project - - name: go-kosu image: gcr.io/kosu-io/go-kosu-ci:latest pull: always @@ -54,7 +34,7 @@ steps: WEB3_TEST_URI: ws://kosu-geth:8546 commands: - cd packages/go-kosu - - make ci + - make testnet depends_on: - build-project From 6c85b72715d32202b9053d70a8d8578b912c6b0d Mon Sep 17 00:00:00 2001 From: Henry Harder Date: Wed, 21 Aug 2019 14:25:16 -0700 Subject: [PATCH 04/19] test potential drone config for testnet --- .drone.yml | 65 +++++++++++++++++++++++++---- packages/go-kosu/Dockerfile.compose | 10 ++--- 2 files changed, 63 insertions(+), 12 deletions(-) diff --git a/.drone.yml b/.drone.yml index c1ec7127..82f106e3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -27,6 +27,46 @@ steps: depends_on: - clone + - name: kosu-node-0 + image: gcr.io/kosu-io/go-kosu-ci:latest + pull: always + detach: true + depends_on: + - build-project + commands: + - cd packages/go-kosu + - ./kosud -H ./testnet/node0 -E ws://go-kosu-ci-geth:8546 + + - name: kosu-node-1 + image: gcr.io/kosu-io/go-kosu-ci:latest + pull: always + detach: true + depends_on: + - build-project + commands: + - cd packages/go-kosu + - ./kosud -H ./testnet/node1 -E ws://go-kosu-ci-geth:8546 + + - name: kosu-node-2 + image: gcr.io/kosu-io/go-kosu-ci:latest + pull: always + detach: true + depends_on: + - build-project + commands: + - cd packages/go-kosu + - ./kosud -H ./testnet/node2 -E ws://go-kosu-ci-geth:8546 + + - name: kosu-node-3 + image: gcr.io/kosu-io/go-kosu-ci:latest + pull: always + detach: true + depends_on: + - build-project + commands: + - cd packages/go-kosu + - ./kosud -H ./testnet/node3 -E ws://go-kosu-ci-geth:8546 + - name: go-kosu image: gcr.io/kosu-io/go-kosu-ci:latest pull: always @@ -34,17 +74,28 @@ steps: WEB3_TEST_URI: ws://kosu-geth:8546 commands: - cd packages/go-kosu - - make testnet + - make ci depends_on: - build-project + - node0 + - node1 + - node2 + - node3 + services: - - name: kosu-geth - image: gcr.io/kosu-io/kosu-geth:0.1.1 - pull: always - ports: - - 8545 - - 8546 + - name: kosu-geth + image: gcr.io/kosu-io/kosu-geth:0.1.1 + pull: always + ports: + - 8545 + - 8546 + + - name: go-kosu-ci-geth + image: gcr.io/kosu-io/kosu-geth:0.1.1 + pull: always + ports: + - 8546 trigger: event: diff --git a/packages/go-kosu/Dockerfile.compose b/packages/go-kosu/Dockerfile.compose index adab0a63..aa90eae8 100644 --- a/packages/go-kosu/Dockerfile.compose +++ b/packages/go-kosu/Dockerfile.compose @@ -1,11 +1,11 @@ FROM golang:1.12 WORKDIR /go-kosu -COPY kosud . -COPY kosu-cli . -COPY ./testnet/ ./testnet/ +# COPY kosud . +# COPY kosu-cli . +# COPY ./testnet/ ./testnet/ -#COPY . . -#RUN make +COPY . . +RUN go build -o kosud ./cmd/kosud CMD ./kosud From 3ed7a785cd48bb970368c86cd980b01b8a34eced Mon Sep 17 00:00:00 2001 From: Henry Harder Date: Wed, 21 Aug 2019 14:27:17 -0700 Subject: [PATCH 05/19] migrate to second contract system server --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 82f106e3..20387a23 100644 --- a/.drone.yml +++ b/.drone.yml @@ -24,6 +24,7 @@ steps: - yarn setup:ci - cd packages/kosu-system-contracts - yarn migrate:ci + - WEB3_URI=http://go-kosu-ci-geth:8545 yarn migrate:ci depends_on: - clone From abb2e0d513620dbcb28cd537858a68ab8504e1ed Mon Sep 17 00:00:00 2001 From: Henry Harder Date: Wed, 21 Aug 2019 15:10:14 -0700 Subject: [PATCH 06/19] fixing dronefile syntax --- .drone.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.drone.yml b/.drone.yml index 20387a23..866077a3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -59,14 +59,14 @@ steps: - ./kosud -H ./testnet/node2 -E ws://go-kosu-ci-geth:8546 - name: kosu-node-3 - image: gcr.io/kosu-io/go-kosu-ci:latest - pull: always - detach: true - depends_on: + image: gcr.io/kosu-io/go-kosu-ci:latest + pull: always + detach: true + depends_on: - build-project - commands: - - cd packages/go-kosu - - ./kosud -H ./testnet/node3 -E ws://go-kosu-ci-geth:8546 + commands: + - cd packages/go-kosu + - ./kosud -H ./testnet/node3 -E ws://go-kosu-ci-geth:8546 - name: go-kosu image: gcr.io/kosu-io/go-kosu-ci:latest From 9350ae78d5a11e5ef2143ee9ba67ab01c0b73179 Mon Sep 17 00:00:00 2001 From: Henry Harder Date: Wed, 21 Aug 2019 15:11:05 -0700 Subject: [PATCH 07/19] fixing node step names --- .drone.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index 866077a3..77f95cb4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -78,10 +78,10 @@ steps: - make ci depends_on: - build-project - - node0 - - node1 - - node2 - - node3 + - kosu-node-0 + - kosu-node-1 + - kosu-node-2 + - kosu-node-3 services: From 867bfeb24bbebb9435becbe368cfddae47b8cca1 Mon Sep 17 00:00:00 2001 From: Henry Harder Date: Wed, 21 Aug 2019 15:25:05 -0700 Subject: [PATCH 08/19] add verbose flag to GOTEST_FLAGS --- packages/go-kosu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/go-kosu/Makefile b/packages/go-kosu/Makefile index 500036a4..b5a1058f 100644 --- a/packages/go-kosu/Makefile +++ b/packages/go-kosu/Makefile @@ -1,4 +1,4 @@ -GOTEST_FLAGS ?= +GOTEST_FLAGS ?= -v GOTEST_TAGS ?= integration GOTEST = go test ./... ${GOTEST_FLAGS} From 7366970f18d509f6ada78dfc4bb206e2530bc419 Mon Sep 17 00:00:00 2001 From: Henry Harder Date: Wed, 21 Aug 2019 15:52:58 -0700 Subject: [PATCH 09/19] add required environment variable for int. tests --- .drone.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index d8b1137e..1ff04c34 100644 --- a/.drone.yml +++ b/.drone.yml @@ -68,13 +68,19 @@ steps: - cd packages/go-kosu - ./kosud -H ./testnet/node3 -E ws://go-kosu-ci-geth:8546 - - name: go-kosu + - name: go-kosu-tests image: gcr.io/kosu-io/go-kosu-ci:latest pull: always environment: WEB3_TEST_URI: ws://kosu-geth:8546 commands: - cd packages/go-kosu + - | + export KOSU_TEST_NODES=\ + $(pwd)/testnet/node0@kosu-node-1:26657,\ + $(pwd)/testnet/node1@kosu-node-1:26657,\ + $(pwd)/testnet/node2@kosu-node-1:26657,\ + $(pwd)/testnet/node3@kosu-node-1:26657 - make ci depends_on: - build-project From 5008ef43dbb9d8fd8527c9428d919c3fc37b73a1 Mon Sep 17 00:00:00 2001 From: Henry Harder Date: Wed, 21 Aug 2019 15:53:34 -0700 Subject: [PATCH 10/19] use alternate go-kosu geth image for web3 --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 1ff04c34..fb5a4243 100644 --- a/.drone.yml +++ b/.drone.yml @@ -72,7 +72,7 @@ steps: image: gcr.io/kosu-io/go-kosu-ci:latest pull: always environment: - WEB3_TEST_URI: ws://kosu-geth:8546 + WEB3_TEST_URI: ws://go-kosu-ci-geth:8546 commands: - cd packages/go-kosu - | From 115968bfacc51612474a6c6742338d711fb27d36 Mon Sep 17 00:00:00 2001 From: Henry Harder Date: Wed, 21 Aug 2019 17:20:23 -0700 Subject: [PATCH 11/19] fix export command --- .drone.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index fb5a4243..2d948a95 100644 --- a/.drone.yml +++ b/.drone.yml @@ -75,12 +75,7 @@ steps: WEB3_TEST_URI: ws://go-kosu-ci-geth:8546 commands: - cd packages/go-kosu - - | - export KOSU_TEST_NODES=\ - $(pwd)/testnet/node0@kosu-node-1:26657,\ - $(pwd)/testnet/node1@kosu-node-1:26657,\ - $(pwd)/testnet/node2@kosu-node-1:26657,\ - $(pwd)/testnet/node3@kosu-node-1:26657 + - export KOSU_TEST_NODES=$(pwd)/testnet/node0@kosu-node-1:26657,$(pwd)/testnet/node1@kosu-node-1:26657,$(pwd)/testnet/node2@kosu-node-1:26657,$(pwd)/testnet/node3@kosu-node-1:26657 - make ci depends_on: - build-project From 7b8ffc59341ebaf3e38d87bce071a4b126c3a1c8 Mon Sep 17 00:00:00 2001 From: Henry Harder Date: Wed, 21 Aug 2019 17:23:38 -0700 Subject: [PATCH 12/19] update hostnames for persistent peers --- .drone.yml | 1 - packages/go-kosu/docker-compose.yml | 11 +++++------ packages/go-kosu/testnet/node0/config/config.toml | 2 +- packages/go-kosu/testnet/node1/config/config.toml | 2 +- packages/go-kosu/testnet/node2/config/config.toml | 2 +- packages/go-kosu/testnet/node3/config/config.toml | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.drone.yml b/.drone.yml index 2d948a95..6fd4897d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -83,7 +83,6 @@ steps: - kosu-node-1 - kosu-node-2 - kosu-node-3 - services: - name: kosu-geth diff --git a/packages/go-kosu/docker-compose.yml b/packages/go-kosu/docker-compose.yml index 0857d949..07c33f15 100644 --- a/packages/go-kosu/docker-compose.yml +++ b/packages/go-kosu/docker-compose.yml @@ -2,7 +2,7 @@ version: '3' services: node0: - container_name: node0 + container_name: kosu-node-0 build: context: . dockerfile: Dockerfile.compose @@ -14,7 +14,7 @@ services: ipv4_address: 192.167.10.2 node1: - container_name: node1 + container_name: kosu-node-1 build: context: . dockerfile: Dockerfile.compose @@ -26,7 +26,7 @@ services: ipv4_address: 192.167.10.3 node2: - container_name: node2 + container_name: kosu-node-2 build: context: . dockerfile: Dockerfile.compose @@ -38,7 +38,7 @@ services: ipv4_address: 192.167.10.4 node3: - container_name: node3 + container_name: kosu-node-3 build: context: . dockerfile: Dockerfile.compose @@ -55,5 +55,4 @@ networks: ipam: driver: default config: - - - subnet: 192.167.10.0/16 + - subnet: 192.167.10.0/16 diff --git a/packages/go-kosu/testnet/node0/config/config.toml b/packages/go-kosu/testnet/node0/config/config.toml index 6ebcdec1..e526129c 100644 --- a/packages/go-kosu/testnet/node0/config/config.toml +++ b/packages/go-kosu/testnet/node0/config/config.toml @@ -142,7 +142,7 @@ external_address = "" seeds = "" # Comma separated list of nodes to keep persistent connections to -persistent_peers = "4858315c384a60d3664f8c2afa4270e8ef2e1864@192.167.10.2:26656,73df76c913c65763cb37038758e1e6e9b6e55e9b@192.167.10.3:26656,06baf318001f3c0694560a24c849b2a0a58ec233@192.167.10.4:26656,386ee942c2acd02092783d20105ac84caeab7903@192.167.10.5:26656" +persistent_peers = "4858315c384a60d3664f8c2afa4270e8ef2e1864@kosu-node-0:26656,73df76c913c65763cb37038758e1e6e9b6e55e9b@kosu-node-1:26656,06baf318001f3c0694560a24c849b2a0a58ec233@kosu-node-2:26656,386ee942c2acd02092783d20105ac84caeab7903@kosu-node-3:26656" # UPNP port forwarding upnp = false diff --git a/packages/go-kosu/testnet/node1/config/config.toml b/packages/go-kosu/testnet/node1/config/config.toml index 00db51cf..7e593093 100644 --- a/packages/go-kosu/testnet/node1/config/config.toml +++ b/packages/go-kosu/testnet/node1/config/config.toml @@ -142,7 +142,7 @@ external_address = "" seeds = "" # Comma separated list of nodes to keep persistent connections to -persistent_peers = "4858315c384a60d3664f8c2afa4270e8ef2e1864@192.167.10.2:26656,73df76c913c65763cb37038758e1e6e9b6e55e9b@192.167.10.3:26656,06baf318001f3c0694560a24c849b2a0a58ec233@192.167.10.4:26656,386ee942c2acd02092783d20105ac84caeab7903@192.167.10.5:26656" +persistent_peers = "4858315c384a60d3664f8c2afa4270e8ef2e1864@kosu-node-0:26656,73df76c913c65763cb37038758e1e6e9b6e55e9b@kosu-node-1:26656,06baf318001f3c0694560a24c849b2a0a58ec233@kosu-node-2:26656,386ee942c2acd02092783d20105ac84caeab7903@kosu-node-3:26656" # UPNP port forwarding upnp = false diff --git a/packages/go-kosu/testnet/node2/config/config.toml b/packages/go-kosu/testnet/node2/config/config.toml index 00db51cf..7e593093 100644 --- a/packages/go-kosu/testnet/node2/config/config.toml +++ b/packages/go-kosu/testnet/node2/config/config.toml @@ -142,7 +142,7 @@ external_address = "" seeds = "" # Comma separated list of nodes to keep persistent connections to -persistent_peers = "4858315c384a60d3664f8c2afa4270e8ef2e1864@192.167.10.2:26656,73df76c913c65763cb37038758e1e6e9b6e55e9b@192.167.10.3:26656,06baf318001f3c0694560a24c849b2a0a58ec233@192.167.10.4:26656,386ee942c2acd02092783d20105ac84caeab7903@192.167.10.5:26656" +persistent_peers = "4858315c384a60d3664f8c2afa4270e8ef2e1864@kosu-node-0:26656,73df76c913c65763cb37038758e1e6e9b6e55e9b@kosu-node-1:26656,06baf318001f3c0694560a24c849b2a0a58ec233@kosu-node-2:26656,386ee942c2acd02092783d20105ac84caeab7903@kosu-node-3:26656" # UPNP port forwarding upnp = false diff --git a/packages/go-kosu/testnet/node3/config/config.toml b/packages/go-kosu/testnet/node3/config/config.toml index 00db51cf..7e593093 100644 --- a/packages/go-kosu/testnet/node3/config/config.toml +++ b/packages/go-kosu/testnet/node3/config/config.toml @@ -142,7 +142,7 @@ external_address = "" seeds = "" # Comma separated list of nodes to keep persistent connections to -persistent_peers = "4858315c384a60d3664f8c2afa4270e8ef2e1864@192.167.10.2:26656,73df76c913c65763cb37038758e1e6e9b6e55e9b@192.167.10.3:26656,06baf318001f3c0694560a24c849b2a0a58ec233@192.167.10.4:26656,386ee942c2acd02092783d20105ac84caeab7903@192.167.10.5:26656" +persistent_peers = "4858315c384a60d3664f8c2afa4270e8ef2e1864@kosu-node-0:26656,73df76c913c65763cb37038758e1e6e9b6e55e9b@kosu-node-1:26656,06baf318001f3c0694560a24c849b2a0a58ec233@kosu-node-2:26656,386ee942c2acd02092783d20105ac84caeab7903@kosu-node-3:26656" # UPNP port forwarding upnp = false From 92fb51dd0f9a82b122591b346d087c67b2a2faca Mon Sep 17 00:00:00 2001 From: Gustavo Chain Date: Thu, 22 Aug 2019 12:24:25 +0200 Subject: [PATCH 13/19] Fully move .drone to jsonnet definitions --- .drone.jsonnet | 72 ++++++++++++++++++++++++++++++ .drone.yml | 117 ------------------------------------------------- 2 files changed, 72 insertions(+), 117 deletions(-) create mode 100644 .drone.jsonnet delete mode 100644 .drone.yml diff --git a/.drone.jsonnet b/.drone.jsonnet new file mode 100644 index 00000000..2163dea1 --- /dev/null +++ b/.drone.jsonnet @@ -0,0 +1,72 @@ +local Image(name, image) = { + name: name, + image: "gcr.io/kosu-io/" + image, + pull: "always", + environment: { + WEB3_URI: "http://kosu-geth:8545" + } +}; + +local KosuNode(id) = Image("kosu-node-"+id, "go-kosu-ci:latest") { + detach: true, + depends_on: ["build_project"], + commands: [ + "cd packages/go-kosu", + './kosud -H ./testnet/node%(id)s -E ws://go-kosu-ci-geth:8546' %id, + ] +}; + +local KosuGEth(name) = Image(name, "kosu-geth:0.1.1") { + ports: [8545, 8546] +}; + +{ + "kind": "pipeline", + "name": "tests", + "steps": [ + Image("prettier_project", "node-lts:latest") { + "commands": ["yarn prettier:ci"], + "depends_on": ["clone"], + }, + + Image("build-project", "node-lts:latest") { + "commands": [ + "yarn", + "yarn setup:ci", + "cd packages/kosu-system-contracts", + "yarn migrate:ci", + "WEB3_URI=http://go-kosu-ci-geth:8545 yarn migrate:ci" + ], + "depends_on": ["clone"] + }, + + Image("npm-tests", "node-lts:latest") { + "commands": [ "yarn test:ci" ], + "depends_on": [ "build-project" ], + }, + + Image("solidity", "node-lts:latest") { + "commands": [ "yarn contracts:test:ci" ], + "depends_on": [ "build-project" ], + }, + + KosuNode(0), KosuNode(1), KosuNode(2), KosuNode(3), + Image("go-kosu", "go-kosu-ci:latest") { + "commands": [ + "cd packages/go-kosu", + "export KOSU_TEST_NODES=$(pwd)/testnet/node0@kosu-node-1:26657,$(pwd)/testnet/node1@kosu-node-1:26657,$(pwd)/testnet/node2@kosu-node-1:26657,$(pwd)/testnet/node3@kosu-node-1:26657", + "make ci" + ], + "depends_on": ["build-project", "kosu-node-0", "kosu-node-1","kosu-node-2","kosu-node-3"] + }, + ], + + "services": [ + KosuGEth("kosu-geth"), + KosuGEth("go-kosu-ci-geth"), + ], + + "trigger": { + "event": [ "pull_request" ] + }, +} diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 6fd4897d..00000000 --- a/.drone.yml +++ /dev/null @@ -1,117 +0,0 @@ -# Kosu monorepo CI config file (last updated: 24 June 2019) - -kind: pipeline -name: tests - -steps: - - name: prettier-project - image: gcr.io/kosu-io/node-lts:latest - pull: always - environment: - WEB3_URI: http://kosu-geth:8545 - commands: - - yarn prettier:ci - depends_on: - - clone - - - name: build-project - image: gcr.io/kosu-io/node-lts:latest - pull: always - environment: - WEB3_URI: http://kosu-geth:8545 - commands: - - yarn - - yarn setup:ci - - cd packages/kosu-system-contracts - - yarn migrate:ci - - WEB3_URI=http://go-kosu-ci-geth:8545 yarn migrate:ci - depends_on: - - clone - - - name: kosu-node-0 - image: gcr.io/kosu-io/go-kosu-ci:latest - pull: always - detach: true - depends_on: - - build-project - commands: - - cd packages/go-kosu - - ./kosud -H ./testnet/node0 -E ws://go-kosu-ci-geth:8546 - - - name: kosu-node-1 - image: gcr.io/kosu-io/go-kosu-ci:latest - pull: always - detach: true - depends_on: - - build-project - commands: - - cd packages/go-kosu - - ./kosud -H ./testnet/node1 -E ws://go-kosu-ci-geth:8546 - - - name: kosu-node-2 - image: gcr.io/kosu-io/go-kosu-ci:latest - pull: always - detach: true - depends_on: - - build-project - commands: - - cd packages/go-kosu - - ./kosud -H ./testnet/node2 -E ws://go-kosu-ci-geth:8546 - - - name: kosu-node-3 - image: gcr.io/kosu-io/go-kosu-ci:latest - pull: always - detach: true - depends_on: - - build-project - commands: - - cd packages/go-kosu - - ./kosud -H ./testnet/node3 -E ws://go-kosu-ci-geth:8546 - - - name: go-kosu-tests - image: gcr.io/kosu-io/go-kosu-ci:latest - pull: always - environment: - WEB3_TEST_URI: ws://go-kosu-ci-geth:8546 - commands: - - cd packages/go-kosu - - export KOSU_TEST_NODES=$(pwd)/testnet/node0@kosu-node-1:26657,$(pwd)/testnet/node1@kosu-node-1:26657,$(pwd)/testnet/node2@kosu-node-1:26657,$(pwd)/testnet/node3@kosu-node-1:26657 - - make ci - depends_on: - - build-project - - kosu-node-0 - - kosu-node-1 - - kosu-node-2 - - kosu-node-3 - -services: - - name: kosu-geth - image: gcr.io/kosu-io/kosu-geth:0.1.1 - pull: always - ports: - - 8545 - - 8546 - - - name: go-kosu-ci-geth - image: gcr.io/kosu-io/kosu-geth:0.1.1 - pull: always - ports: - - 8545 - - 8546 - -trigger: - event: - - pull_request - -# UNTESTED -# --- -# kind: pipeline -# name: go-kosu-release -# -# release: -# image: golang:1.12 -# secrets: [github_token] -# commands: -# curl -sL https://git.io/goreleaser | bash -# when: -# event: tag From 5f118e054d157377edf223defb3b32a86cc11642 Mon Sep 17 00:00:00 2001 From: Gustavo Chain Date: Thu, 22 Aug 2019 12:45:07 +0200 Subject: [PATCH 14/19] readd autogenerated .drone.yml --- .drone.yml | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 00000000..86c8978a --- /dev/null +++ b/.drone.yml @@ -0,0 +1,141 @@ +--- +kind: pipeline +name: tests + +platform: + os: linux + arch: amd64 + +steps: +- name: prettier_project + pull: always + image: gcr.io/kosu-io/node-lts:latest + commands: + - yarn prettier:ci + environment: + WEB3_URI: http://kosu-geth:8545 + depends_on: + - clone + +- name: build-project + pull: always + image: gcr.io/kosu-io/node-lts:latest + commands: + - yarn + - yarn setup:ci + - cd packages/kosu-system-contracts + - yarn migrate:ci + - WEB3_URI=http://go-kosu-ci-geth:8545 yarn migrate:ci + environment: + WEB3_URI: http://kosu-geth:8545 + depends_on: + - clone + +- name: npm-tests + pull: always + image: gcr.io/kosu-io/node-lts:latest + commands: + - yarn test:ci + environment: + WEB3_URI: http://kosu-geth:8545 + depends_on: + - build-project + +- name: solidity + pull: always + image: gcr.io/kosu-io/node-lts:latest + commands: + - yarn contracts:test:ci + environment: + WEB3_URI: http://kosu-geth:8545 + depends_on: + - build-project + +- name: kosu-node-0 + pull: always + image: gcr.io/kosu-io/go-kosu-ci:latest + detach: true + commands: + - cd packages/go-kosu + - ./kosud -H ./testnet/node0 -E ws://go-kosu-ci-geth:8546 + environment: + WEB3_URI: http://kosu-geth:8545 + depends_on: + - build_project + +- name: kosu-node-1 + pull: always + image: gcr.io/kosu-io/go-kosu-ci:latest + detach: true + commands: + - cd packages/go-kosu + - ./kosud -H ./testnet/node1 -E ws://go-kosu-ci-geth:8546 + environment: + WEB3_URI: http://kosu-geth:8545 + depends_on: + - build_project + +- name: kosu-node-2 + pull: always + image: gcr.io/kosu-io/go-kosu-ci:latest + detach: true + commands: + - cd packages/go-kosu + - ./kosud -H ./testnet/node2 -E ws://go-kosu-ci-geth:8546 + environment: + WEB3_URI: http://kosu-geth:8545 + depends_on: + - build_project + +- name: kosu-node-3 + pull: always + image: gcr.io/kosu-io/go-kosu-ci:latest + detach: true + commands: + - cd packages/go-kosu + - ./kosud -H ./testnet/node3 -E ws://go-kosu-ci-geth:8546 + environment: + WEB3_URI: http://kosu-geth:8545 + depends_on: + - build_project + +- name: go-kosu + pull: always + image: gcr.io/kosu-io/go-kosu-ci:latest + commands: + - cd packages/go-kosu + - export KOSU_TEST_NODES=$(pwd)/testnet/node0@kosu-node-1:26657,$(pwd)/testnet/node1@kosu-node-1:26657,$(pwd)/testnet/node2@kosu-node-1:26657,$(pwd)/testnet/node3@kosu-node-1:26657 + - make ci + environment: + WEB3_URI: http://kosu-geth:8545 + depends_on: + - build-project + - kosu-node-0 + - kosu-node-1 + - kosu-node-2 + - kosu-node-3 + +services: +- name: kosu-geth + pull: always + image: gcr.io/kosu-io/kosu-geth:0.1.1 + environment: + WEB3_URI: http://kosu-geth:8545 + ports: + - 8545 + - 8546 + +- name: go-kosu-ci-geth + pull: always + image: gcr.io/kosu-io/kosu-geth:0.1.1 + environment: + WEB3_URI: http://kosu-geth:8545 + ports: + - 8545 + - 8546 + +trigger: + event: + - pull_request + +... From 5012b357a99aad06bbba08d69b26813ad35983a7 Mon Sep 17 00:00:00 2001 From: Henry Harder Date: Thu, 22 Aug 2019 09:48:08 -0700 Subject: [PATCH 15/19] change "_" to "-" --- .drone.jsonnet | 8 ++++---- .drone.yml | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 2163dea1..f768e72b 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -9,14 +9,14 @@ local Image(name, image) = { local KosuNode(id) = Image("kosu-node-"+id, "go-kosu-ci:latest") { detach: true, - depends_on: ["build_project"], + depends_on: ["build-project"], commands: [ "cd packages/go-kosu", './kosud -H ./testnet/node%(id)s -E ws://go-kosu-ci-geth:8546' %id, ] }; -local KosuGEth(name) = Image(name, "kosu-geth:0.1.1") { +local KosuGeth(name) = Image(name, "kosu-geth:0.1.1") { ports: [8545, 8546] }; @@ -62,8 +62,8 @@ local KosuGEth(name) = Image(name, "kosu-geth:0.1.1") { ], "services": [ - KosuGEth("kosu-geth"), - KosuGEth("go-kosu-ci-geth"), + KosuGeth("kosu-geth"), + KosuGeth("go-kosu-ci-geth"), ], "trigger": { diff --git a/.drone.yml b/.drone.yml index 86c8978a..21d9c0dd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -61,7 +61,7 @@ steps: environment: WEB3_URI: http://kosu-geth:8545 depends_on: - - build_project + - build-project - name: kosu-node-1 pull: always @@ -73,7 +73,7 @@ steps: environment: WEB3_URI: http://kosu-geth:8545 depends_on: - - build_project + - build-project - name: kosu-node-2 pull: always @@ -85,7 +85,7 @@ steps: environment: WEB3_URI: http://kosu-geth:8545 depends_on: - - build_project + - build-project - name: kosu-node-3 pull: always @@ -97,14 +97,14 @@ steps: environment: WEB3_URI: http://kosu-geth:8545 depends_on: - - build_project + - build-project - name: go-kosu pull: always image: gcr.io/kosu-io/go-kosu-ci:latest commands: - cd packages/go-kosu - - export KOSU_TEST_NODES=$(pwd)/testnet/node0@kosu-node-1:26657,$(pwd)/testnet/node1@kosu-node-1:26657,$(pwd)/testnet/node2@kosu-node-1:26657,$(pwd)/testnet/node3@kosu-node-1:26657 + - "export KOSU_TEST_NODES=$(pwd)/testnet/node0@kosu-node-1:26657,$(pwd)/testnet/node1@kosu-node-1:26657,$(pwd)/testnet/node2@kosu-node-1:26657,$(pwd)/testnet/node3@kosu-node-1:26657" - make ci environment: WEB3_URI: http://kosu-geth:8545 From 4b0067028ca8517e045d6d1b2900703cb4d8f1ab Mon Sep 17 00:00:00 2001 From: Gustavo Chain Date: Thu, 22 Aug 2019 22:41:10 +0200 Subject: [PATCH 16/19] go-kosu: witness ethereum tests uses WS endpoint --- .drone.jsonnet | 3 +- .drone.yml | 13 ++- packages/go-kosu/witness/eth.go.orig | 119 --------------------------- packages/go-kosu/witness/eth_test.go | 3 +- 4 files changed, 16 insertions(+), 122 deletions(-) delete mode 100644 packages/go-kosu/witness/eth.go.orig diff --git a/.drone.jsonnet b/.drone.jsonnet index f768e72b..d8e93aae 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -3,7 +3,8 @@ local Image(name, image) = { image: "gcr.io/kosu-io/" + image, pull: "always", environment: { - WEB3_URI: "http://kosu-geth:8545" + WEB3_URI: "http://kosu-geth:8545", + WEB3_URI_WS: "ws://kosu-geth:8546", } }; diff --git a/.drone.yml b/.drone.yml index 21d9c0dd..6f1a7dfa 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,6 +14,7 @@ steps: - yarn prettier:ci environment: WEB3_URI: http://kosu-geth:8545 + WEB3_URI_WS: ws://kosu-geth:8546 depends_on: - clone @@ -28,6 +29,7 @@ steps: - WEB3_URI=http://go-kosu-ci-geth:8545 yarn migrate:ci environment: WEB3_URI: http://kosu-geth:8545 + WEB3_URI_WS: ws://kosu-geth:8546 depends_on: - clone @@ -38,6 +40,7 @@ steps: - yarn test:ci environment: WEB3_URI: http://kosu-geth:8545 + WEB3_URI_WS: ws://kosu-geth:8546 depends_on: - build-project @@ -48,6 +51,7 @@ steps: - yarn contracts:test:ci environment: WEB3_URI: http://kosu-geth:8545 + WEB3_URI_WS: ws://kosu-geth:8546 depends_on: - build-project @@ -60,6 +64,7 @@ steps: - ./kosud -H ./testnet/node0 -E ws://go-kosu-ci-geth:8546 environment: WEB3_URI: http://kosu-geth:8545 + WEB3_URI_WS: ws://kosu-geth:8546 depends_on: - build-project @@ -72,6 +77,7 @@ steps: - ./kosud -H ./testnet/node1 -E ws://go-kosu-ci-geth:8546 environment: WEB3_URI: http://kosu-geth:8545 + WEB3_URI_WS: ws://kosu-geth:8546 depends_on: - build-project @@ -84,6 +90,7 @@ steps: - ./kosud -H ./testnet/node2 -E ws://go-kosu-ci-geth:8546 environment: WEB3_URI: http://kosu-geth:8545 + WEB3_URI_WS: ws://kosu-geth:8546 depends_on: - build-project @@ -96,6 +103,7 @@ steps: - ./kosud -H ./testnet/node3 -E ws://go-kosu-ci-geth:8546 environment: WEB3_URI: http://kosu-geth:8545 + WEB3_URI_WS: ws://kosu-geth:8546 depends_on: - build-project @@ -104,10 +112,11 @@ steps: image: gcr.io/kosu-io/go-kosu-ci:latest commands: - cd packages/go-kosu - - "export KOSU_TEST_NODES=$(pwd)/testnet/node0@kosu-node-1:26657,$(pwd)/testnet/node1@kosu-node-1:26657,$(pwd)/testnet/node2@kosu-node-1:26657,$(pwd)/testnet/node3@kosu-node-1:26657" + - export KOSU_TEST_NODES=$(pwd)/testnet/node0@kosu-node-1:26657,$(pwd)/testnet/node1@kosu-node-1:26657,$(pwd)/testnet/node2@kosu-node-1:26657,$(pwd)/testnet/node3@kosu-node-1:26657 - make ci environment: WEB3_URI: http://kosu-geth:8545 + WEB3_URI_WS: ws://kosu-geth:8546 depends_on: - build-project - kosu-node-0 @@ -121,6 +130,7 @@ services: image: gcr.io/kosu-io/kosu-geth:0.1.1 environment: WEB3_URI: http://kosu-geth:8545 + WEB3_URI_WS: ws://kosu-geth:8546 ports: - 8545 - 8546 @@ -130,6 +140,7 @@ services: image: gcr.io/kosu-io/kosu-geth:0.1.1 environment: WEB3_URI: http://kosu-geth:8545 + WEB3_URI_WS: ws://kosu-geth:8546 ports: - 8545 - 8546 diff --git a/packages/go-kosu/witness/eth.go.orig b/packages/go-kosu/witness/eth.go.orig deleted file mode 100644 index d8b6f3ab..00000000 --- a/packages/go-kosu/witness/eth.go.orig +++ /dev/null @@ -1,119 +0,0 @@ -package witness - -import ( - "context" - "log" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/ethclient" -) - -var _ Provider = &EthereumProvider{} - -// EthereumProvider implements a Provider that connect to the Ethereum Blockchain -type EthereumProvider struct { - client *ethclient.Client -} - -// NewEthereumProvider returns a new EthereumProvider -func NewEthereumProvider(addr string) (*EthereumProvider, error) { - client, err := ethclient.Dial(addr) - if err != nil { - return nil, err - } - -<<<<<<< HEAD - return &EthereumProvider{client: client}, nil -} - -// WatchEvents watches for emitted events from the EventEmitter contract. -// First, emits the existing events in the blockchain, then subscribes to get the emitted events as they happen -func (w *EthereumProvider) WatchEvents(ctx context.Context, fn EventHandler) error { - emitter, err := NewEventEmitter( - common.HexToAddress(KosuEventEmitterAddress), - w.client, -======= - nID, err := client.NetworkID(context.Background()) - if err != nil { - return nil, err - } - - cAddr, err := GetContractAddress(nID, "EventEmitter") - if err != nil { - return nil, err - } - - events, err := NewEventEmitter( - common.HexToAddress(cAddr), - client, ->>>>>>> master - ) - if err != nil { - return err - } - - f, err := emitter.FilterKosuEvent(nil) - if err != nil { - return err - } - defer f.Close() // nolint:errcheck - - events := make(chan *EventEmitterKosuEvent) - defer close(events) - - sub, err := emitter.WatchKosuEvent(nil, events) - if err != nil { - return err - } - defer sub.Unsubscribe() - - for f.Next() { - fn(f.Event) - } - - for { - select { - case <-ctx.Done(): - return ctx.Err() - case err := <-sub.Err(): - log.Fatalf("WatchEvents: err = %+v", err) - return err - case evt := <-events: - fn(evt) - } - } -} - -// WatchBlocks watches for incoming block headers -func (w *EthereumProvider) WatchBlocks(ctx context.Context, fn BlockHandler) error { - ch := make(chan *types.Header) - defer close(ch) - - sub, err := w.client.SubscribeNewHead(ctx, ch) - if err != nil { - return err - } - defer sub.Unsubscribe() - - for { - select { - case <-ctx.Done(): - return ctx.Err() - case err := <-sub.Err(): - return err - case header := <-ch: - fn(header) - } - } -} - -// GetLastBlockNumber returns the latest known block number from the chain -func (w *EthereumProvider) GetLastBlockNumber(ctx context.Context) (uint64, error) { - block, err := w.client.BlockByNumber(ctx, nil) - if err != nil { - return 0, err - } - - return block.NumberU64(), nil -} diff --git a/packages/go-kosu/witness/eth_test.go b/packages/go-kosu/witness/eth_test.go index 20c91827..8a5004c1 100644 --- a/packages/go-kosu/witness/eth_test.go +++ b/packages/go-kosu/witness/eth_test.go @@ -12,7 +12,7 @@ import ( ) func TestEth(t *testing.T) { - env := "WEB3_URI" + env := "WEB3_URI_WS" addr := os.Getenv(env) if addr == "" { t.Skipf("%s env not declared", env) @@ -28,6 +28,7 @@ func TestEth(t *testing.T) { fn := func(e *EventEmitterKosuEvent) { log.Printf("type(%-30s) @#%d", e.EventType, e.Raw.BlockNumber) } + err := eth.WatchEvents(ctx, fn) require.Equal(t, context.DeadlineExceeded, err) }) From e5d0770b5e84ccce5c69dc0301d6a1bf7db59ded Mon Sep 17 00:00:00 2001 From: Gustavo Chain Date: Mon, 26 Aug 2019 18:54:33 +0200 Subject: [PATCH 17/19] go-kosu: disable race detector on tests --- packages/go-kosu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/go-kosu/Makefile b/packages/go-kosu/Makefile index 6f77579a..2143f624 100644 --- a/packages/go-kosu/Makefile +++ b/packages/go-kosu/Makefile @@ -26,7 +26,7 @@ test-fast: $(GOTEST) -failfast test: - $(GOTEST) -race + $(GOTEST) lint: $(GOLINT) From 6667a5cd5d3634227c471e3ca92ed5687a3d4e6a Mon Sep 17 00:00:00 2001 From: Nick Freyaldenhoven Date: Mon, 26 Aug 2019 14:43:41 -0500 Subject: [PATCH 18/19] Extending time out for more taxed CI host. --- packages/kosu.js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kosu.js/package.json b/packages/kosu.js/package.json index fc083cb9..0e42e038 100644 --- a/packages/kosu.js/package.json +++ b/packages/kosu.js/package.json @@ -7,7 +7,7 @@ "scripts": { "test": "mocha", "coverage": "nyc mocha && istanbul report html && open coverage/lcov-report/index.html", - "test:ci": "ts-mocha -p tsconfig.json test/ --timeout 8000 -- geth", + "test:ci": "ts-mocha -p tsconfig.json test/ --timeout 20000 -- geth", "test:ganache": "docker run --rm -p 8545:8545 ${npm_package_config_ganache_image_uri}", "test:ganache_detached": "docker run --rm -d -p 8545:8545 ${npm_package_config_ganache_image_uri}", "build": "tsc", From bca08d7476cf5732d17288aae2946d5b166654c4 Mon Sep 17 00:00:00 2001 From: Nick Freyaldenhoven Date: Mon, 26 Aug 2019 14:50:13 -0500 Subject: [PATCH 19/19] Updating image name. --- .drone.jsonnet | 2 +- .drone.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index d8e93aae..87ce4402 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -17,7 +17,7 @@ local KosuNode(id) = Image("kosu-node-"+id, "go-kosu-ci:latest") { ] }; -local KosuGeth(name) = Image(name, "kosu-geth:0.1.1") { +local KosuGeth(name) = Image(name, "kosu-test-geth:latest") { ports: [8545, 8546] }; diff --git a/.drone.yml b/.drone.yml index 6f1a7dfa..02b20313 100644 --- a/.drone.yml +++ b/.drone.yml @@ -127,7 +127,7 @@ steps: services: - name: kosu-geth pull: always - image: gcr.io/kosu-io/kosu-geth:0.1.1 + image: gcr.io/kosu-io/kosu-test-geth:latest environment: WEB3_URI: http://kosu-geth:8545 WEB3_URI_WS: ws://kosu-geth:8546 @@ -137,7 +137,7 @@ services: - name: go-kosu-ci-geth pull: always - image: gcr.io/kosu-io/kosu-geth:0.1.1 + image: gcr.io/kosu-io/kosu-test-geth:latest environment: WEB3_URI: http://kosu-geth:8545 WEB3_URI_WS: ws://kosu-geth:8546