mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-08 02:40:24 +02:00
zpay32: use message signer from unit tests
The message signer from invoice_test.go is identical to the one created in the fuzz test. We're already using the private key from invoice_test.go, so we may as well use the complete message signer for simplicity.
This commit is contained in:
parent
4207be6e50
commit
82753f091b
@ -1,13 +1,9 @@
|
|||||||
package zpay32
|
package zpay32
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec/v2"
|
|
||||||
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
|
||||||
"github.com/btcsuite/btcd/chaincfg"
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func FuzzDecode(f *testing.F) {
|
func FuzzDecode(f *testing.F) {
|
||||||
@ -23,26 +19,7 @@ func FuzzEncode(f *testing.F) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the static key we will be using for this fuzz
|
// Re-encode the invoice using our private key from unit tests.
|
||||||
// test.
|
|
||||||
testPrivKey, _ := btcec.PrivKeyFromBytes(testPrivKeyBytes)
|
|
||||||
|
|
||||||
// Then, initialize the testMessageSigner so we can encode out
|
|
||||||
// invoices with this private key.
|
|
||||||
testMessageSigner := MessageSigner{
|
|
||||||
SignCompact: func(msg []byte) ([]byte, error) {
|
|
||||||
hash := chainhash.HashB(msg)
|
|
||||||
sig, err := ecdsa.SignCompact(testPrivKey, hash,
|
|
||||||
true)
|
|
||||||
if err != nil {
|
|
||||||
return nil,
|
|
||||||
fmt.Errorf("can't sign the "+
|
|
||||||
"message: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return sig, nil
|
|
||||||
},
|
|
||||||
}
|
|
||||||
_, err = inv.Encode(testMessageSigner)
|
_, err = inv.Encode(testMessageSigner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user