diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index ea79ab448423b..15d7edc7e1445 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -141,10 +141,11 @@ func NewXDCSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64, chainConfi // NewSimulatedBackend creates a new binding backend using a simulated blockchain // for testing purposes. +// // A simulated backend always uses chainID 1337. -func NewSimulatedBackend(alloc core.GenesisAlloc) *SimulatedBackend { +func NewSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend { database := rawdb.NewMemoryDatabase() - genesis := core.Genesis{Config: params.AllEthashProtocolChanges, Alloc: alloc, GasLimit: 42000000} + genesis := core.Genesis{Config: params.AllEthashProtocolChanges, GasLimit: gasLimit, Alloc: alloc} genesis.MustCommit(database) blockchain, _ := core.NewBlockChain(database, nil, genesis.Config, ethash.NewFaker(), vm.Config{}) diff --git a/contracts/randomize/randomize_test.go b/contracts/randomize/randomize_test.go index 14d229196c6c4..fd117681f1b05 100644 --- a/contracts/randomize/randomize_test.go +++ b/contracts/randomize/randomize_test.go @@ -73,7 +73,7 @@ func TestRandomize(t *testing.T) { func TestSendTxRandomizeSecretAndOpening(t *testing.T) { genesis := core.GenesisAlloc{acc1Addr: {Balance: big.NewInt(1000000000000)}} - backend := backends.NewSimulatedBackend(genesis) + backend := backends.NewSimulatedBackend(genesis, 42000000) backend.Commit() signer := types.HomesteadSigner{} ctx := context.Background() diff --git a/contracts/tests/Inherited_test.go b/contracts/tests/Inherited_test.go index 94298fc0e3b46..a60fa6344f5b4 100644 --- a/contracts/tests/Inherited_test.go +++ b/contracts/tests/Inherited_test.go @@ -2,15 +2,16 @@ package tests import ( "fmt" + "math/big" + "os" + "testing" + "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" "github.com/XinFinOrg/XDPoSChain/common" "github.com/XinFinOrg/XDPoSChain/core" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/log" - "math/big" - "os" - "testing" ) var ( @@ -27,7 +28,7 @@ func TestPriceFeed(t *testing.T) { // init genesis contractBackend := backends.NewSimulatedBackend(core.GenesisAlloc{ mainAddr: {Balance: big.NewInt(0).Mul(big.NewInt(10000000000000), big.NewInt(10000000000000))}, - }) + }, 42000000) transactOpts := bind.NewKeyedTransactor(mainKey) // deploy payer swap SMC addr, contract, err := DeployMyInherited(transactOpts, contractBackend) diff --git a/contracts/trc21issuer/trc21issuer_test.go b/contracts/trc21issuer/trc21issuer_test.go index a8658b105be3d..aeebb7b7ad723 100644 --- a/contracts/trc21issuer/trc21issuer_test.go +++ b/contracts/trc21issuer/trc21issuer_test.go @@ -33,7 +33,7 @@ func TestFeeTxWithTRC21Token(t *testing.T) { // init genesis contractBackend := backends.NewSimulatedBackend(core.GenesisAlloc{ mainAddr: {Balance: big.NewInt(0).Mul(big.NewInt(10000000000000), big.NewInt(10000000000000))}, - }) + }, 42000000) transactOpts := bind.NewKeyedTransactor(mainKey) // deploy payer swap SMC trc21IssuerAddr, trc21Issuer, err := DeployTRC21Issuer(transactOpts, contractBackend, minApply)