github.com/decred/dcrlnd@v0.7.6/fuzz/zpay32/decode.go (about)

     1  //go:build gofuzz
     2  // +build gofuzz
     3  
     4  package zpay32fuzz
     5  
     6  import (
     7  	"github.com/decred/dcrd/chaincfg/v3"
     8  	"github.com/decred/dcrlnd/zpay32"
     9  )
    10  
    11  // Fuzz_decode is used by go-fuzz.
    12  func Fuzz_decode(data []byte) int {
    13  	inv, err := zpay32.Decode(string(data), chaincfg.TestNet3Params())
    14  	if err != nil {
    15  		return 1
    16  	}
    17  
    18  	// Call these functions as a sanity check to make sure the invoice
    19  	// is well-formed.
    20  	_ = inv.MinFinalCLTVExpiry()
    21  	_ = inv.Expiry()
    22  	return 1
    23  }