Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add testcase for createAccessList when gasPrice is less than baseFee …
…(default 875M)
  • Loading branch information
SangIlMo authored and holiman committed Nov 8, 2024
commit 1280d75987fb59d9eee385c357871d5150155c3c
23 changes: 23 additions & 0 deletions ethclient/gethclient/gethclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"math/big"
"testing"

Expand Down Expand Up @@ -214,6 +215,28 @@ func testAccessList(t *testing.T, client *rpc.Client) {
if (*al)[0].StorageKeys[0] != common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000081") {
t.Fatalf("unexpected storage key: %v", (*al)[0].StorageKeys[0])
}

// error when gasPrice is less than baseFee
msg = ethereum.CallMsg{
From: testAddr,
To: &common.Address{},
Gas: 21000,
GasPrice: big.NewInt(1), // less than baseFee
Value: big.NewInt(1),
}
al, gas, vmErr, err = ec.CreateAccessList(context.Background(), msg)
if errors.Is(err, core.ErrBlobFeeCapTooLow) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it, you are waiting for a specific error here, right?
Why are you checking for BlobFeeCap too low, which has nothing to do with the basefeecap?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I just fix this code. (ErrFeeCapTooLow)

One thing is the err at this code, cannot be unwrapped because it was from RPC API response format. So I choose strings.Contains to get the error contains the ErrFeeCapTooLow.

t.Fatalf("unexpected error: %v", err)
}
if vmErr != "" {
t.Fatalf("unexpected vm error: %v", vmErr)
}
if gas != 0 {
t.Fatalf("unexpected gas used: %v", gas)
}
if al != nil {
t.Fatalf("unexpected accesslist: %v", len(*al))
}
}

func testGetProof(t *testing.T, client *rpc.Client, addr common.Address) {
Expand Down