lnwallet: update channel state machine tests to use distinct keys

In this commit, we update the channel state machine tests to use a new
key for each purpose. Before this commit, the same key would be used
the entire time. As a result, a few bugs slipped by that would’ve been
detected if we used fresh keys for each purpose. Additionally, this
reflect the real world case as we always use distinct keys for each
purpose to avoid key re-use.
This commit is contained in:
Olaoluwa Osuntokun
2018-01-16 18:38:49 -08:00
parent b5496c52a2
commit 1d7a1ac0ee
3 changed files with 105 additions and 39 deletions

View File

@@ -443,7 +443,7 @@ func TestHTLCSenderSpendValidation(t *testing.T) {
InputIndex: 0,
}
return senderHtlcSpendRedeem(bobSigner, signDesc,
return SenderHtlcSpendRedeem(bobSigner, signDesc,
sweepTx,
// Invalid preimage length
bytes.Repeat([]byte{1}, 45))
@@ -464,7 +464,7 @@ func TestHTLCSenderSpendValidation(t *testing.T) {
InputIndex: 0,
}
return senderHtlcSpendRedeem(bobSigner, signDesc,
return SenderHtlcSpendRedeem(bobSigner, signDesc,
sweepTx, paymentPreimage)
}),
true,
@@ -728,7 +728,7 @@ func TestHTLCReceiverSpendValidation(t *testing.T) {
}
return receiverHtlcSpendTimeout(aliceSigner, signDesc,
sweepTx, cltvTimeout-2)
sweepTx, int32(cltvTimeout-2))
}),
false,
},
@@ -746,7 +746,7 @@ func TestHTLCReceiverSpendValidation(t *testing.T) {
}
return receiverHtlcSpendTimeout(aliceSigner, signDesc,
sweepTx, cltvTimeout)
sweepTx, int32(cltvTimeout))
}),
true,
},