mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-28 10:41:57 +01:00
Merge pull request #9355 from Roasbeef/rapid-fuzz-htlc-blobs
contractcourt: add rapid derived fuzz test for HtlcAuxBlob
This commit is contained in:
commit
b958667811
@ -127,20 +127,30 @@ func TestTaprootBriefcase(t *testing.T) {
|
|||||||
require.Equal(t, testCase, &decodedCase)
|
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
|
// TestHtlcAuxBlobEncodeDecode tests the encode/decode methods of the HTLC aux
|
||||||
// blobs.
|
// blobs.
|
||||||
func TestHtlcAuxBlobEncodeDecode(t *testing.T) {
|
func TestHtlcAuxBlobEncodeDecode(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
rapid.Check(t, func(t *rapid.T) {
|
rapid.Check(t, testHtlcAuxBlobProperties)
|
||||||
htlcBlobs := rapid.Make[htlcAuxBlobs]().Draw(t, "htlcAuxBlobs")
|
}
|
||||||
|
|
||||||
var b bytes.Buffer
|
// FuzzHtlcAuxBlobEncodeDecodeFuzz tests the encode/decode methods of the HTLC
|
||||||
require.NoError(t, htlcBlobs.Encode(&b))
|
// aux blobs using the rapid derived fuzzer.
|
||||||
|
func FuzzHtlcAuxBlobEncodeDecode(f *testing.F) {
|
||||||
decodedBlobs := newAuxHtlcBlobs()
|
f.Fuzz(rapid.MakeFuzz(testHtlcAuxBlobProperties))
|
||||||
require.NoError(t, decodedBlobs.Decode(&b))
|
|
||||||
|
|
||||||
require.Equal(t, htlcBlobs, decodedBlobs)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user