Skip to content

Commit 2f10cb1

Browse files
author
Chandra Pratap
committed
fuzz-tests: Add a roundtrip check for bigsize_put()
Add a roundtrip check for `bigsize_put()` using `bigsize_get()`. This enforces a stricter check for the former and adds a test for the latter, which is currently untested.
1 parent 466c048 commit 2f10cb1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tests/fuzz/fuzz-bigsize.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ void run(const uint8_t *data, size_t size)
2020
wire_max = tal_count(wire_chunks[i]);
2121
wire_ptr = wire_chunks[i];
2222

23-
bigsize_t bs = fromwire_bigsize(&wire_ptr, &wire_max);
23+
bigsize_t bs = fromwire_bigsize(&wire_ptr, &wire_max), bs_decoded;
2424
assert(bigsize_put(buff, bs) > 0);
2525
assert(bigsize_len(bs));
26+
assert(bigsize_get(buff, sizeof(buff), &bs_decoded) == bigsize_len(bs));
27+
assert(bs_decoded == bs);
2628

2729
wire_buff = tal_arr(NULL, uint8_t, 8);
2830
towire_bigsize(&wire_buff, bs);

0 commit comments

Comments
 (0)