Skip to content

Commit c80d7d4

Browse files
committed
test(chainwork): skip long inputs in FuzzChainWorkFromHex
Added a check to skip unrealistically long hex strings to prevent timeouts during big.Int operations.
1 parent e0dde43 commit c80d7d4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/chaintracks/chainwork_fuzz_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ func FuzzChainWorkFromHex(f *testing.F) {
6363
f.Add(string([]byte{0x00, 0x01, 0x02})) // control chars
6464

6565
f.Fuzz(func(t *testing.T, hexStr string) {
66+
// Skip unrealistically long inputs to avoid timeout on expensive big.Int operations
67+
// Bitcoin chainwork is at most 256 bits = 64 hex characters
68+
if len(hexStr) > 64 {
69+
return
70+
}
71+
6672
// Should never panic
6773
result, err := ChainWorkFromHex(hexStr)
6874

0 commit comments

Comments
 (0)