From 1cc90541da77da4a290637603b14b837b98687a5 Mon Sep 17 00:00:00 2001 From: Alexander Ewetumo Date: Thu, 26 Oct 2017 14:11:24 +0100 Subject: [PATCH] Update makefiles and make changes regards review --- Makefile | 8 +------- e2e/accounts/accounts_rpc_test.go | 2 +- e2e/api/backend_test.go | 10 ++++----- e2e/node/manager_test.go | 8 ++++---- e2e/rpc/rpc_test.go | 2 +- e2e/transactions/transactions_test.go | 4 ++-- testing/testing.go | 29 ++++++++++++++------------- 7 files changed, 29 insertions(+), 34 deletions(-) diff --git a/Makefile b/Makefile index a56f2797e..7c4ae606e 100644 --- a/Makefile +++ b/Makefile @@ -145,13 +145,7 @@ test-coverage: ##@tests Run unit and integration tests with covevare test-e2e: ##@tests Run e2e tests # order: reliability then alphabetical # TODO(tiabc): make a single command out of them adding `-p 1` flag. - build/env.sh go test -timeout 5m ./e2e/accounts/... - build/env.sh go test -timeout 5m ./e2e/api/... -network=3 - build/env.sh go test -timeout 5m ./e2e/node/... -network=3 - build/env.sh go test -timeout 15m ./e2e/jail/... - build/env.sh go test -timeout 20m ./e2e/rpc/... -network=3 - build/env.sh go test -timeout 20m ./e2e/whisper/... - build/env.sh go test -timeout 10m ./e2e/transactions/... + build/env.sh go test -timeout 40m ./e2e/... build/env.sh go test -timeout 40m ./cmd/statusd ci: mock-install mock test-coverage test-e2e ##@tests Run all tests in CI diff --git a/e2e/accounts/accounts_rpc_test.go b/e2e/accounts/accounts_rpc_test.go index 55e5a6d09..302aa54c9 100644 --- a/e2e/accounts/accounts_rpc_test.go +++ b/e2e/accounts/accounts_rpc_test.go @@ -47,7 +47,7 @@ func (s *AccountsTestSuite) TestRPCEthAccountsWithUpstream() { return } - addr, err := GetRemoteURLForNetworkID() + addr, err := GetRemoteURL() s.NoError(err) s.StartTestBackend(e2e.WithUpstream(addr)) defer s.StopTestBackend() diff --git a/e2e/api/backend_test.go b/e2e/api/backend_test.go index f6d322219..16488ed92 100644 --- a/e2e/api/backend_test.go +++ b/e2e/api/backend_test.go @@ -203,7 +203,7 @@ func (s *APIBackendTestSuite) TestNetworkSwitching() { firstHash, err := e2e.FirstBlockHash(s.Backend.NodeManager()) s.NoError(err) - s.Equal(GetHeadHashForNetworkID(), firstHash) + s.Equal(GetHeadHash(), firstHash) // now stop node, and make sure that a new node, on different network can be started nodeStopped, err := s.Backend.StopNode() @@ -224,7 +224,7 @@ func (s *APIBackendTestSuite) TestNetworkSwitching() { // make sure we are on another network indeed firstHash, err = e2e.FirstBlockHash(s.Backend.NodeManager()) s.NoError(err) - s.Equal(GetHeadHashForNetworkID(), firstHash) + s.Equal(GetHeadHash(), firstHash) nodeStopped, err = s.Backend.StopNode() s.NoError(err) @@ -253,7 +253,7 @@ func (s *APIBackendTestSuite) TestResetChainData() { // 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(GetHeadHashForNetworkID(), firstHash) + s.Equal(GetHeadHash(), firstHash) } // FIXME(tiabc): There's also a test with the same name in geth/node/manager_test.go @@ -275,7 +275,7 @@ func (s *APIBackendTestSuite) TestRestartNode() { firstHash, err := e2e.FirstBlockHash(s.Backend.NodeManager()) s.NoError(err) - s.Equal(GetHeadHashForNetworkID(), firstHash) + s.Equal(GetHeadHash(), firstHash) s.True(s.Backend.IsNodeRunning()) nodeRestarted, err := s.Backend.RestartNode() @@ -286,5 +286,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(GetHeadHashForNetworkID(), firstHash) + s.Equal(GetHeadHash(), firstHash) } diff --git a/e2e/node/manager_test.go b/e2e/node/manager_test.go index 1daee4faf..da77c3fd6 100644 --- a/e2e/node/manager_test.go +++ b/e2e/node/manager_test.go @@ -246,7 +246,7 @@ func (s *ManagerTestSuite) TestNetworkSwitching() { firstHash, err := e2e.FirstBlockHash(s.NodeManager) s.NoError(err) - s.Equal(GetHeadHashForNetworkID(), firstHash) + s.Equal(GetHeadHash(), firstHash) // now stop node, and make sure that a new node, on different network can be started nodeStopped, err := s.NodeManager.StopNode() @@ -282,7 +282,7 @@ func (s *ManagerTestSuite) TestStartNodeWithUpstreamEnabled() { nodeConfig, err := e2e.MakeTestNodeConfig(GetNetworkID()) s.NoError(err) - networkURL, err := GetRemoteURLForNetworkID() + networkURL, err := GetRemoteURL() s.NoError(err) nodeConfig.UpstreamConfig.Enabled = true @@ -316,7 +316,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(GetHeadHashForNetworkID(), firstHash) + s.Equal(GetHeadHash(), firstHash) } func (s *ManagerTestSuite) TestRestartNode() { @@ -333,7 +333,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(GetHeadHashForNetworkID(), firstHash) + s.Equal(GetHeadHash(), firstHash) } // TODO(adam): race conditions should be tested with -race flag and unit tests, if possible. diff --git a/e2e/rpc/rpc_test.go b/e2e/rpc/rpc_test.go index 9276c95c6..a936a05f2 100644 --- a/e2e/rpc/rpc_test.go +++ b/e2e/rpc/rpc_test.go @@ -44,7 +44,7 @@ func (s *RPCTestSuite) TestCallRPC() { nodeConfig.HTTPHost = "" // to make sure that no HTTP interface is started if upstreamEnabled { - networkURL, err := GetRemoteURLForNetworkID() + networkURL, err := GetRemoteURL() s.NoError(err) nodeConfig.UpstreamConfig.Enabled = true diff --git a/e2e/transactions/transactions_test.go b/e2e/transactions/transactions_test.go index 3b403f5ea..cd5147085 100644 --- a/e2e/transactions/transactions_test.go +++ b/e2e/transactions/transactions_test.go @@ -88,7 +88,7 @@ func (s *TransactionsTestSuite) TestCallRPCSendTransactionUpstream() { return } - addr, err := GetRemoteURLForNetworkID() + addr, err := GetRemoteURL() s.NoError(err) s.StartTestBackend(e2e.WithUpstream(addr)) defer s.StopTestBackend() @@ -321,7 +321,7 @@ func (s *TransactionsTestSuite) TestSendEtherTxUpstream() { return } - addr, err := GetRemoteURLForNetworkID() + addr, err := GetRemoteURL() s.NoError(err) s.StartTestBackend(e2e.WithUpstream(addr)) defer s.StopTestBackend() diff --git a/testing/testing.go b/testing/testing.go index e6c09adad..6d0a9da27 100644 --- a/testing/testing.go +++ b/testing/testing.go @@ -16,10 +16,10 @@ import ( ) var ( - networkSelected = flag.String("network", "statuschain", "-network=NETWORKID to select network used for tests") + networkSelected = flag.String("network", "statuschain", "-network=NETWORKID or -network=NETWORKNAME to select network used for tests") - // ErrStatusPrivateNetwork is returned when network id is for a private chain network, whoes URL must be provided. - ErrStatusPrivateNetwork = errors.New("network id reserves for private chain network, provide URL") + // ErrNoRemoteURL is returned when network id has no associated url. + ErrNoRemoteURL = errors.New("network id requires a remote URL") // TestConfig defines the default config usable at package-level. TestConfig *common.TestConfig @@ -119,18 +119,19 @@ func EnsureNodeSync(nodeManager common.NodeManager) { } } -// GetRemoteURLFromID returns asociated network url for giving network id. -func GetRemoteURLFromID(id int) (string, error) { +// GetRemoteURLFromNetworkID returns asociated network url for giving network id. +func GetRemoteURLFromNetworkID(id int) (url string, err error) { switch id { case params.MainNetworkID: - return params.MainnetEthereumNetworkURL, nil + url = params.MainnetEthereumNetworkURL case params.RinkebyNetworkID: - return params.RinkebyEthereumNetworkURL, nil + url = params.RinkebyEthereumNetworkURL case params.RopstenNetworkID: - return params.RopstenEthereumNetworkURL, nil + url = params.RopstenEthereumNetworkURL } - return "", ErrStatusPrivateNetwork + err = ErrNoRemoteURL + return } // GetHeadHashFromNetworkID returns the hash associated with a given network id. @@ -147,13 +148,13 @@ func GetHeadHashFromNetworkID(id int) string { return "" } -// GetRemoteURLForNetworkID returns the url associated with a given network id. -func GetRemoteURLForNetworkID() (string, error) { - return GetRemoteURLFromID(GetNetworkID()) +// GetRemoteURL returns the url associated with a given network id. +func GetRemoteURL() (string, error) { + return GetRemoteURLFromNetworkID(GetNetworkID()) } -// GetHeadHashForNetworkID returns the hash associated with a given network id. -func GetHeadHashForNetworkID() string { +// GetHeadHash returns the hash associated with a given network id. +func GetHeadHash() string { return GetHeadHashFromNetworkID(GetNetworkID()) }