diff --git a/geth/params/config.go b/geth/params/config.go index 25c869ffa..14fd257ac 100644 --- a/geth/params/config.go +++ b/geth/params/config.go @@ -169,7 +169,7 @@ type ClusterConfig struct { // StaticNodes lists the static nodes taken from compiled or passed cluster.json StaticNodes []string - // BootNodes list of cluster peer nodes for a given network (Ropsten, Rinkeby, Homestead), + // BootNodes list of cluster peer nodes for a given network (Mainnet, Ropsten, Rinkeby, Homestead), // for a given mode (production vs development) BootNodes []string } diff --git a/t/doc.go b/t/doc.go index 7d3801447..398b6830e 100644 --- a/t/doc.go +++ b/t/doc.go @@ -1,4 +1,3 @@ // Package t and its sub-packages are intended to support the testing -// of status-go. So the code here is not intended to run on Mainnet. -// It only supports Ropsten, Rinkeby, and StatusChain for tests. +// of status-go. It supports Ropsten, Rinkeby, and StatusChain for tests. package t diff --git a/t/e2e/accounts/accounts_rpc_test.go b/t/e2e/accounts/accounts_rpc_test.go index aa646af82..78398f083 100644 --- a/t/e2e/accounts/accounts_rpc_test.go +++ b/t/e2e/accounts/accounts_rpc_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/status-im/status-go/geth/params" - e2e "github.com/status-im/status-go/t/e2e" + "github.com/status-im/status-go/t/e2e" . "github.com/status-im/status-go/t/utils" "github.com/stretchr/testify/suite" ) diff --git a/t/e2e/api/backend_test.go b/t/e2e/api/backend_test.go index f260833ac..8d6758633 100644 --- a/t/e2e/api/backend_test.go +++ b/t/e2e/api/backend_test.go @@ -12,7 +12,7 @@ import ( "github.com/status-im/status-go/geth/jail" "github.com/status-im/status-go/geth/node" "github.com/status-im/status-go/geth/params" - e2e "github.com/status-im/status-go/t/e2e" + "github.com/status-im/status-go/t/e2e" . "github.com/status-im/status-go/t/utils" "github.com/stretchr/testify/suite" ) @@ -190,7 +190,7 @@ func (s *APIBackendTestSuite) TestRaceConditions() { // FIXME(tiabc): There's also a test with the same name in geth/node/manager_test.go // so this test should only check StatusBackend logic with a mocked version of the underlying StatusNode. func (s *APIBackendTestSuite) TestNetworkSwitching() { - // get Ropsten config + // Get test node configuration. nodeConfig, err := MakeTestNodeConfig(GetNetworkID()) s.NoError(err) diff --git a/t/e2e/jail/jail_rpc_test.go b/t/e2e/jail/jail_rpc_test.go index 949b23b9b..25651ece1 100644 --- a/t/e2e/jail/jail_rpc_test.go +++ b/t/e2e/jail/jail_rpc_test.go @@ -36,6 +36,8 @@ func (s *JailRPCTestSuite) SetupTest() { } func (s *JailRPCTestSuite) TestJailRPCSend() { + CheckTestSkipForNetworks(s.T(), params.MainNetworkID) + s.StartTestBackend() defer s.StopTestBackend() @@ -107,6 +109,8 @@ func (s *JailRPCTestSuite) TestRegressionGetTransactionReceipt() { } func (s *JailRPCTestSuite) TestContractDeployment() { + CheckTestSkipForNetworks(s.T(), params.MainNetworkID) + s.StartTestBackend() defer s.StopTestBackend() @@ -190,6 +194,8 @@ func (s *JailRPCTestSuite) TestContractDeployment() { } func (s *JailRPCTestSuite) TestJailVMPersistence() { + CheckTestSkipForNetworks(s.T(), params.MainNetworkID) + s.StartTestBackend() defer s.StopTestBackend() diff --git a/t/e2e/jail/jail_test.go b/t/e2e/jail/jail_test.go index beca03c72..4c9905674 100644 --- a/t/e2e/jail/jail_test.go +++ b/t/e2e/jail/jail_test.go @@ -14,7 +14,7 @@ import ( "github.com/status-im/status-go/geth/node" "github.com/status-im/status-go/geth/signal" "github.com/status-im/status-go/static" - e2e "github.com/status-im/status-go/t/e2e" + "github.com/status-im/status-go/t/e2e" "github.com/stretchr/testify/suite" ) diff --git a/t/e2e/node/manager_test.go b/t/e2e/node/manager_test.go index 2270d714b..47b2b1380 100644 --- a/t/e2e/node/manager_test.go +++ b/t/e2e/node/manager_test.go @@ -13,7 +13,7 @@ import ( "github.com/status-im/status-go/geth/node" "github.com/status-im/status-go/geth/params" - e2e "github.com/status-im/status-go/t/e2e" + "github.com/status-im/status-go/t/e2e" . "github.com/status-im/status-go/t/utils" "github.com/stretchr/testify/suite" ) diff --git a/t/e2e/rpc/client_test.go b/t/e2e/rpc/client_test.go index 5cd12197b..4c0da864d 100644 --- a/t/e2e/rpc/client_test.go +++ b/t/e2e/rpc/client_test.go @@ -5,7 +5,7 @@ import ( "github.com/status-im/status-go/geth/node" "github.com/status-im/status-go/geth/rpc" - e2e "github.com/status-im/status-go/t/e2e" + "github.com/status-im/status-go/t/e2e" . "github.com/status-im/status-go/t/utils" //nolint: golint "github.com/stretchr/testify/suite" ) diff --git a/t/e2e/rpc/rpc_test.go b/t/e2e/rpc/rpc_test.go index db7c0ce9f..ecf311fa8 100644 --- a/t/e2e/rpc/rpc_test.go +++ b/t/e2e/rpc/rpc_test.go @@ -12,7 +12,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/status-im/status-go/geth/node" "github.com/status-im/status-go/geth/params" - e2e "github.com/status-im/status-go/t/e2e" + "github.com/status-im/status-go/t/e2e" . "github.com/status-im/status-go/t/utils" "github.com/stretchr/testify/suite" ) @@ -160,6 +160,8 @@ func (s *RPCTestSuite) TestCallRawResultGetTransactionReceipt() { // TestCallContextResult checks if result passed to CallContext // is set accordingly to its underlying memory layout. func (s *RPCTestSuite) TestCallContextResult() { + CheckTestSkipForNetworks(s.T(), params.MainNetworkID) + s.StartTestNode() defer s.StopTestNode() diff --git a/t/e2e/transactions/transactions_test.go b/t/e2e/transactions/transactions_test.go index c3992b5ca..d22e7512d 100644 --- a/t/e2e/transactions/transactions_test.go +++ b/t/e2e/transactions/transactions_test.go @@ -39,6 +39,8 @@ type TransactionsTestSuite struct { } func (s *TransactionsTestSuite) TestCallRPCSendTransaction() { + CheckTestSkipForNetworks(s.T(), params.MainNetworkID) + s.StartTestBackend() defer s.StopTestBackend() @@ -90,9 +92,7 @@ func (s *TransactionsTestSuite) TestCallRPCSendTransaction() { } func (s *TransactionsTestSuite) TestCallRPCSendTransactionUpstream() { - if GetNetworkID() == params.StatusChainNetworkID { - s.T().Skip() - } + CheckTestSkipForNetworks(s.T(), params.MainNetworkID, params.StatusChainNetworkID) addr, err := GetRemoteURL() s.NoError(err) @@ -148,6 +148,8 @@ func (s *TransactionsTestSuite) TestCallRPCSendTransactionUpstream() { } func (s *TransactionsTestSuite) TestEmptyToFieldPreserved() { + CheckTestSkipForNetworks(s.T(), params.MainNetworkID) + s.StartTestBackend() defer s.StopTestBackend() @@ -195,6 +197,8 @@ func (s *TransactionsTestSuite) TestEmptyToFieldPreserved() { // TestSendContractCompat tries to send transaction using the legacy "Data" // field, which is supported for backward compatibility reasons. func (s *TransactionsTestSuite) TestSendContractTxCompat() { + CheckTestSkipForNetworks(s.T(), params.MainNetworkID) + initFunc := func(byteCode []byte, args *transactions.SendTxArgs) { args.Data = (hexutil.Bytes)(byteCode) } @@ -205,6 +209,8 @@ func (s *TransactionsTestSuite) TestSendContractTxCompat() { // "Data" and "Input" fields. Also makes sure that the error is returned if // they have different values. func (s *TransactionsTestSuite) TestSendContractTxCollision() { + CheckTestSkipForNetworks(s.T(), params.MainNetworkID) + // Scenario 1: Both fields are filled and have the same value, expect success initFunc := func(byteCode []byte, args *transactions.SendTxArgs) { args.Input = (hexutil.Bytes)(byteCode) @@ -232,6 +238,8 @@ func (s *TransactionsTestSuite) TestSendContractTxCollision() { } func (s *TransactionsTestSuite) TestSendContractTx() { + CheckTestSkipForNetworks(s.T(), params.MainNetworkID) + initFunc := func(byteCode []byte, args *transactions.SendTxArgs) { args.Input = (hexutil.Bytes)(byteCode) } @@ -344,6 +352,8 @@ func (s *TransactionsTestSuite) testSendContractTx(setInputAndDataValue initFunc } func (s *TransactionsTestSuite) TestSendEther() { + CheckTestSkipForNetworks(s.T(), params.MainNetworkID) + s.StartTestBackend() defer s.StopTestBackend() @@ -379,9 +389,7 @@ func (s *TransactionsTestSuite) TestSendEther() { } func (s *TransactionsTestSuite) TestSendEtherTxUpstream() { - if GetNetworkID() == params.StatusChainNetworkID { - s.T().Skip() - } + CheckTestSkipForNetworks(s.T(), params.MainNetworkID, params.StatusChainNetworkID) addr, err := GetRemoteURL() s.NoError(err) @@ -437,6 +445,8 @@ func (s *TransactionsTestSuite) TestSendEtherTxUpstream() { } func (s *TransactionsTestSuite) TestDoubleCompleteQueuedTransactions() { + CheckTestSkipForNetworks(s.T(), params.MainNetworkID) + s.StartTestBackend() defer s.StopTestBackend() @@ -514,6 +524,8 @@ func (s *TransactionsTestSuite) TestDoubleCompleteQueuedTransactions() { } func (s *TransactionsTestSuite) TestDiscardQueuedTransaction() { + CheckTestSkipForNetworks(s.T(), params.MainNetworkID) + s.StartTestBackend() defer s.StopTestBackend() @@ -588,6 +600,8 @@ func (s *TransactionsTestSuite) TestDiscardQueuedTransaction() { } func (s *TransactionsTestSuite) TestCompleteMultipleQueuedTransactions() { + CheckTestSkipForNetworks(s.T(), params.MainNetworkID) + s.setupLocalNode() defer s.StopTestBackend() @@ -599,6 +613,8 @@ func (s *TransactionsTestSuite) TestCompleteMultipleQueuedTransactions() { } func (s *TransactionsTestSuite) TestDiscardMultipleQueuedTransactions() { + CheckTestSkipForNetworks(s.T(), params.MainNetworkID) + s.StartTestBackend() defer s.StopTestBackend() @@ -729,6 +745,8 @@ func (s *TransactionsTestSuite) TestNonExistentQueuedTransactions() { } func (s *TransactionsTestSuite) TestCompleteMultipleQueuedTransactionsUpstream() { + CheckTestSkipForNetworks(s.T(), params.MainNetworkID) + s.setupUpstreamNode() defer s.StopTestBackend() diff --git a/t/e2e/whisper/whisper_jail_test.go b/t/e2e/whisper/whisper_jail_test.go index bfcc074ec..9e985040a 100644 --- a/t/e2e/whisper/whisper_jail_test.go +++ b/t/e2e/whisper/whisper_jail_test.go @@ -8,7 +8,7 @@ import ( whisper "github.com/ethereum/go-ethereum/whisper/whisperv6" "github.com/status-im/status-go/geth/jail" "github.com/status-im/status-go/static" - e2e "github.com/status-im/status-go/t/e2e" + "github.com/status-im/status-go/t/e2e" . "github.com/status-im/status-go/t/utils" "github.com/stretchr/testify/suite" ) diff --git a/t/utils/utils.go b/t/utils/utils.go index 24390836e..26ebda1db 100644 --- a/t/utils/utils.go +++ b/t/utils/utils.go @@ -131,9 +131,10 @@ func GetRemoteURLFromNetworkID(id int) (url string, err error) { } // GetHeadHashFromNetworkID returns the hash associated with a given network id. -// Mainnet is not supported for tests. func GetHeadHashFromNetworkID(id int) string { switch id { + case params.MainNetworkID: + return "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" case params.RinkebyNetworkID: return "0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177" case params.RopstenNetworkID: @@ -156,10 +157,11 @@ func GetHeadHash() string { } // GetNetworkID returns appropriate network id for test based on -// default or provided -network flag. Mainnet is not supported for -// tests. +// default or provided -network flag. func GetNetworkID() int { switch strings.ToLower(*networkSelected) { + case fmt.Sprintf("%d", params.MainNetworkID), "mainnet": + return params.MainNetworkID case fmt.Sprintf("%d", params.RinkebyNetworkID), "rinkeby": return params.RinkebyNetworkID case fmt.Sprintf("%d", params.RopstenNetworkID), "ropsten", "testnet": @@ -171,6 +173,17 @@ func GetNetworkID() int { panic(fmt.Sprintf("invalid selected network: %q", *networkSelected)) } +// CheckTestSkipForNetworks checks if network for test is one of the +// prohibited ones and skips the test in this case. +func CheckTestSkipForNetworks(t *testing.T, networks ...int) { + id := GetNetworkID() + for _, network := range networks { + if network == id { + t.Skipf("skipping test for network %d", network) + } + } +} + // GetAccount1PKFile returns the filename for Account1 keystore based // on the current network. This allows running the e2e tests on the // private network w/o access to the ACCOUNT_PASSWORD env variable