input: introduce Signature iface

This commit introduces the Signature interface which will be used by our
witness construction methods instead of passing in raw byte slices. This
will be used later to inject various kinds of mock signatures, e.g.
73-byte signatures for simulating worst-case witness weight.
This commit is contained in:
Conner Fromknecht
2020-04-05 17:06:14 -07:00
parent 2b2c8b5a10
commit 37dffb225a
3 changed files with 37 additions and 11 deletions

View File

@@ -226,7 +226,7 @@ func TestHTLCSenderSpendValidation(t *testing.T) {
htlcOutput *wire.TxOut
sweepTxSigHashes *txscript.TxSigHashes
senderCommitTx, sweepTx *wire.MsgTx
bobRecvrSig []byte
bobRecvrSig *btcec.Signature
bobSigHash txscript.SigHashType
)
@@ -303,10 +303,15 @@ func TestHTLCSenderSpendValidation(t *testing.T) {
SigHashes: sweepTxSigHashes,
InputIndex: 0,
}
bobRecvrSig, err = bobSigner.SignOutputRaw(sweepTx, &bobSignDesc)
bobSigBytes, err := bobSigner.SignOutputRaw(sweepTx, &bobSignDesc)
if err != nil {
t.Fatalf("unable to generate alice signature: %v", err)
}
bobRecvrSig, err = btcec.ParseDERSignature(bobSigBytes, btcec.S256())
if err != nil {
t.Fatalf("unable to parse signature: %v", err)
}
}
testCases := []struct {
@@ -622,7 +627,7 @@ func TestHTLCReceiverSpendValidation(t *testing.T) {
htlcOutput *wire.TxOut
receiverCommitTx, sweepTx *wire.MsgTx
sweepTxSigHashes *txscript.TxSigHashes
aliceSenderSig []byte
aliceSenderSig *btcec.Signature
aliceSigHash txscript.SigHashType
)
@@ -695,10 +700,15 @@ func TestHTLCReceiverSpendValidation(t *testing.T) {
SigHashes: sweepTxSigHashes,
InputIndex: 0,
}
aliceSenderSig, err = aliceSigner.SignOutputRaw(sweepTx, &aliceSignDesc)
aliceSigBytes, err := aliceSigner.SignOutputRaw(sweepTx, &aliceSignDesc)
if err != nil {
t.Fatalf("unable to generate alice signature: %v", err)
}
aliceSenderSig, err = btcec.ParseDERSignature(aliceSigBytes, btcec.S256())
if err != nil {
t.Fatalf("unable to parse signature: %v", err)
}
}
// TODO(roasbeef): modify valid to check precise script errors?