mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-26 01:33:02 +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)
|
||||
}
|
||||
|
||||
// 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))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user