mirror of
https://github.com/status-im/status-go.git
synced 2025-02-16 16:56:53 +00:00
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 lists the static nodes taken from compiled or passed cluster.json
|
||||||
StaticNodes []string
|
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)
|
// for a given mode (production vs development)
|
||||||
BootNodes []string
|
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
|
// 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.
|
// of status-go. It supports Ropsten, Rinkeby, and StatusChain for tests.
|
||||||
// It only supports Ropsten, Rinkeby, and StatusChain for tests.
|
|
||||||
package t
|
package t
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/status-im/status-go/geth/params"
|
"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/status-im/status-go/t/utils"
|
||||||
"github.com/stretchr/testify/suite"
|
"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/jail"
|
||||||
"github.com/status-im/status-go/geth/node"
|
"github.com/status-im/status-go/geth/node"
|
||||||
"github.com/status-im/status-go/geth/params"
|
"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/status-im/status-go/t/utils"
|
||||||
"github.com/stretchr/testify/suite"
|
"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
|
// 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.
|
// so this test should only check StatusBackend logic with a mocked version of the underlying StatusNode.
|
||||||
func (s *APIBackendTestSuite) TestNetworkSwitching() {
|
func (s *APIBackendTestSuite) TestNetworkSwitching() {
|
||||||
// get Ropsten config
|
// Get test node configuration.
|
||||||
nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
|
nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
|
||||||
s.NoError(err)
|
s.NoError(err)
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ func (s *JailRPCTestSuite) SetupTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *JailRPCTestSuite) TestJailRPCSend() {
|
func (s *JailRPCTestSuite) TestJailRPCSend() {
|
||||||
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID)
|
||||||
|
|
||||||
s.StartTestBackend()
|
s.StartTestBackend()
|
||||||
defer s.StopTestBackend()
|
defer s.StopTestBackend()
|
||||||
|
|
||||||
@ -107,6 +109,8 @@ func (s *JailRPCTestSuite) TestRegressionGetTransactionReceipt() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *JailRPCTestSuite) TestContractDeployment() {
|
func (s *JailRPCTestSuite) TestContractDeployment() {
|
||||||
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID)
|
||||||
|
|
||||||
s.StartTestBackend()
|
s.StartTestBackend()
|
||||||
defer s.StopTestBackend()
|
defer s.StopTestBackend()
|
||||||
|
|
||||||
@ -190,6 +194,8 @@ func (s *JailRPCTestSuite) TestContractDeployment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *JailRPCTestSuite) TestJailVMPersistence() {
|
func (s *JailRPCTestSuite) TestJailVMPersistence() {
|
||||||
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID)
|
||||||
|
|
||||||
s.StartTestBackend()
|
s.StartTestBackend()
|
||||||
defer s.StopTestBackend()
|
defer s.StopTestBackend()
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
"github.com/status-im/status-go/geth/node"
|
"github.com/status-im/status-go/geth/node"
|
||||||
"github.com/status-im/status-go/geth/signal"
|
"github.com/status-im/status-go/geth/signal"
|
||||||
"github.com/status-im/status-go/static"
|
"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"
|
"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/node"
|
||||||
"github.com/status-im/status-go/geth/params"
|
"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/status-im/status-go/t/utils"
|
||||||
"github.com/stretchr/testify/suite"
|
"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/node"
|
||||||
"github.com/status-im/status-go/geth/rpc"
|
"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/status-im/status-go/t/utils" //nolint: golint
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
)
|
)
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/status-im/status-go/geth/node"
|
"github.com/status-im/status-go/geth/node"
|
||||||
"github.com/status-im/status-go/geth/params"
|
"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/status-im/status-go/t/utils"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
)
|
)
|
||||||
@ -160,6 +160,8 @@ func (s *RPCTestSuite) TestCallRawResultGetTransactionReceipt() {
|
|||||||
// TestCallContextResult checks if result passed to CallContext
|
// TestCallContextResult checks if result passed to CallContext
|
||||||
// is set accordingly to its underlying memory layout.
|
// is set accordingly to its underlying memory layout.
|
||||||
func (s *RPCTestSuite) TestCallContextResult() {
|
func (s *RPCTestSuite) TestCallContextResult() {
|
||||||
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID)
|
||||||
|
|
||||||
s.StartTestNode()
|
s.StartTestNode()
|
||||||
defer s.StopTestNode()
|
defer s.StopTestNode()
|
||||||
|
|
||||||
|
@ -39,6 +39,8 @@ type TransactionsTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *TransactionsTestSuite) TestCallRPCSendTransaction() {
|
func (s *TransactionsTestSuite) TestCallRPCSendTransaction() {
|
||||||
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID)
|
||||||
|
|
||||||
s.StartTestBackend()
|
s.StartTestBackend()
|
||||||
defer s.StopTestBackend()
|
defer s.StopTestBackend()
|
||||||
|
|
||||||
@ -90,9 +92,7 @@ func (s *TransactionsTestSuite) TestCallRPCSendTransaction() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *TransactionsTestSuite) TestCallRPCSendTransactionUpstream() {
|
func (s *TransactionsTestSuite) TestCallRPCSendTransactionUpstream() {
|
||||||
if GetNetworkID() == params.StatusChainNetworkID {
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID, params.StatusChainNetworkID)
|
||||||
s.T().Skip()
|
|
||||||
}
|
|
||||||
|
|
||||||
addr, err := GetRemoteURL()
|
addr, err := GetRemoteURL()
|
||||||
s.NoError(err)
|
s.NoError(err)
|
||||||
@ -148,6 +148,8 @@ func (s *TransactionsTestSuite) TestCallRPCSendTransactionUpstream() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *TransactionsTestSuite) TestEmptyToFieldPreserved() {
|
func (s *TransactionsTestSuite) TestEmptyToFieldPreserved() {
|
||||||
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID)
|
||||||
|
|
||||||
s.StartTestBackend()
|
s.StartTestBackend()
|
||||||
defer s.StopTestBackend()
|
defer s.StopTestBackend()
|
||||||
|
|
||||||
@ -195,6 +197,8 @@ func (s *TransactionsTestSuite) TestEmptyToFieldPreserved() {
|
|||||||
// TestSendContractCompat tries to send transaction using the legacy "Data"
|
// TestSendContractCompat tries to send transaction using the legacy "Data"
|
||||||
// field, which is supported for backward compatibility reasons.
|
// field, which is supported for backward compatibility reasons.
|
||||||
func (s *TransactionsTestSuite) TestSendContractTxCompat() {
|
func (s *TransactionsTestSuite) TestSendContractTxCompat() {
|
||||||
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID)
|
||||||
|
|
||||||
initFunc := func(byteCode []byte, args *transactions.SendTxArgs) {
|
initFunc := func(byteCode []byte, args *transactions.SendTxArgs) {
|
||||||
args.Data = (hexutil.Bytes)(byteCode)
|
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
|
// "Data" and "Input" fields. Also makes sure that the error is returned if
|
||||||
// they have different values.
|
// they have different values.
|
||||||
func (s *TransactionsTestSuite) TestSendContractTxCollision() {
|
func (s *TransactionsTestSuite) TestSendContractTxCollision() {
|
||||||
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID)
|
||||||
|
|
||||||
// Scenario 1: Both fields are filled and have the same value, expect success
|
// Scenario 1: Both fields are filled and have the same value, expect success
|
||||||
initFunc := func(byteCode []byte, args *transactions.SendTxArgs) {
|
initFunc := func(byteCode []byte, args *transactions.SendTxArgs) {
|
||||||
args.Input = (hexutil.Bytes)(byteCode)
|
args.Input = (hexutil.Bytes)(byteCode)
|
||||||
@ -232,6 +238,8 @@ func (s *TransactionsTestSuite) TestSendContractTxCollision() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *TransactionsTestSuite) TestSendContractTx() {
|
func (s *TransactionsTestSuite) TestSendContractTx() {
|
||||||
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID)
|
||||||
|
|
||||||
initFunc := func(byteCode []byte, args *transactions.SendTxArgs) {
|
initFunc := func(byteCode []byte, args *transactions.SendTxArgs) {
|
||||||
args.Input = (hexutil.Bytes)(byteCode)
|
args.Input = (hexutil.Bytes)(byteCode)
|
||||||
}
|
}
|
||||||
@ -344,6 +352,8 @@ func (s *TransactionsTestSuite) testSendContractTx(setInputAndDataValue initFunc
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *TransactionsTestSuite) TestSendEther() {
|
func (s *TransactionsTestSuite) TestSendEther() {
|
||||||
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID)
|
||||||
|
|
||||||
s.StartTestBackend()
|
s.StartTestBackend()
|
||||||
defer s.StopTestBackend()
|
defer s.StopTestBackend()
|
||||||
|
|
||||||
@ -379,9 +389,7 @@ func (s *TransactionsTestSuite) TestSendEther() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *TransactionsTestSuite) TestSendEtherTxUpstream() {
|
func (s *TransactionsTestSuite) TestSendEtherTxUpstream() {
|
||||||
if GetNetworkID() == params.StatusChainNetworkID {
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID, params.StatusChainNetworkID)
|
||||||
s.T().Skip()
|
|
||||||
}
|
|
||||||
|
|
||||||
addr, err := GetRemoteURL()
|
addr, err := GetRemoteURL()
|
||||||
s.NoError(err)
|
s.NoError(err)
|
||||||
@ -437,6 +445,8 @@ func (s *TransactionsTestSuite) TestSendEtherTxUpstream() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *TransactionsTestSuite) TestDoubleCompleteQueuedTransactions() {
|
func (s *TransactionsTestSuite) TestDoubleCompleteQueuedTransactions() {
|
||||||
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID)
|
||||||
|
|
||||||
s.StartTestBackend()
|
s.StartTestBackend()
|
||||||
defer s.StopTestBackend()
|
defer s.StopTestBackend()
|
||||||
|
|
||||||
@ -514,6 +524,8 @@ func (s *TransactionsTestSuite) TestDoubleCompleteQueuedTransactions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *TransactionsTestSuite) TestDiscardQueuedTransaction() {
|
func (s *TransactionsTestSuite) TestDiscardQueuedTransaction() {
|
||||||
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID)
|
||||||
|
|
||||||
s.StartTestBackend()
|
s.StartTestBackend()
|
||||||
defer s.StopTestBackend()
|
defer s.StopTestBackend()
|
||||||
|
|
||||||
@ -588,6 +600,8 @@ func (s *TransactionsTestSuite) TestDiscardQueuedTransaction() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *TransactionsTestSuite) TestCompleteMultipleQueuedTransactions() {
|
func (s *TransactionsTestSuite) TestCompleteMultipleQueuedTransactions() {
|
||||||
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID)
|
||||||
|
|
||||||
s.setupLocalNode()
|
s.setupLocalNode()
|
||||||
defer s.StopTestBackend()
|
defer s.StopTestBackend()
|
||||||
|
|
||||||
@ -599,6 +613,8 @@ func (s *TransactionsTestSuite) TestCompleteMultipleQueuedTransactions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *TransactionsTestSuite) TestDiscardMultipleQueuedTransactions() {
|
func (s *TransactionsTestSuite) TestDiscardMultipleQueuedTransactions() {
|
||||||
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID)
|
||||||
|
|
||||||
s.StartTestBackend()
|
s.StartTestBackend()
|
||||||
defer s.StopTestBackend()
|
defer s.StopTestBackend()
|
||||||
|
|
||||||
@ -729,6 +745,8 @@ func (s *TransactionsTestSuite) TestNonExistentQueuedTransactions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *TransactionsTestSuite) TestCompleteMultipleQueuedTransactionsUpstream() {
|
func (s *TransactionsTestSuite) TestCompleteMultipleQueuedTransactionsUpstream() {
|
||||||
|
CheckTestSkipForNetworks(s.T(), params.MainNetworkID)
|
||||||
|
|
||||||
s.setupUpstreamNode()
|
s.setupUpstreamNode()
|
||||||
defer s.StopTestBackend()
|
defer s.StopTestBackend()
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
|
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
|
||||||
"github.com/status-im/status-go/geth/jail"
|
"github.com/status-im/status-go/geth/jail"
|
||||||
"github.com/status-im/status-go/static"
|
"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/status-im/status-go/t/utils"
|
||||||
"github.com/stretchr/testify/suite"
|
"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.
|
// GetHeadHashFromNetworkID returns the hash associated with a given network id.
|
||||||
// Mainnet is not supported for tests.
|
|
||||||
func GetHeadHashFromNetworkID(id int) string {
|
func GetHeadHashFromNetworkID(id int) string {
|
||||||
switch id {
|
switch id {
|
||||||
|
case params.MainNetworkID:
|
||||||
|
return "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"
|
||||||
case params.RinkebyNetworkID:
|
case params.RinkebyNetworkID:
|
||||||
return "0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177"
|
return "0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177"
|
||||||
case params.RopstenNetworkID:
|
case params.RopstenNetworkID:
|
||||||
@ -156,10 +157,11 @@ func GetHeadHash() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetNetworkID returns appropriate network id for test based on
|
// GetNetworkID returns appropriate network id for test based on
|
||||||
// default or provided -network flag. Mainnet is not supported for
|
// default or provided -network flag.
|
||||||
// tests.
|
|
||||||
func GetNetworkID() int {
|
func GetNetworkID() int {
|
||||||
switch strings.ToLower(*networkSelected) {
|
switch strings.ToLower(*networkSelected) {
|
||||||
|
case fmt.Sprintf("%d", params.MainNetworkID), "mainnet":
|
||||||
|
return params.MainNetworkID
|
||||||
case fmt.Sprintf("%d", params.RinkebyNetworkID), "rinkeby":
|
case fmt.Sprintf("%d", params.RinkebyNetworkID), "rinkeby":
|
||||||
return params.RinkebyNetworkID
|
return params.RinkebyNetworkID
|
||||||
case fmt.Sprintf("%d", params.RopstenNetworkID), "ropsten", "testnet":
|
case fmt.Sprintf("%d", params.RopstenNetworkID), "ropsten", "testnet":
|
||||||
@ -171,6 +173,17 @@ func GetNetworkID() int {
|
|||||||
panic(fmt.Sprintf("invalid selected network: %q", *networkSelected))
|
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
|
// GetAccount1PKFile returns the filename for Account1 keystore based
|
||||||
// on the current network. This allows running the e2e tests on the
|
// on the current network. This allows running the e2e tests on the
|
||||||
// private network w/o access to the ACCOUNT_PASSWORD env variable
|
// private network w/o access to the ACCOUNT_PASSWORD env variable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user