Merge pull request #3992 from joostjager/restore-update-fix

lnwallet: fix invalid value use in restoreUpdate
This commit is contained in:
Joost Jager 2020-02-11 18:26:51 +01:00 committed by GitHub
commit 2c08a8b9a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

@ -1064,7 +1064,7 @@ func (u *updateLog) appendUpdate(pd *PaymentDescriptor) {
// also added to index accordingly. This function differs from appendUpdate in
// that it won't increment the log index counter.
func (u *updateLog) restoreUpdate(pd *PaymentDescriptor) {
u.updateIndex[u.logIndex] = u.PushBack(pd)
u.updateIndex[pd.LogIndex] = u.PushBack(pd)
}
// appendHtlc appends a new HTLC offer to the tip of the update log. The entry

@ -3146,7 +3146,7 @@ func TestChanSyncOweCommitmentPendingRemote(t *testing.T) {
}
// Bob signs the commitment he owes.
_, bobHtlcSigs, _, err := bobChannel.SignNextCommitment()
bobCommit, bobHtlcSigs, _, err := bobChannel.SignNextCommitment()
if err != nil {
t.Fatalf("unable to sign commitment: %v", err)
}
@ -3155,6 +3155,20 @@ func TestChanSyncOweCommitmentPendingRemote(t *testing.T) {
if len(bobHtlcSigs) != 0 {
t.Fatalf("no htlcs expected, but got %v", len(bobHtlcSigs))
}
// Get Alice to revoke and trigger Bob to compact his logs.
err = aliceChannel.ReceiveNewCommitment(bobCommit, bobHtlcSigs)
if err != nil {
t.Fatal(err)
}
aliceRevoke, _, err := aliceChannel.RevokeCurrentCommitment()
if err != nil {
t.Fatal(err)
}
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevoke)
if err != nil {
t.Fatal(err)
}
}
// TestChanSyncOweRevocation tests that if Bob restarts (and then Alice) before