Skip to content

Commit b958667

Browse files
authored
Merge pull request #9355 from Roasbeef/rapid-fuzz-htlc-blobs
contractcourt: add rapid derived fuzz test for HtlcAuxBlob
2 parents 1b0f41d + 78cbed9 commit b958667

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

contractcourt/taproot_briefcase_test.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,30 @@ func TestTaprootBriefcase(t *testing.T) {
127127
require.Equal(t, testCase, &decodedCase)
128128
}
129129

130+
// testHtlcAuxBlobProperties is a rapid property that verifies the encoding and
131+
// decoding of the HTLC aux blobs.
132+
func testHtlcAuxBlobProperties(t *rapid.T) {
133+
htlcBlobs := rapid.Make[htlcAuxBlobs]().Draw(t, "htlcAuxBlobs")
134+
135+
var b bytes.Buffer
136+
require.NoError(t, htlcBlobs.Encode(&b))
137+
138+
decodedBlobs := newAuxHtlcBlobs()
139+
require.NoError(t, decodedBlobs.Decode(&b))
140+
141+
require.Equal(t, htlcBlobs, decodedBlobs)
142+
}
143+
130144
// TestHtlcAuxBlobEncodeDecode tests the encode/decode methods of the HTLC aux
131145
// blobs.
132146
func TestHtlcAuxBlobEncodeDecode(t *testing.T) {
133147
t.Parallel()
134148

135-
rapid.Check(t, func(t *rapid.T) {
136-
htlcBlobs := rapid.Make[htlcAuxBlobs]().Draw(t, "htlcAuxBlobs")
137-
138-
var b bytes.Buffer
139-
require.NoError(t, htlcBlobs.Encode(&b))
140-
141-
decodedBlobs := newAuxHtlcBlobs()
142-
require.NoError(t, decodedBlobs.Decode(&b))
149+
rapid.Check(t, testHtlcAuxBlobProperties)
150+
}
143151

144-
require.Equal(t, htlcBlobs, decodedBlobs)
145-
})
152+
// FuzzHtlcAuxBlobEncodeDecodeFuzz tests the encode/decode methods of the HTLC
153+
// aux blobs using the rapid derived fuzzer.
154+
func FuzzHtlcAuxBlobEncodeDecode(f *testing.F) {
155+
f.Fuzz(rapid.MakeFuzz(testHtlcAuxBlobProperties))
146156
}

0 commit comments

Comments
 (0)