htlcswitch/test: add test cases that triggers empty commit sig
Co-authored-by: Johan T. Halseth <johanth@gmail.com>
This commit is contained in:
1 parent
517ad4e4f5
commit
64f4421d6c
2 files changed
+187
-5
No files matched your search
@@ -139,6 +139,21 @@ func (l *linkTestContext) receiveRevAndAckAliceToBob() {
|
||||
func (l *linkTestContext) receiveCommitSigAliceToBob(expHtlcs int) {
|
||||
l.t.Helper()
|
||||
|
||||
comSig := l.receiveCommitSigAlice(expHtlcs)
|
||||
|
||||
err := l.bobChannel.ReceiveNewCommitment(
|
||||
comSig.CommitSig, comSig.HtlcSigs,
|
||||
)
|
||||
if err != nil {
|
||||
l.t.Fatalf("bob failed receiving commitment: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// receiveCommitSigAlice waits for Alice to send a CommitSig, signing expHtlcs
|
||||
// numbers of HTLCs.
|
||||
func (l *linkTestContext) receiveCommitSigAlice(expHtlcs int) *lnwire.CommitSig {
|
||||
l.t.Helper()
|
||||
|
||||
var msg lnwire.Message
|
||||
select {
|
||||
case msg = <-l.aliceMsgs:
|
||||
@@ -155,11 +170,8 @@ func (l *linkTestContext) receiveCommitSigAliceToBob(expHtlcs int) {
|
||||
l.t.Fatalf("expected %d htlc sigs, got %d", expHtlcs,
|
||||
len(comSig.HtlcSigs))
|
||||
}
|
||||
err := l.bobChannel.ReceiveNewCommitment(comSig.CommitSig,
|
||||
comSig.HtlcSigs)
|
||||
if err != nil {
|
||||
l.t.Fatalf("bob failed receiving commitment: %v", err)
|
||||
}
|
||||
|
||||
return comSig
|
||||
}
|
||||
|
||||
// sendRevAndAckBobToAlice make Bob revoke his current commitment, then hand
|
||||
@@ -242,3 +254,15 @@ func (l *linkTestContext) receiveFailAliceToBob() {
|
||||
l.t.Fatalf("unable to apply received fail htlc: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// assertNoMsgFromAlice asserts that Alice hasn't sent a message. Before
|
||||
// calling, make sure that Alice has had the opportunity to send the message.
|
||||
func (l *linkTestContext) assertNoMsgFromAlice(timeout time.Duration) {
|
||||
l.t.Helper()
|
||||
|
||||
select {
|
||||
case msg := <-l.aliceMsgs:
|
||||
l.t.Fatalf("unexpected message from Alice: %v", msg)
|
||||
case <-time.After(timeout):
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user