Skip to content

Commit b6f3007

Browse files
committed
core: move genesis alloc types to core/types (ethereum#29003)
1 parent 745c276 commit b6f3007

35 files changed

+279
-243
lines changed

accounts/abi/bind/backends/simulated.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func SimulateWalletAddressAndSignFn() (common.Address, func(account accounts.Acc
102102
}
103103

104104
// NewXDCSimulatedBackend creates a new backend for testing purpose.
105-
func NewXDCSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64, chainConfig *params.ChainConfig) *SimulatedBackend {
105+
func NewXDCSimulatedBackend(alloc types.GenesisAlloc, gasLimit uint64, chainConfig *params.ChainConfig) *SimulatedBackend {
106106
database := rawdb.NewMemoryDatabase()
107107
genesis := core.Genesis{
108108
GasLimit: gasLimit, // need this big, support initial smart contract
@@ -147,7 +147,7 @@ func NewXDCSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64, chainConfi
147147
// SimulOldNewSimulatedBackendatedBackend creates a new binding backend based on the given database
148148
// and uses a simulated blockchain for testing purposes.
149149
// A simulated backend always uses chainID 1337.
150-
func NewSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
150+
func NewSimulatedBackend(alloc types.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
151151
database := rawdb.NewMemoryDatabase()
152152
genesis := core.Genesis{Config: params.AllEthashProtocolChanges, GasLimit: gasLimit, Alloc: alloc}
153153
genesis.MustCommit(database)

accounts/abi/bind/backends/simulated_test.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"github.com/XinFinOrg/XDPoSChain/accounts/abi"
3232
"github.com/XinFinOrg/XDPoSChain/accounts/abi/bind"
3333
"github.com/XinFinOrg/XDPoSChain/common"
34-
"github.com/XinFinOrg/XDPoSChain/core"
3534
"github.com/XinFinOrg/XDPoSChain/core/types"
3635
"github.com/XinFinOrg/XDPoSChain/crypto"
3736
"github.com/XinFinOrg/XDPoSChain/params"
@@ -42,8 +41,8 @@ func TestSimulatedBackend(t *testing.T) {
4241
var gasLimit uint64 = 8000029
4342
key, _ := crypto.GenerateKey() // nolint: gosec
4443
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
45-
genAlloc := make(core.GenesisAlloc)
46-
genAlloc[auth.From] = core.GenesisAccount{Balance: big.NewInt(9223372036854775807)}
44+
genAlloc := make(types.GenesisAlloc)
45+
genAlloc[auth.From] = types.Account{Balance: big.NewInt(9223372036854775807)}
4746

4847
config := *params.TestXDPoSMockChainConfig
4948
config.Eip1559Block = big.NewInt(0)
@@ -119,7 +118,7 @@ func simTestBackend(testAddr common.Address) *SimulatedBackend {
119118
config := *params.TestXDPoSMockChainConfig
120119
config.Eip1559Block = big.NewInt(0)
121120
return NewXDCSimulatedBackend(
122-
core.GenesisAlloc{
121+
types.GenesisAlloc{
123122
testAddr: {Balance: big.NewInt(100000000000000000)},
124123
},
125124
10000000,
@@ -144,7 +143,7 @@ func TestNewSimulatedBackend(t *testing.T) {
144143
func TestAdjustTime(t *testing.T) {
145144
t.Parallel()
146145
sim := NewXDCSimulatedBackend(
147-
core.GenesisAlloc{},
146+
types.GenesisAlloc{},
148147
10000000,
149148
params.TestXDPoSMockChainConfig,
150149
)
@@ -226,7 +225,7 @@ func TestBalanceAt(t *testing.T) {
226225
func TestBlockByHash(t *testing.T) {
227226
t.Parallel()
228227
sim := NewXDCSimulatedBackend(
229-
core.GenesisAlloc{},
228+
types.GenesisAlloc{},
230229
10000000,
231230
params.TestXDPoSMockChainConfig,
232231
)
@@ -250,7 +249,7 @@ func TestBlockByHash(t *testing.T) {
250249
func TestBlockByNumber(t *testing.T) {
251250
t.Parallel()
252251
sim := NewXDCSimulatedBackend(
253-
core.GenesisAlloc{},
252+
types.GenesisAlloc{},
254253
10000000,
255254
params.TestXDPoSMockChainConfig,
256255
)
@@ -446,7 +445,7 @@ func TestEstimateGas(t *testing.T) {
446445
opts, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
447446

448447
sim := NewXDCSimulatedBackend(
449-
core.GenesisAlloc{addr: {Balance: big.NewInt(params.Ether)}},
448+
types.GenesisAlloc{addr: {Balance: big.NewInt(params.Ether)}},
450449
10000000,
451450
params.TestXDPoSMockChainConfig,
452451
)
@@ -557,10 +556,10 @@ func TestEstimateGasWithPrice(t *testing.T) {
557556
addr := crypto.PubkeyToAddress(key.PublicKey)
558557

559558
sim := NewXDCSimulatedBackend(
560-
core.GenesisAlloc{addr: {Balance: big.NewInt(params.Ether*2 + 2e17)}},
559+
types.GenesisAlloc{addr: {Balance: big.NewInt(params.Ether*2 + 2e17)}},
561560
10000000,
562561
params.TestXDPoSMockChainConfig,
563-
)
562+
)
564563
defer sim.Close()
565564

566565
recipient := common.HexToAddress("deadbeef")
@@ -908,7 +907,7 @@ func TestTransactionReceipt(t *testing.T) {
908907
func TestSuggestGasPrice(t *testing.T) {
909908
t.Parallel()
910909
sim := NewXDCSimulatedBackend(
911-
core.GenesisAlloc{},
910+
types.GenesisAlloc{},
912911
10000000,
913912
params.TestXDPoSMockChainConfig,
914913
)

0 commit comments

Comments
 (0)