Skip to content

Commit

Permalink
backends: increase gaslimit in order to allow tests of large contracts (
Browse files Browse the repository at this point in the history
  • Loading branch information
gzliudan committed Jan 1, 2025
1 parent 2d4142c commit 03333ed
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})

Expand Down
2 changes: 1 addition & 1 deletion contracts/randomize/randomize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 5 additions & 4 deletions contracts/tests/Inherited_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion contracts/trc21issuer/trc21issuer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 03333ed

Please sign in to comment.