lnd/fuzz/zpay32/decode.go
eugene bbe85f3c16 fuzz/zpay32: add Decode/Encode fuzz tests.
These can be expanded on in the future. Encoding is currently done
with a static key for test determinism.
2020-10-21 06:42:54 -04:00

23 lines
447 B
Go

// +build gofuzz
package zpay32fuzz
import (
"github.com/btcsuite/btcd/chaincfg"
"github.com/lightningnetwork/lnd/zpay32"
)
// Fuzz_decode is used by go-fuzz.
func Fuzz_decode(data []byte) int {
inv, err := zpay32.Decode(string(data), &chaincfg.TestNet3Params)
if err != nil {
return 1
}
// Call these functions as a sanity check to make sure the invoice
// is well-formed.
_ = inv.MinFinalCLTVExpiry()
_ = inv.Expiry()
return 1
}