lnwallet: include htlcs to settle in returned set of htlc's to forward
This commit fixes a slight bug in the channel state machine’s code executed when processing a revocation messages. With this commit after processing a revocation, log entries which we should forward to the downstream or upstream peer for settling/adding HTLC’s are now properly returned. The testa have also been updated to ensure to correct htlc’s are returned “for forwarding”.
This commit is contained in:
2 files changed
+41
-21
No files matched your search
@@ -2,7 +2,6 @@ package lnwallet
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
@@ -355,13 +354,17 @@ func TestSimpleAddSettleWorkflow(t *testing.T) {
|
||||
}
|
||||
if htlcs, err := bobChannel.ReceiveRevocation(aliceRevocation2); err != nil {
|
||||
t.Fatalf("bob unable to process alice's revocation: %v", err)
|
||||
} else {
|
||||
fmt.Println("bob forward htlcs: %v", htlcs)
|
||||
} else if len(htlcs) != 0 {
|
||||
t.Fatalf("bob shouldn't forward any HTLC's after outgoing settle, "+
|
||||
"instead can forward: %v", spew.Sdump(htlcs))
|
||||
}
|
||||
if htlcs, err := aliceChannel.ReceiveRevocation(bobRevocation2); err != nil {
|
||||
t.Fatalf("alice unable to process bob's revocation: %v", err)
|
||||
} else {
|
||||
fmt.Println("alice forward htlcs: %v", spew.Sdump(htlcs))
|
||||
} else if len(htlcs) != 1 {
|
||||
// Alice should now be able to forward the settlement HTLC to
|
||||
// any down stream peers.
|
||||
t.Fatalf("alice should be able to forward a single HTLC, "+
|
||||
"instead can forward %v: %v", len(htlcs), spew.Sdump(htlcs))
|
||||
}
|
||||
|
||||
// At this point, bob should have 6BTC settled, with Alice still having
|
||||
@@ -416,3 +419,7 @@ func TestSimpleAddSettleWorkflow(t *testing.T) {
|
||||
"instead", bobLogLen)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCooperativeChannelClosure(t *testing.T) {
|
||||
// * add validation of their sig
|
||||
}
|
||||
Reference in new issue
Block a user