Skip to content

Commit ecf46bd

Browse files
lightclientRampex1
authored andcommitted
eth/gasprice: sanity check ratio values (ethereum#31270)
Follow on to ethereum#31246. Adds a sanity check in the test to make sure the ratio value never goes over 1. Would have avoided the issue in ethereum#31245.
1 parent e01415c commit ecf46bd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

eth/gasprice/feehistory_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,19 @@ func TestFeeHistory(t *testing.T) {
8484
if len(ratio) != c.expCount {
8585
t.Fatalf("Test case %d: gasUsedRatio array length mismatch, want %d, got %d", i, c.expCount, len(ratio))
8686
}
87+
for _, ratio := range ratio {
88+
if ratio > 1 {
89+
t.Fatalf("Test case %d: gasUsedRatio greater than 1, got %f", i, ratio)
90+
}
91+
}
8792
if len(blobRatio) != c.expCount {
8893
t.Fatalf("Test case %d: blobGasUsedRatio array length mismatch, want %d, got %d", i, c.expCount, len(blobRatio))
8994
}
95+
for _, ratio := range blobRatio {
96+
if ratio > 1 {
97+
t.Fatalf("Test case %d: blobGasUsedRatio greater than 1, got %f", i, ratio)
98+
}
99+
}
90100
if len(blobBaseFee) != len(baseFee) {
91101
t.Fatalf("Test case %d: blobBaseFee array length mismatch, want %d, got %d", i, len(baseFee), len(blobBaseFee))
92102
}

0 commit comments

Comments
 (0)