Merge pull request #9355 from Roasbeef/rapid-fuzz-htlc-blobs
contractcourt: add rapid derived fuzz test for HtlcAuxBlob
This commit is contained in:
1 file changed
+21
-11
@@ -127,20 +127,30 @@ func TestTaprootBriefcase(t *testing.T) {
|
||||
require.Equal(t, testCase, &decodedCase)
|
||||
}
|
||||
|
||||
// testHtlcAuxBlobProperties is a rapid property that verifies the encoding and
|
||||
// decoding of the HTLC aux blobs.
|
||||
func testHtlcAuxBlobProperties(t *rapid.T) {
|
||||
htlcBlobs := rapid.Make[htlcAuxBlobs]().Draw(t, "htlcAuxBlobs")
|
||||
|
||||
var b bytes.Buffer
|
||||
require.NoError(t, htlcBlobs.Encode(&b))
|
||||
|
||||
decodedBlobs := newAuxHtlcBlobs()
|
||||
require.NoError(t, decodedBlobs.Decode(&b))
|
||||
|
||||
require.Equal(t, htlcBlobs, decodedBlobs)
|
||||
}
|
||||
|
||||
// TestHtlcAuxBlobEncodeDecode tests the encode/decode methods of the HTLC aux
|
||||
// blobs.
|
||||
func TestHtlcAuxBlobEncodeDecode(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
rapid.Check(t, func(t *rapid.T) {
|
||||
htlcBlobs := rapid.Make[htlcAuxBlobs]().Draw(t, "htlcAuxBlobs")
|
||||
|
||||
var b bytes.Buffer
|
||||
require.NoError(t, htlcBlobs.Encode(&b))
|
||||
|
||||
decodedBlobs := newAuxHtlcBlobs()
|
||||
require.NoError(t, decodedBlobs.Decode(&b))
|
||||
|
||||
require.Equal(t, htlcBlobs, decodedBlobs)
|
||||
})
|
||||
rapid.Check(t, testHtlcAuxBlobProperties)
|
||||
}
|
||||
|
||||
// FuzzHtlcAuxBlobEncodeDecodeFuzz tests the encode/decode methods of the HTLC
|
||||
// aux blobs using the rapid derived fuzzer.
|
||||
func FuzzHtlcAuxBlobEncodeDecode(f *testing.F) {
|
||||
f.Fuzz(rapid.MakeFuzz(testHtlcAuxBlobProperties))
|
||||
}
|
||||
Reference in new issue
Block a user