From a257d1c2013c89127cde048bf2c0f0ecfa65c761 Mon Sep 17 00:00:00 2001 From: Alexander Ewetumo Date: Mon, 23 Oct 2017 18:18:09 +0100 Subject: [PATCH] Fix errors on network chain id validation in tests --- e2e/accounts/accounts_rpc_test.go | 6 +----- e2e/accounts/accounts_test.go | 1 - e2e/api/backend_test.go | 8 ++++---- e2e/node/manager_test.go | 8 ++++---- e2e/rpc/client_test.go | 1 - e2e/rpc/rpc_test.go | 7 ++++--- e2e/transactions/transactions_test.go | 5 +---- e2e/whisper/whisper_jail_test.go | 5 ++--- 8 files changed, 16 insertions(+), 25 deletions(-) diff --git a/e2e/accounts/accounts_rpc_test.go b/e2e/accounts/accounts_rpc_test.go index 0ee9cd26c..681dd1efa 100644 --- a/e2e/accounts/accounts_rpc_test.go +++ b/e2e/accounts/accounts_rpc_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/status-im/status-go/e2e" - "github.com/status-im/status-go/geth/params" . "github.com/status-im/status-go/testing" "github.com/stretchr/testify/suite" ) @@ -43,10 +42,7 @@ func (s *AccountsTestSuite) TestRPCEthAccountsWithUpstream() { // FIXME(tiabc): Stop skipping after https://github.com/status-im/status-go/issues/424 s.T().Skip() - s.StartTestBackend( - params.RopstenNetworkID, - e2e.WithUpstream("https://ropsten.infura.io/z6GCTmjdP3FETEJmMBI4"), - ) + s.StartTestBackend(e2e.WithUpstream("https://ropsten.infura.io/z6GCTmjdP3FETEJmMBI4")) defer s.StopTestBackend() // log into test account diff --git a/e2e/accounts/accounts_test.go b/e2e/accounts/accounts_test.go index 6e5fce0c2..6d44e8091 100644 --- a/e2e/accounts/accounts_test.go +++ b/e2e/accounts/accounts_test.go @@ -8,7 +8,6 @@ import ( "github.com/status-im/status-go/e2e" "github.com/status-im/status-go/geth/account" "github.com/status-im/status-go/geth/common" - "github.com/status-im/status-go/geth/params" . "github.com/status-im/status-go/testing" "github.com/stretchr/testify/suite" ) diff --git a/e2e/api/backend_test.go b/e2e/api/backend_test.go index 0d9dc9950..4cadac2d6 100644 --- a/e2e/api/backend_test.go +++ b/e2e/api/backend_test.go @@ -191,7 +191,7 @@ func (s *APIBackendTestSuite) TestRaceConditions() { // so this test should only check StatusBackend logic with a mocked version of the underlying NodeManager. func (s *APIBackendTestSuite) TestNetworkSwitching() { // get Ropsten config - nodeConfig, err := e2e.MakeTestNodeConfig(e2e.GetNetworkID()) + nodeConfig, err := e2e.MakeTestNodeConfig(params.RopstenNetworkID) s.NoError(err) s.False(s.Backend.IsNodeRunning()) @@ -211,7 +211,7 @@ func (s *APIBackendTestSuite) TestNetworkSwitching() { <-nodeStopped // start new node with completely different config - nodeConfig, err = e2e.MakeTestNodeConfig(e2e.GetNetworkID()) + nodeConfig, err = e2e.MakeTestNodeConfig(params.RinkebyNetworkID) s.NoError(err) s.False(s.Backend.IsNodeRunning()) @@ -267,7 +267,7 @@ func (s *APIBackendTestSuite) TestRestartNode() { firstHash, err := e2e.FirstBlockHash(s.Backend.NodeManager()) s.NoError(err) - s.Equal("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177", firstHash) + s.Equal("0x28c4da1cca48d0107ea5ea29a40ac15fca86899c52d02309fa12ea39b86d219c", firstHash) s.True(s.Backend.IsNodeRunning()) nodeRestarted, err := s.Backend.RestartNode() @@ -278,5 +278,5 @@ func (s *APIBackendTestSuite) TestRestartNode() { // make sure we can read the first byte, and it is valid (for Rinkeby) firstHash, err = e2e.FirstBlockHash(s.Backend.NodeManager()) s.NoError(err) - s.Equal("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177", firstHash) + s.Equal("0x28c4da1cca48d0107ea5ea29a40ac15fca86899c52d02309fa12ea39b86d219c", firstHash) } diff --git a/e2e/node/manager_test.go b/e2e/node/manager_test.go index 8690f23bd..0fcefd39f 100644 --- a/e2e/node/manager_test.go +++ b/e2e/node/manager_test.go @@ -235,7 +235,7 @@ func (s *ManagerTestSuite) TestNodeStartStop() { func (s *ManagerTestSuite) TestNetworkSwitching() { // get Ropsten config - nodeConfig, err := e2e.MakeTestNodeConfig(e2e.GetNetworkID()) + nodeConfig, err := e2e.MakeTestNodeConfig(params.RopstenNetworkID) s.NoError(err) s.False(s.NodeManager.IsNodeRunning()) nodeStarted, err := s.NodeManager.StartNode(nodeConfig) @@ -255,7 +255,7 @@ func (s *ManagerTestSuite) TestNetworkSwitching() { s.False(s.NodeManager.IsNodeRunning()) // start new node with completely different config - nodeConfig, err = e2e.MakeTestNodeConfig(e2e.GetNetworkID()) + nodeConfig, err = e2e.MakeTestNodeConfig(params.RinkebyNetworkID) s.NoError(err) nodeStarted, err = s.NodeManager.StartNode(nodeConfig) s.NoError(err) @@ -308,7 +308,7 @@ func (s *ManagerTestSuite) TestResetChainData() { // make sure we can read the first byte, and it is valid (for Rinkeby) firstHash, err := e2e.FirstBlockHash(s.NodeManager) s.NoError(err) - s.Equal("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177", firstHash) + s.Equal("0x28c4da1cca48d0107ea5ea29a40ac15fca86899c52d02309fa12ea39b86d219c", firstHash) } func (s *ManagerTestSuite) TestRestartNode() { @@ -325,7 +325,7 @@ func (s *ManagerTestSuite) TestRestartNode() { // make sure we can read the first byte, and it is valid (for Rinkeby) firstHash, err := e2e.FirstBlockHash(s.NodeManager) s.NoError(err) - s.Equal("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177", firstHash) + s.Equal("0x28c4da1cca48d0107ea5ea29a40ac15fca86899c52d02309fa12ea39b86d219c", firstHash) } // TODO(adam): race conditions should be tested with -race flag and unit tests, if possible. diff --git a/e2e/rpc/client_test.go b/e2e/rpc/client_test.go index 273a8fe5f..19e475054 100644 --- a/e2e/rpc/client_test.go +++ b/e2e/rpc/client_test.go @@ -5,7 +5,6 @@ import ( "github.com/status-im/status-go/e2e" "github.com/status-im/status-go/geth/node" - "github.com/status-im/status-go/geth/params" "github.com/status-im/status-go/geth/rpc" "github.com/stretchr/testify/suite" ) diff --git a/e2e/rpc/rpc_test.go b/e2e/rpc/rpc_test.go index 6db1651d1..43cf3a14c 100644 --- a/e2e/rpc/rpc_test.go +++ b/e2e/rpc/rpc_test.go @@ -6,13 +6,14 @@ import ( "testing" "time" + "math/big" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/status-im/status-go/e2e" "github.com/status-im/status-go/geth/node" "github.com/status-im/status-go/geth/params" . "github.com/status-im/status-go/testing" "github.com/stretchr/testify/suite" - "math/big" ) func TestRPCTestSuite(t *testing.T) { @@ -30,7 +31,7 @@ func (s *RPCTestSuite) SetupTest() { func (s *RPCTestSuite) TestCallRPC() { for _, upstreamEnabled := range []bool{false, true} { - nodeConfig, err := e2e.MakeTestNodeConfig(e2e.GetNetworkID()) + nodeConfig, err := e2e.MakeTestNodeConfig(params.RinkebyNetworkID) s.NoError(err) nodeConfig.IPCEnabled = false @@ -140,7 +141,7 @@ func (s *RPCTestSuite) TestCallRawResult() { // TestCallContextResult checks if result passed to CallContext // is set accordingly to its underlying memory layout. func (s *RPCTestSuite) TestCallContextResult() { - s.StartTestNode(params.StatusChainNetworkID) + s.StartTestNode() defer s.StopTestNode() s.Require().NoError(EnsureNodeSync(s.NodeManager)) diff --git a/e2e/transactions/transactions_test.go b/e2e/transactions/transactions_test.go index 3a8165e0e..dcc798440 100644 --- a/e2e/transactions/transactions_test.go +++ b/e2e/transactions/transactions_test.go @@ -83,10 +83,7 @@ func (s *TransactionsTestSuite) TestCallRPCSendTransactionUpstream() { // FIXME(tiabc): Stop skipping after https://github.com/status-im/status-go/issues/424 s.T().Skip() - s.StartTestBackend( - params.RopstenNetworkID, - e2e.WithUpstream("https://ropsten.infura.io/nKmXgiFgc2KqtoQ8BCGJ"), - ) + s.StartTestBackend(e2e.WithUpstream("https://ropsten.infura.io/nKmXgiFgc2KqtoQ8BCGJ")) defer s.StopTestBackend() err := s.Backend.AccountManager().SelectAccount(TestConfig.Account2.Address, TestConfig.Account2.Password) diff --git a/e2e/whisper/whisper_jail_test.go b/e2e/whisper/whisper_jail_test.go index ebd8f4fbd..2fbd7be38 100644 --- a/e2e/whisper/whisper_jail_test.go +++ b/e2e/whisper/whisper_jail_test.go @@ -13,7 +13,6 @@ import ( whisper "github.com/ethereum/go-ethereum/whisper/whisperv5" "github.com/status-im/status-go/e2e" "github.com/status-im/status-go/geth/common" - "github.com/status-im/status-go/geth/params" "github.com/status-im/status-go/static" . "github.com/status-im/status-go/testing" "github.com/stretchr/testify/suite" @@ -45,8 +44,8 @@ type WhisperJailTestSuite struct { Jail common.JailManager } -func (s *WhisperJailTestSuite) StartTestBackend(networkID int, opts ...e2e.TestNodeOption) { - s.BackendTestSuite.StartTestBackend(networkID, opts...) +func (s *WhisperJailTestSuite) StartTestBackend(opts ...e2e.TestNodeOption) { + s.BackendTestSuite.StartTestBackend(opts...) s.WhisperAPI = whisper.NewPublicWhisperAPI(s.WhisperService()) s.Jail = s.Backend.JailManager()