Prepare tests for mainnet (#831)
* Start enabling to test Mainnet * Minor corrections found during code scan * Set mainnet blocker in E2E again * Introduced securing of mainnet transaction tests * Fix typing error * Typo led to follow-up errors * Linter problem * Change to individual test skips after review * More flexible skip control for mainnet and status chain * Fix double space * Change of skipping method and fixing wrong skipped networks
This commit is contained in:
parent
c32a82b88d
commit
6598371dc0
|
@ -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
|
||||
}
|
||||
|
|
3
t/doc.go
3
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
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue