ethereum, ethclient: add FeeHistory support (#25403)

Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
lightclient
2022-07-29 18:22:04 +02:00
committed by GitHub
co-authored by Felix Lange
parent 377c7d799f
commit 9ad508018e
4 changed files with 65 additions and 0 deletions
+23
View File
@@ -508,6 +508,29 @@ func testStatusFunctions(t *testing.T, client *rpc.Client) {
if gasTipCap.Cmp(big.NewInt(234375000)) != 0 {
t.Fatalf("unexpected gas tip cap: %v", gasTipCap)
}
// FeeHistory
history, err := ec.FeeHistory(context.Background(), 1, big.NewInt(2), []float64{95, 99})
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
want := &ethereum.FeeHistory{
OldestBlock: big.NewInt(2),
Reward: [][]*big.Int{
{
big.NewInt(234375000),
big.NewInt(234375000),
},
},
BaseFee: []*big.Int{
big.NewInt(765625000),
big.NewInt(671627818),
},
GasUsedRatio: []float64{0.008912678667376286},
}
if !reflect.DeepEqual(history, want) {
t.Fatalf("FeeHistory result doesn't match expected: (got: %v, want: %v)", history, want)
}
}
func testCallContractAtHash(t *testing.T, client *rpc.Client) {