channeldb+lnwallet: make ChanSyncMsg method on OpenChannel

This commit is contained in:
Johan T. Halseth
2019-09-06 13:14:38 +02:00
parent 0122dda88a
commit eb1b84c0b4
5 changed files with 106 additions and 110 deletions

View File

@@ -2530,7 +2530,7 @@ func assertNoChanSyncNeeded(t *testing.T, aliceChannel *LightningChannel,
_, _, line, _ := runtime.Caller(1)
aliceChanSyncMsg, err := ChanSyncMsg(aliceChannel.channelState, false)
aliceChanSyncMsg, err := aliceChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("line #%v: unable to produce chan sync msg: %v",
line, err)
@@ -2545,7 +2545,7 @@ func assertNoChanSyncNeeded(t *testing.T, aliceChannel *LightningChannel,
"instead wants to send: %v", line, spew.Sdump(bobMsgsToSend))
}
bobChanSyncMsg, err := ChanSyncMsg(bobChannel.channelState, false)
bobChanSyncMsg, err := bobChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("line #%v: unable to produce chan sync msg: %v",
line, err)
@@ -2778,11 +2778,11 @@ func TestChanSyncOweCommitment(t *testing.T) {
// Bob doesn't get this message so upon reconnection, they need to
// synchronize. Alice should conclude that she owes Bob a commitment,
// while Bob should think he's properly synchronized.
aliceSyncMsg, err := ChanSyncMsg(aliceChannel.channelState, false)
aliceSyncMsg, err := aliceChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
bobSyncMsg, err := ChanSyncMsg(bobChannel.channelState, false)
bobSyncMsg, err := bobChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
@@ -3092,11 +3092,11 @@ func TestChanSyncOweRevocation(t *testing.T) {
// If we fetch the channel sync messages at this state, then Alice
// should report that she owes Bob a revocation message, while Bob
// thinks they're fully in sync.
aliceSyncMsg, err := ChanSyncMsg(aliceChannel.channelState, false)
aliceSyncMsg, err := aliceChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
bobSyncMsg, err := ChanSyncMsg(bobChannel.channelState, false)
bobSyncMsg, err := bobChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
@@ -3261,11 +3261,11 @@ func TestChanSyncOweRevocationAndCommit(t *testing.T) {
// If we now attempt to resync, then Alice should conclude that she
// doesn't need any further updates, while Bob concludes that he needs
// to re-send both his revocation and commit sig message.
aliceSyncMsg, err := ChanSyncMsg(aliceChannel.channelState, false)
aliceSyncMsg, err := aliceChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
bobSyncMsg, err := ChanSyncMsg(bobChannel.channelState, false)
bobSyncMsg, err := bobChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
@@ -3472,11 +3472,11 @@ func TestChanSyncOweRevocationAndCommitForceTransition(t *testing.T) {
// Now if we attempt to synchronize states at this point, Alice should
// detect that she owes nothing, while Bob should re-send both his
// RevokeAndAck as well as his commitment message.
aliceSyncMsg, err := ChanSyncMsg(aliceChannel.channelState, false)
aliceSyncMsg, err := aliceChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
bobSyncMsg, err := ChanSyncMsg(bobChannel.channelState, false)
bobSyncMsg, err := bobChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
@@ -3677,11 +3677,11 @@ func TestChanSyncFailure(t *testing.T) {
assertLocalDataLoss := func(aliceOld *LightningChannel) {
t.Helper()
aliceSyncMsg, err := ChanSyncMsg(aliceOld.channelState, false)
aliceSyncMsg, err := aliceOld.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
bobSyncMsg, err := ChanSyncMsg(bobChannel.channelState, false)
bobSyncMsg, err := bobChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
@@ -3755,7 +3755,7 @@ func TestChanSyncFailure(t *testing.T) {
// If we remove the recovery options from Bob's message, Alice cannot
// tell if she lost state, since Bob might be lying. She still should
// be able to detect that chains cannot be synced.
bobSyncMsg, err := ChanSyncMsg(bobChannel.channelState, false)
bobSyncMsg, err := bobChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
@@ -3769,7 +3769,7 @@ func TestChanSyncFailure(t *testing.T) {
// If Bob lies about the NextLocalCommitHeight, making it greater than
// what Alice expect, she cannot tell for sure whether she lost state,
// but should detect the desync.
bobSyncMsg, err = ChanSyncMsg(bobChannel.channelState, false)
bobSyncMsg, err = bobChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
@@ -3782,7 +3782,7 @@ func TestChanSyncFailure(t *testing.T) {
// If Bob's NextLocalCommitHeight is lower than what Alice expects, Bob
// probably lost state.
bobSyncMsg, err = ChanSyncMsg(bobChannel.channelState, false)
bobSyncMsg, err = bobChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
@@ -3795,7 +3795,7 @@ func TestChanSyncFailure(t *testing.T) {
// If Alice and Bob's states are in sync, but Bob is sending the wrong
// LocalUnrevokedCommitPoint, Alice should detect this.
bobSyncMsg, err = ChanSyncMsg(bobChannel.channelState, false)
bobSyncMsg, err = bobChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
@@ -3824,7 +3824,7 @@ func TestChanSyncFailure(t *testing.T) {
// when there's a pending remote commit.
halfAdvance()
bobSyncMsg, err = ChanSyncMsg(bobChannel.channelState, false)
bobSyncMsg, err = bobChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
@@ -3912,11 +3912,11 @@ func TestChannelRetransmissionFeeUpdate(t *testing.T) {
// Bob doesn't get this message so upon reconnection, they need to
// synchronize. Alice should conclude that she owes Bob a commitment,
// while Bob should think he's properly synchronized.
aliceSyncMsg, err := ChanSyncMsg(aliceChannel.channelState, false)
aliceSyncMsg, err := aliceChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
bobSyncMsg, err := ChanSyncMsg(bobChannel.channelState, false)
bobSyncMsg, err := bobChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to produce chan sync msg: %v", err)
}
@@ -4361,11 +4361,11 @@ func TestChanSyncInvalidLastSecret(t *testing.T) {
}
// Next, we'll produce the ChanSync messages for both parties.
aliceChanSync, err := ChanSyncMsg(aliceChannel.channelState, false)
aliceChanSync, err := aliceChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to generate chan sync msg: %v", err)
}
bobChanSync, err := ChanSyncMsg(bobChannel.channelState, false)
bobChanSync, err := bobChannel.channelState.ChanSyncMsg(false)
if err != nil {
t.Fatalf("unable to generate chan sync msg: %v", err)
}