Skip to content

Commit

Permalink
eth/gasprice: sanity check ratio values (#31270)
Browse files Browse the repository at this point in the history
Follow on to #31246. Adds a sanity check in the test to make sure the
ratio value never goes over 1. Would have avoided the issue in #31245.
  • Loading branch information
lightclient authored Feb 27, 2025
1 parent 939a804 commit 1d2043e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions eth/gasprice/feehistory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,19 @@ func TestFeeHistory(t *testing.T) {
if len(ratio) != c.expCount {
t.Fatalf("Test case %d: gasUsedRatio array length mismatch, want %d, got %d", i, c.expCount, len(ratio))
}
for _, ratio := range ratio {
if ratio > 1 {
t.Fatalf("Test case %d: gasUsedRatio greater than 1, got %f", i, ratio)
}
}
if len(blobRatio) != c.expCount {
t.Fatalf("Test case %d: blobGasUsedRatio array length mismatch, want %d, got %d", i, c.expCount, len(blobRatio))
}
for _, ratio := range blobRatio {
if ratio > 1 {
t.Fatalf("Test case %d: blobGasUsedRatio greater than 1, got %f", i, ratio)
}
}
if len(blobBaseFee) != len(baseFee) {
t.Fatalf("Test case %d: blobBaseFee array length mismatch, want %d, got %d", i, len(baseFee), len(blobBaseFee))
}
Expand Down

0 comments on commit 1d2043e

Please sign in to comment.