test: Updated test cases to include MaxInt64, MinInt64 and MaxUint64, also rename testcase to TestHas0xPrefix to cover Has0xPrefix public method in hexutil package

This commit is contained in:
Tarun Sharma 2025-05-16 12:55:45 +04:00
parent 631be3cc04
commit c14f2e17aa
2 changed files with 6 additions and 6 deletions

View file

@ -141,7 +141,7 @@ var (
}
hexStringValidityTest = []hexValidityTest{
{"0x", false},
{"0x", true},
{"asdcc", false},
{"0x00000102", true},
}
@ -213,9 +213,9 @@ func TestDecodeUint64(t *testing.T) {
}
}
func TestIsValidHexString(t *testing.T) {
func TestHas0xPrefix(t *testing.T) {
for _, test := range hexStringValidityTest {
actual := IsValidHexString(test.input)
actual := Has0xPrefix(test.input)
if actual != test.want {
t.Errorf("input %s: value mismatch: got %t, want %t", test.input, actual, test.want)
}

View file

@ -54,9 +54,9 @@ func TestBlockNumberJSONUnmarshal(t *testing.T) {
18: {``, true, BlockNumber(0)},
19: {`88439993`, false, BlockNumber(88439993)},
20: {`-1`, true, BlockNumber(0)},
21: {`MaxInt64`, true, BlockNumber(0)},
22: {`MinInt64`, true, BlockNumber(0)},
23: {`MaxUint64`, true, BlockNumber(0)},
21: {`9223372036854775807`, false, BlockNumber(9223372036854775807)},
22: {`-9223372036854775808`, true, BlockNumber(0)},
23: {`18446744073709551615`, true, BlockNumber(0)},
}
for i, test := range tests {