From 6afebfba5d18cb39e30f90e6fa7b6d01c92e2196 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 13 Nov 2017 22:51:16 -0800 Subject: [PATCH] htlcswitch: update link to match latest ChanSyncMsg API change --- htlcswitch/link.go | 9 ++++++++- htlcswitch/link_test.go | 8 ++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 7400545b..9f5522e5 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -317,7 +317,12 @@ func (l *channelLink) htlcManager() { // First, we'll generate our ChanSync message to send to the // other side. Based on this message, the remote party will // decide if they need to retransmit any data or not. - localChanSyncMsg := l.channel.ChanSyncMsg() + localChanSyncMsg, err := l.channel.ChanSyncMsg() + if err != nil { + l.fail("unable to generate chan sync message for "+ + "ChannelPoint(%v)", l.channel.ChannelPoint()) + return + } if err := l.cfg.Peer.SendMessage(localChanSyncMsg); err != nil { l.fail("Unable to send chan sync message for "+ "ChannelPoint(%v)", l.channel.ChannelPoint()) @@ -706,6 +711,8 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) { // need to re-transmit any messages to the remote party. msgsToReSend, err := l.channel.ProcessChanSyncMsg(msg) if err != nil { + // TODO(roasbeef): check conrete type of error, act + // accordingly l.fail("unable to handle upstream reestablish "+ "message: %v", err) return diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go index a679319c..34c56917 100644 --- a/htlcswitch/link_test.go +++ b/htlcswitch/link_test.go @@ -358,16 +358,20 @@ func TestChannelLinkBidirectionalOneHopPayments(t *testing.T) { } } + // TODO(roasbeef): should instead consume async notifications from both + // links time.Sleep(time.Second * 2) // At the end Bob and Alice balances should be the same as previous, // because they sent the equal amount of money to each other. if aliceBandwidthBefore != n.aliceChannelLink.Bandwidth() { - t.Fatal("alice bandwidth shouldn't have changed") + t.Fatalf("alice bandwidth shouldn't have changed: expected %v, got %x", + aliceBandwidthBefore, n.aliceChannelLink.Bandwidth()) } if bobBandwidthBefore != n.firstBobChannelLink.Bandwidth() { - t.Fatal("bob bandwidth shouldn't have changed") + t.Fatalf("bob bandwidth shouldn't have changed: expected %v, got %v", + bobBandwidthBefore, n.firstBobChannelLink.Bandwidth()) } t.Logf("Max waiting: %v", maxDelay)