Skip to content

Commit

Permalink
tests: adjust for new gas pricings
Browse files Browse the repository at this point in the history
  • Loading branch information
iquidus committed Jan 28, 2022
1 parent be55d32 commit 8389355
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 38 deletions.
26 changes: 13 additions & 13 deletions core/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ func TestFastVsFullChains(t *testing.T) {
gendb = rawdb.NewMemoryDatabase()
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
address = crypto.PubkeyToAddress(key.PublicKey)
funds = big.NewInt(10000000000000000)
funds = big.NewInt(8000000000000000000)
gspec = &Genesis{
Config: params.TestChainConfig,
Alloc: GenesisAlloc{address: {Balance: funds}},
Expand Down Expand Up @@ -867,9 +867,9 @@ func TestChainTxReorgs(t *testing.T) {
Config: params.TestChainConfig,
GasLimit: 3141592,
Alloc: GenesisAlloc{
addr1: {Balance: big.NewInt(10000000000000000)},
addr2: {Balance: big.NewInt(10000000000000000)},
addr3: {Balance: big.NewInt(10000000000000000)},
addr1: {Balance: big.NewInt(100000000000000000)},
addr2: {Balance: big.NewInt(100000000000000000)},
addr3: {Balance: big.NewInt(100000000000000000)},
},
}
genesis = gspec.MustCommit(db)
Expand Down Expand Up @@ -2145,7 +2145,7 @@ func TestTransactionIndices(t *testing.T) {
gendb = rawdb.NewMemoryDatabase()
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
address = crypto.PubkeyToAddress(key.PublicKey)
funds = big.NewInt(100000000000000000)
funds = big.NewInt(1000000000000000000)
gspec = &Genesis{
Config: params.TestChainConfig,
Alloc: GenesisAlloc{address: {Balance: funds}},
Expand Down Expand Up @@ -2276,7 +2276,7 @@ func TestSkipStaleTxIndicesInFastSync(t *testing.T) {
gendb = rawdb.NewMemoryDatabase()
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
address = crypto.PubkeyToAddress(key.PublicKey)
funds = big.NewInt(100000000000000000)
funds = big.NewInt(1000000000000000000)
gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{address: {Balance: funds}}}
genesis = gspec.MustCommit(gendb)
signer = types.LatestSigner(gspec.Config)
Expand Down Expand Up @@ -2601,7 +2601,7 @@ func TestDeleteRecreateSlots(t *testing.T) {
// A sender who makes transactions, has some funds
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
address = crypto.PubkeyToAddress(key.PublicKey)
funds = big.NewInt(10000000000000000)
funds = big.NewInt(100000000000000000)
bb = common.HexToAddress("0x000000000000000000000000000000000000bbbb")
aaStorage = make(map[common.Hash]common.Hash) // Initial storage in AA
aaCode = []byte{byte(vm.PC), byte(vm.SELFDESTRUCT)} // Code for AA (simple selfdestruct)
Expand Down Expand Up @@ -2728,7 +2728,7 @@ func TestDeleteRecreateAccount(t *testing.T) {
// A sender who makes transactions, has some funds
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
address = crypto.PubkeyToAddress(key.PublicKey)
funds = big.NewInt(10000000000000000)
funds = big.NewInt(100000000000000000)

aa = common.HexToAddress("0x7217d81b76bdd8707601e959454e3d776aee5f43")
aaStorage = make(map[common.Hash]common.Hash) // Initial storage in AA
Expand Down Expand Up @@ -2804,7 +2804,7 @@ func TestDeleteRecreateSlotsAcrossManyBlocks(t *testing.T) {
// A sender who makes transactions, has some funds
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
address = crypto.PubkeyToAddress(key.PublicKey)
funds = big.NewInt(100000000000000000)
funds = big.NewInt(1000000000000000000)
bb = common.HexToAddress("0x000000000000000000000000000000000000bbbb")
aaStorage = make(map[common.Hash]common.Hash) // Initial storage in AA
aaCode = []byte{byte(vm.PC), byte(vm.SELFDESTRUCT)} // Code for AA (simple selfdestruct)
Expand Down Expand Up @@ -3121,7 +3121,7 @@ func TestEIP2718Transition(t *testing.T) {
// A sender who makes transactions, has some funds
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
address = crypto.PubkeyToAddress(key.PublicKey)
funds = big.NewInt(10000000000000000)
funds = big.NewInt(100000000000000000)
gspec = &Genesis{
Config: params.TestChainConfig,
Alloc: GenesisAlloc{
Expand Down Expand Up @@ -3152,7 +3152,7 @@ func TestEIP2718Transition(t *testing.T) {
Nonce: 0,
To: &aa,
Gas: 30000,
GasPrice: big.NewInt(71000000000),
GasPrice: big.NewInt(81000000000),
AccessList: types.AccessList{{
Address: aa,
StorageKeys: []common.Hash{{0}},
Expand Down Expand Up @@ -3247,7 +3247,7 @@ func TestEIP1559Transition(t *testing.T) {
Nonce: 0,
To: &aa,
Gas: 30000,
GasFeeCap: newGwei(71),
GasFeeCap: newGwei(82),
GasTipCap: big.NewInt(2),
AccessList: accesses,
Data: []byte{},
Expand Down Expand Up @@ -3306,7 +3306,7 @@ func TestEIP1559Transition(t *testing.T) {
Nonce: 0,
To: &aa,
Gas: 30000,
GasPrice: newGwei(70),
GasPrice: newGwei(81),
}
tx := types.NewTx(txdata)
tx, _ = types.SignTx(tx, signer, key2)
Expand Down
28 changes: 14 additions & 14 deletions core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestStateProcessorErrors(t *testing.T) {
Config: config,
Alloc: GenesisAlloc{
common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): GenesisAccount{
Balance: big.NewInt(2000000000000000000), // 2 ether
Balance: big.NewInt(4000000000000000000), // 4 ether
Nonce: 0,
},
common.HexToAddress("0xfd0810DD14796680f72adf1a371963d0745BCc64"): GenesisAccount{
Expand All @@ -103,10 +103,10 @@ func TestStateProcessorErrors(t *testing.T) {
}{
{ // ErrNonceTooLow
txs: []*types.Transaction{
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.TxGas, big.NewInt(70000000000), nil),
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.TxGas, big.NewInt(70000000000), nil),
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.TxGas, big.NewInt(810000000000), nil),
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.TxGas, big.NewInt(810000000000), nil),
},
want: "could not apply tx 1 [0x035a4d54498b8faecac7ead306be8d5c641d81150da56d4ca0011820c9d0e732]: nonce too low: address 0x71562b71999873DB5b286dF957af199Ec94617F7, tx: 0 state: 1",
want: "could not apply tx 1 [0xff614db3c65e3d21b66c25829da0daadc6119feeb6ace13a5fc8e72f60f3b8e6]: nonce too low: address 0x71562b71999873DB5b286dF957af199Ec94617F7, tx: 0 state: 1",
},
{ // ErrNonceTooHigh
txs: []*types.Transaction{
Expand All @@ -122,37 +122,37 @@ func TestStateProcessorErrors(t *testing.T) {
},
{ // ErrGasLimitReached
txs: []*types.Transaction{
makeTx(key1, 0, common.Address{}, big.NewInt(0), 21000000, big.NewInt(70000000000), nil),
makeTx(key1, 0, common.Address{}, big.NewInt(0), 21000000, big.NewInt(81000000000), nil),
},
want: "could not apply tx 0 [0x71f496a82fafcb2e3cab0e27796b10984702fd00ea7ad648af22397cb05652a8]: gas limit reached",
want: "could not apply tx 0 [0x8513c2ba1a55e84a30582ce8ece0c5ea5e446590cdcd8384506ee16cbfcede73]: gas limit reached",
},
{ // ErrInsufficientFundsForTransfer
txs: []*types.Transaction{
makeTx(key1, 0, common.Address{}, big.NewInt(1000000000000000000), params.TxGas, big.NewInt(800000000000000), nil),
},
want: "could not apply tx 0 [0x95c504430523b9af2e3765f7a79b5a77275dd329a1f79d7251121b286a80c667]: insufficient funds for gas * price + value: address 0x71562b71999873DB5b286dF957af199Ec94617F7 have 2000000000000000000 want 17800000000000000000",
want: "could not apply tx 0 [0x95c504430523b9af2e3765f7a79b5a77275dd329a1f79d7251121b286a80c667]: insufficient funds for gas * price + value: address 0x71562b71999873DB5b286dF957af199Ec94617F7 have 4000000000000000000 want 17800000000000000000",
},
{ // ErrInsufficientFunds
txs: []*types.Transaction{
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.TxGas, big.NewInt(900000000000000000), nil),
},
want: "could not apply tx 0 [0x4a69690c4b0cd85e64d0d9ea06302455b01e10a83db964d60281739752003440]: insufficient funds for gas * price + value: address 0x71562b71999873DB5b286dF957af199Ec94617F7 have 2000000000000000000 want 18900000000000000000000",
want: "could not apply tx 0 [0x4a69690c4b0cd85e64d0d9ea06302455b01e10a83db964d60281739752003440]: insufficient funds for gas * price + value: address 0x71562b71999873DB5b286dF957af199Ec94617F7 have 4000000000000000000 want 18900000000000000000000",
},
// ErrGasUintOverflow
// One missing 'core' error is ErrGasUintOverflow: "gas uint64 overflow",
// In order to trigger that one, we'd have to allocate a _huge_ chunk of data, such that the
// multiplication len(data) +gas_per_byte overflows uint64. Not testable at the moment
{ // ErrIntrinsicGas
txs: []*types.Transaction{
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.TxGas-1000, big.NewInt(70000000000), nil),
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.TxGas-1000, big.NewInt(81000000000), nil),
},
want: "could not apply tx 0 [0x0d0ca7d886da6c28ac094d3c2d2d0783b3753c9b92fcd2987c8d21b87fceb69f]: intrinsic gas too low: have 20000, want 21000",
want: "could not apply tx 0 [0xa1973160a53bd892ab1a7489c2aa84bf41ee3d13e383e84b49d29c02bb8348e7]: intrinsic gas too low: have 20000, want 21000",
},
{ // ErrGasLimitReached
txs: []*types.Transaction{
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.TxGas*1000, big.NewInt(70000000000), nil),
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.TxGas*1000, big.NewInt(81000000000), nil),
},
want: "could not apply tx 0 [0x71f496a82fafcb2e3cab0e27796b10984702fd00ea7ad648af22397cb05652a8]: gas limit reached",
want: "could not apply tx 0 [0x8513c2ba1a55e84a30582ce8ece0c5ea5e446590cdcd8384506ee16cbfcede73]: gas limit reached",
},
{ // ErrFeeCapTooLow
txs: []*types.Transaction{
Expand Down Expand Up @@ -187,13 +187,13 @@ func TestStateProcessorErrors(t *testing.T) {
txs: []*types.Transaction{
mkDynamicTx(0, common.Address{}, params.TxGas, big.NewInt(1), big.NewInt(500000000000000)),
},
want: "could not apply tx 0 [0x3e4bc338670810e7edcd7570dce67ee4e4ac9e38fcea6febc51f89d9bd7fe4ec]: insufficient funds for gas * price + value: address 0x71562b71999873DB5b286dF957af199Ec94617F7 have 2000000000000000000 want 10500000000000000000",
want: "could not apply tx 0 [0x3e4bc338670810e7edcd7570dce67ee4e4ac9e38fcea6febc51f89d9bd7fe4ec]: insufficient funds for gas * price + value: address 0x71562b71999873DB5b286dF957af199Ec94617F7 have 4000000000000000000 want 10500000000000000000",
},
{ // Another ErrInsufficientFunds, this one to ensure that feecap/tip of max u256 is allowed
txs: []*types.Transaction{
mkDynamicTx(0, common.Address{}, params.TxGas, bigNumber, bigNumber),
},
want: "could not apply tx 0 [0xd82a0c2519acfeac9a948258c47e784acd20651d9d80f9a1c67b4137651c3a24]: insufficient funds for gas * price + value: address 0x71562b71999873DB5b286dF957af199Ec94617F7 have 2000000000000000000 want 2431633873983640103894990685182446064918669677978451844828609264166175722438635000",
want: "could not apply tx 0 [0xd82a0c2519acfeac9a948258c47e784acd20651d9d80f9a1c67b4137651c3a24]: insufficient funds for gas * price + value: address 0x71562b71999873DB5b286dF957af199Ec94617F7 have 4000000000000000000 want 2431633873983640103894990685182446064918669677978451844828609264166175722438635000",
},
} {
block := GenerateBadBlock(genesis, ubqhash.NewFaker(), tt.txs, gspec.Config)
Expand Down
2 changes: 1 addition & 1 deletion eth/downloader/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (

var (
testdb = rawdb.NewMemoryDatabase()
genesis = core.GenesisBlockForTesting(testdb, testAddress, big.NewInt(10000000000000000))
genesis = core.GenesisBlockForTesting(testdb, testAddress, big.NewInt(8000000000000000000))
)

// makeChain creates a chain of n blocks starting at and including parent.
Expand Down
2 changes: 1 addition & 1 deletion eth/downloader/testchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
testAddress = crypto.PubkeyToAddress(testKey.PublicKey)
testDB = rawdb.NewMemoryDatabase()
testGenesis = core.GenesisBlockForTesting(testDB, testAddress, big.NewInt(2000000000000000))
testGenesis = core.GenesisBlockForTesting(testDB, testAddress, big.NewInt(800000000000000000))
)

// The common prefix of all test chains:
Expand Down
2 changes: 1 addition & 1 deletion eth/fetcher/block_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var (
testdb = rawdb.NewMemoryDatabase()
testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
testAddress = crypto.PubkeyToAddress(testKey.PublicKey)
genesis = core.GenesisBlockForTesting(testdb, testAddress, big.NewInt(8000000000000000))
genesis = core.GenesisBlockForTesting(testdb, testAddress, big.NewInt(800000000000000000))
unknownBlock = types.NewBlock(&types.Header{GasLimit: params.GenesisGasLimit, BaseFee: big.NewInt(params.InitialBaseFee)}, nil, nil, nil, trie.NewStackTrie(nil))
)

Expand Down
4 changes: 2 additions & 2 deletions eth/gasprice/gasprice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ func TestSuggestTipCap(t *testing.T) {
expect *big.Int // Expected gasprice suggestion
}{
{nil, big.NewInt(params.GWei * int64(30))},
{big.NewInt(0), big.NewInt(params.GWei * int64(30))}, // Fork point in genesis
{big.NewInt(1), big.NewInt(params.GWei * int64(30))}, // Fork point in first block
{big.NewInt(0), big.NewInt(params.GWei * int64(20))}, // Fork point in genesis
{big.NewInt(1), big.NewInt(params.GWei * int64(20))}, // Fork point in first block
{big.NewInt(32), big.NewInt(params.GWei * int64(29))}, // Fork point in last block
{big.NewInt(33), big.NewInt(params.GWei * int64(30))}, // Fork point in the future
}
Expand Down
4 changes: 2 additions & 2 deletions ethclient/ethclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ func testStatusFunctions(t *testing.T, client *rpc.Client) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if gasPrice.Cmp(big.NewInt(80000000000)) != 0 {
if gasPrice.Cmp(big.NewInt(81000000000)) != 0 {
t.Fatalf("unexpected gas price: %v", gasPrice)
}

Expand All @@ -502,7 +502,7 @@ func testStatusFunctions(t *testing.T, client *rpc.Client) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if gasTipCap.Cmp(big.NewInt(18750000000)) != 0 {
if gasTipCap.Cmp(big.NewInt(1000000000)) != 0 {
t.Fatalf("unexpected gas tip cap: %v", gasTipCap)
}
}
Expand Down
6 changes: 3 additions & 3 deletions ethclient/gethclient/gethclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
var (
testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
testAddr = crypto.PubkeyToAddress(testKey.PublicKey)
testBalance = big.NewInt(8e15)
testBalance = big.NewInt(8e16)
)

func newTestBackend(t *testing.T) (*node.Node, []*types.Block) {
Expand Down Expand Up @@ -141,7 +141,7 @@ func testAccessList(t *testing.T, client *rpc.Client) {
From: testAddr,
To: &common.Address{},
Gas: 21000,
GasPrice: big.NewInt(70000000000),
GasPrice: big.NewInt(81000000000),
Value: big.NewInt(1),
}
al, gas, vmErr, err := ec.CreateAccessList(context.Background(), msg)
Expand All @@ -162,7 +162,7 @@ func testAccessList(t *testing.T, client *rpc.Client) {
From: testAddr,
To: nil,
Gas: 100000,
GasPrice: big.NewInt(61250000000),
GasPrice: big.NewInt(81000000000),
Value: big.NewInt(1),
Data: common.FromHex("0x608060806080608155fd"),
}
Expand Down
2 changes: 1 addition & 1 deletion graphql/graphql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func createGQLServiceWithTransactions(t *testing.T, stack *node.Node) {
// create backend
key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
address := crypto.PubkeyToAddress(key.PublicKey)
funds := big.NewInt(10000000000000000)
funds := big.NewInt(100000000000000000)
dad := common.HexToAddress("0x0000000000000000000000000000000000000dad")

ethConf := &ethconfig.Config{
Expand Down

0 comments on commit 8389355

Please sign in to comment.