mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
parent
ee81b721fc
commit
aaa42a9a42
1 changed files with 41 additions and 25 deletions
|
|
@ -60,8 +60,10 @@ type testBackend struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTestBackend(t *testing.T, n int, gspec *core.Genesis, generator func(i int, b *core.BlockGen)) *testBackend {
|
func newTestBackend(t *testing.T, n int, gspec *core.Genesis, generator func(i int, b *core.BlockGen)) *testBackend {
|
||||||
|
config := *params.TestChainConfig
|
||||||
|
config.Eip1559Block = big.NewInt(0)
|
||||||
backend := &testBackend{
|
backend := &testBackend{
|
||||||
chainConfig: params.TestChainConfig,
|
chainConfig: &config,
|
||||||
engine: ethash.NewFaker(),
|
engine: ethash.NewFaker(),
|
||||||
chaindb: rawdb.NewMemoryDatabase(),
|
chaindb: rawdb.NewMemoryDatabase(),
|
||||||
}
|
}
|
||||||
|
|
@ -186,18 +188,22 @@ func TestTraceCall(t *testing.T) {
|
||||||
|
|
||||||
// Initialize test accounts
|
// Initialize test accounts
|
||||||
accounts := newAccounts(3)
|
accounts := newAccounts(3)
|
||||||
genesis := &core.Genesis{Alloc: types.GenesisAlloc{
|
config := *params.TestChainConfig
|
||||||
accounts[0].addr: {Balance: big.NewInt(9000000000000000000)},
|
config.Eip1559Block = big.NewInt(0)
|
||||||
accounts[1].addr: {Balance: big.NewInt(9000000000000000000)},
|
genesis := &core.Genesis{
|
||||||
accounts[2].addr: {Balance: big.NewInt(9000000000000000000)},
|
Config: &config,
|
||||||
}}
|
Alloc: types.GenesisAlloc{
|
||||||
|
accounts[0].addr: {Balance: big.NewInt(params.Ether)},
|
||||||
|
accounts[1].addr: {Balance: big.NewInt(params.Ether)},
|
||||||
|
accounts[2].addr: {Balance: big.NewInt(params.Ether)},
|
||||||
|
}}
|
||||||
genBlocks := 10
|
genBlocks := 10
|
||||||
signer := types.HomesteadSigner{}
|
signer := types.LatestSigner(&config)
|
||||||
api := NewAPI(newTestBackend(t, genBlocks, genesis, func(i int, b *core.BlockGen) {
|
api := NewAPI(newTestBackend(t, genBlocks, genesis, func(i int, b *core.BlockGen) {
|
||||||
// Transfer from account[0] to account[1]
|
// Transfer from account[0] to account[1]
|
||||||
// value: 1000 wei
|
// value: 1000 wei
|
||||||
// fee: 0 wei
|
// fee: 0 wei
|
||||||
tx, _ := types.SignTx(types.NewTransaction(uint64(i), accounts[1].addr, big.NewInt(1000), params.TxGas, big.NewInt(0), nil), signer, accounts[0].key)
|
tx, _ := types.SignTx(types.NewTransaction(uint64(i), accounts[1].addr, big.NewInt(1000), params.TxGas, b.BaseFee(), nil), signer, accounts[0].key)
|
||||||
b.AddTx(tx)
|
b.AddTx(tx)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
@ -311,6 +317,8 @@ func TestOverridenTraceCall(t *testing.T) {
|
||||||
|
|
||||||
// Initialize test accounts
|
// Initialize test accounts
|
||||||
accounts := newAccounts(3)
|
accounts := newAccounts(3)
|
||||||
|
config := *params.TestChainConfig
|
||||||
|
config.Eip1559Block = big.NewInt(0)
|
||||||
genesis := &core.Genesis{
|
genesis := &core.Genesis{
|
||||||
Alloc: types.GenesisAlloc{
|
Alloc: types.GenesisAlloc{
|
||||||
accounts[0].addr: {Balance: big.NewInt(params.Ether)},
|
accounts[0].addr: {Balance: big.NewInt(params.Ether)},
|
||||||
|
|
@ -319,12 +327,12 @@ func TestOverridenTraceCall(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
genBlocks := 10
|
genBlocks := 10
|
||||||
signer := types.HomesteadSigner{}
|
signer := types.LatestSigner(&config)
|
||||||
api := NewAPI(newTestBackend(t, genBlocks, genesis, func(i int, b *core.BlockGen) {
|
api := NewAPI(newTestBackend(t, genBlocks, genesis, func(i int, b *core.BlockGen) {
|
||||||
// Transfer from account[0] to account[1]
|
// Transfer from account[0] to account[1]
|
||||||
// value: 1000 wei
|
// value: 1000 wei
|
||||||
// fee: 0 wei
|
// fee: 0 wei
|
||||||
tx, _ := types.SignTx(types.NewTransaction(uint64(i), accounts[1].addr, big.NewInt(1000), params.TxGas, big.NewInt(0), nil), signer, accounts[0].key)
|
tx, _ := types.SignTx(types.NewTransaction(uint64(i), accounts[1].addr, big.NewInt(1000), params.TxGas, b.BaseFee(), nil), signer, accounts[0].key)
|
||||||
b.AddTx(tx)
|
b.AddTx(tx)
|
||||||
}))
|
}))
|
||||||
randomAccounts, tracer := newAccounts(3), "callTracer"
|
randomAccounts, tracer := newAccounts(3), "callTracer"
|
||||||
|
|
@ -347,7 +355,7 @@ func TestOverridenTraceCall(t *testing.T) {
|
||||||
config: &TraceCallConfig{
|
config: &TraceCallConfig{
|
||||||
TraceConfig: TraceConfig{Tracer: &tracer},
|
TraceConfig: TraceConfig{Tracer: &tracer},
|
||||||
StateOverrides: ðapi.StateOverride{
|
StateOverrides: ðapi.StateOverride{
|
||||||
randomAccounts[0].addr: ethapi.OverrideAccount{Balance: newRPCBalance(big.NewInt(9000000000000000000))},
|
randomAccounts[0].addr: ethapi.OverrideAccount{Balance: newRPCBalance(big.NewInt(1000))},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectErr: nil,
|
expectErr: nil,
|
||||||
|
|
@ -371,7 +379,7 @@ func TestOverridenTraceCall(t *testing.T) {
|
||||||
config: &TraceCallConfig{
|
config: &TraceCallConfig{
|
||||||
TraceConfig: TraceConfig{Tracer: &tracer},
|
TraceConfig: TraceConfig{Tracer: &tracer},
|
||||||
StateOverrides: ðapi.StateOverride{
|
StateOverrides: ðapi.StateOverride{
|
||||||
randomAccounts[0].addr: ethapi.OverrideAccount{Balance: newRPCBalance(big.NewInt(1250000000000000000))},
|
randomAccounts[0].addr: ethapi.OverrideAccount{Balance: newRPCBalance(big.NewInt(1))},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectErr: core.ErrInsufficientFunds,
|
expectErr: core.ErrInsufficientFunds,
|
||||||
|
|
@ -413,17 +421,21 @@ func TestTraceTransaction(t *testing.T) {
|
||||||
|
|
||||||
// Initialize test accounts
|
// Initialize test accounts
|
||||||
accounts := newAccounts(2)
|
accounts := newAccounts(2)
|
||||||
genesis := &core.Genesis{Alloc: types.GenesisAlloc{
|
config := *params.TestChainConfig
|
||||||
accounts[0].addr: {Balance: big.NewInt(9000000000000000000)},
|
config.Eip1559Block = big.NewInt(0)
|
||||||
accounts[1].addr: {Balance: big.NewInt(9000000000000000000)},
|
genesis := &core.Genesis{
|
||||||
}}
|
Config: &config,
|
||||||
|
Alloc: types.GenesisAlloc{
|
||||||
|
accounts[0].addr: {Balance: big.NewInt(9000000000000000000)},
|
||||||
|
accounts[1].addr: {Balance: big.NewInt(9000000000000000000)},
|
||||||
|
}}
|
||||||
target := common.Hash{}
|
target := common.Hash{}
|
||||||
signer := types.HomesteadSigner{}
|
signer := types.LatestSigner(&config)
|
||||||
api := NewAPI(newTestBackend(t, 1, genesis, func(i int, b *core.BlockGen) {
|
api := NewAPI(newTestBackend(t, 1, genesis, func(i int, b *core.BlockGen) {
|
||||||
// Transfer from account[0] to account[1]
|
// Transfer from account[0] to account[1]
|
||||||
// value: 1000 wei
|
// value: 1000 wei
|
||||||
// fee: 0 wei
|
// fee: 0 wei
|
||||||
tx, _ := types.SignTx(types.NewTransaction(uint64(i), accounts[1].addr, big.NewInt(1000), params.TxGas, big.NewInt(0), nil), signer, accounts[0].key)
|
tx, _ := types.SignTx(types.NewTransaction(uint64(i), accounts[1].addr, big.NewInt(1000), params.TxGas, b.BaseFee(), nil), signer, accounts[0].key)
|
||||||
b.AddTx(tx)
|
b.AddTx(tx)
|
||||||
target = tx.Hash()
|
target = tx.Hash()
|
||||||
}))
|
}))
|
||||||
|
|
@ -446,18 +458,22 @@ func TestTraceBlock(t *testing.T) {
|
||||||
|
|
||||||
// Initialize test accounts
|
// Initialize test accounts
|
||||||
accounts := newAccounts(3)
|
accounts := newAccounts(3)
|
||||||
genesis := &core.Genesis{Alloc: types.GenesisAlloc{
|
config := *params.TestChainConfig
|
||||||
accounts[0].addr: {Balance: big.NewInt(9000000000000000000)},
|
config.Eip1559Block = big.NewInt(0)
|
||||||
accounts[1].addr: {Balance: big.NewInt(9000000000000000000)},
|
genesis := &core.Genesis{
|
||||||
accounts[2].addr: {Balance: big.NewInt(9000000000000000000)},
|
Config: &config,
|
||||||
}}
|
Alloc: types.GenesisAlloc{
|
||||||
|
accounts[0].addr: {Balance: big.NewInt(9000000000000000000)},
|
||||||
|
accounts[1].addr: {Balance: big.NewInt(9000000000000000000)},
|
||||||
|
accounts[2].addr: {Balance: big.NewInt(9000000000000000000)},
|
||||||
|
}}
|
||||||
genBlocks := 10
|
genBlocks := 10
|
||||||
signer := types.HomesteadSigner{}
|
signer := types.LatestSigner(&config)
|
||||||
api := NewAPI(newTestBackend(t, genBlocks, genesis, func(i int, b *core.BlockGen) {
|
api := NewAPI(newTestBackend(t, genBlocks, genesis, func(i int, b *core.BlockGen) {
|
||||||
// Transfer from account[0] to account[1]
|
// Transfer from account[0] to account[1]
|
||||||
// value: 1000 wei
|
// value: 1000 wei
|
||||||
// fee: 0 wei
|
// fee: 0 wei
|
||||||
tx, _ := types.SignTx(types.NewTransaction(uint64(i), accounts[1].addr, big.NewInt(1000), params.TxGas, big.NewInt(0), nil), signer, accounts[0].key)
|
tx, _ := types.SignTx(types.NewTransaction(uint64(i), accounts[1].addr, big.NewInt(1000), params.TxGas, b.BaseFee(), nil), signer, accounts[0].key)
|
||||||
b.AddTx(tx)
|
b.AddTx(tx)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue