htlcswitch+lnwallet: remove PaymentDescriptor from ReceiveRevocation returns
This is part of a systematic removal of PaymentDescriptor from the public API of the lnwallet package. This marks the last change needed before we make the PaymentDescriptor structure private.
This commit is contained in:
7 files changed
+120
-114
No files matched your search
+1
-2
@@ -2321,8 +2321,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
|
|||||||
|
|
||||||
// We now process the message and advance our remote commit
|
// We now process the message and advance our remote commit
|
||||||
// chain.
|
// chain.
|
||||||
fwdPkg, _, _, remoteHTLCs, err := l.channel.
|
fwdPkg, remoteHTLCs, err := l.channel.ReceiveRevocation(msg)
|
||||||
ReceiveRevocation(msg)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO(halseth): force close?
|
// TODO(halseth): force close?
|
||||||
l.failf(
|
l.failf(
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ func (l *linkTestContext) receiveRevAndAckAliceToBob() {
|
|||||||
l.t.Fatalf("expected RevokeAndAck, got %T", msg)
|
l.t.Fatalf("expected RevokeAndAck, got %T", msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _, _, _, err := l.bobChannel.ReceiveRevocation(rev)
|
_, _, err := l.bobChannel.ReceiveRevocation(rev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.t.Fatalf("bob failed receiving revocation: %v", err)
|
l.t.Fatalf("bob failed receiving revocation: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2335,7 +2335,7 @@ func handleStateUpdate(link *channelLink,
|
|||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("expected RevokeAndAck got %T", msg)
|
return fmt.Errorf("expected RevokeAndAck got %T", msg)
|
||||||
}
|
}
|
||||||
_, _, _, _, err = remoteChannel.ReceiveRevocation(revoke)
|
_, _, err = remoteChannel.ReceiveRevocation(revoke)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to receive "+
|
return fmt.Errorf("unable to receive "+
|
||||||
"revocation: %v", err)
|
"revocation: %v", err)
|
||||||
@@ -2389,7 +2389,7 @@ func updateState(batchTick chan time.Time, link *channelLink,
|
|||||||
return fmt.Errorf("expected RevokeAndAck got %T",
|
return fmt.Errorf("expected RevokeAndAck got %T",
|
||||||
msg)
|
msg)
|
||||||
}
|
}
|
||||||
_, _, _, _, err = remoteChannel.ReceiveRevocation(revoke)
|
_, _, err = remoteChannel.ReceiveRevocation(revoke)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to receive "+
|
return fmt.Errorf("unable to receive "+
|
||||||
"revocation: %v", err)
|
"revocation: %v", err)
|
||||||
@@ -3643,7 +3643,7 @@ func TestChannelLinkTrimCircuitsRemoteCommit(t *testing.T) {
|
|||||||
rev, _, _, err := harness.bobChannel.RevokeCurrentCommitment()
|
rev, _, _, err := harness.bobChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err, "unable to revoke current commitment")
|
require.NoError(t, err, "unable to revoke current commitment")
|
||||||
|
|
||||||
_, _, _, _, err = alice.channel.ReceiveRevocation(rev)
|
_, _, err = alice.channel.ReceiveRevocation(rev)
|
||||||
require.NoError(t, err, "unable to receive revocation")
|
require.NoError(t, err, "unable to receive revocation")
|
||||||
|
|
||||||
// Restart Alice's link, which simulates a disconnection with the remote
|
// Restart Alice's link, which simulates a disconnection with the remote
|
||||||
|
|||||||
+28
-39
@@ -5375,15 +5375,10 @@ func (lc *LightningChannel) RevokeCurrentCommitment() (*lnwire.RevokeAndAck,
|
|||||||
// The returned values correspond to:
|
// The returned values correspond to:
|
||||||
// 1. The forwarding package corresponding to the remote commitment height
|
// 1. The forwarding package corresponding to the remote commitment height
|
||||||
// that was revoked.
|
// that was revoked.
|
||||||
// 2. The PaymentDescriptor of any Add HTLCs that were locked in by this
|
// 2. The set of HTLCs present on the current valid commitment transaction
|
||||||
// revocation.
|
|
||||||
// 3. The PaymentDescriptor of any Settle/Fail HTLCs that were locked in by
|
|
||||||
// this revocation.
|
|
||||||
// 4. The set of HTLCs present on the current valid commitment transaction
|
|
||||||
// for the remote party.
|
// for the remote party.
|
||||||
func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
||||||
*channeldb.FwdPkg, []*PaymentDescriptor, []*PaymentDescriptor,
|
*channeldb.FwdPkg, []channeldb.HTLC, error) {
|
||||||
[]channeldb.HTLC, error) {
|
|
||||||
|
|
||||||
lc.Lock()
|
lc.Lock()
|
||||||
defer lc.Unlock()
|
defer lc.Unlock()
|
||||||
@@ -5392,10 +5387,10 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
store := lc.channelState.RevocationStore
|
store := lc.channelState.RevocationStore
|
||||||
revocation, err := chainhash.NewHash(revMsg.Revocation[:])
|
revocation, err := chainhash.NewHash(revMsg.Revocation[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
if err := store.AddNextEntry(revocation); err != nil {
|
if err := store.AddNextEntry(revocation); err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that if we use the commitment point computed based off of the
|
// Verify that if we use the commitment point computed based off of the
|
||||||
@@ -5404,7 +5399,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
currentCommitPoint := lc.channelState.RemoteCurrentRevocation
|
currentCommitPoint := lc.channelState.RemoteCurrentRevocation
|
||||||
derivedCommitPoint := input.ComputeCommitmentPoint(revMsg.Revocation[:])
|
derivedCommitPoint := input.ComputeCommitmentPoint(revMsg.Revocation[:])
|
||||||
if !derivedCommitPoint.IsEqual(currentCommitPoint) {
|
if !derivedCommitPoint.IsEqual(currentCommitPoint) {
|
||||||
return nil, nil, nil, nil, fmt.Errorf("revocation key mismatch")
|
return nil, nil, fmt.Errorf("revocation key mismatch")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that we've verified that the prior commitment has been properly
|
// Now that we've verified that the prior commitment has been properly
|
||||||
@@ -5434,10 +5429,8 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
// updates to disk and optimistically buffer the forwarding package in
|
// updates to disk and optimistically buffer the forwarding package in
|
||||||
// memory.
|
// memory.
|
||||||
var (
|
var (
|
||||||
addsToForward []*PaymentDescriptor
|
addUpdatesToForward []channeldb.LogUpdate
|
||||||
addUpdates []channeldb.LogUpdate
|
settleFailUpdatesToForward []channeldb.LogUpdate
|
||||||
settleFailsToForward []*PaymentDescriptor
|
|
||||||
settleFailUpdates []channeldb.LogUpdate
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var addIndex, settleFailIndex uint16
|
var addIndex, settleFailIndex uint16
|
||||||
@@ -5489,7 +5482,13 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
addIndex++
|
addIndex++
|
||||||
|
|
||||||
pd.isForwarded = true
|
pd.isForwarded = true
|
||||||
addsToForward = append(addsToForward, pd)
|
|
||||||
|
// At this point we put the update into our list of
|
||||||
|
// updates that we will eventually put into the
|
||||||
|
// FwdPkg at this height.
|
||||||
|
addUpdatesToForward = append(
|
||||||
|
addUpdatesToForward, pd.ToLogUpdate(),
|
||||||
|
)
|
||||||
|
|
||||||
case pd.EntryType != Add && committedRmv && shouldFwdRmv:
|
case pd.EntryType != Add && committedRmv && shouldFwdRmv:
|
||||||
// Construct a reference specifying the location that
|
// Construct a reference specifying the location that
|
||||||
@@ -5503,28 +5502,17 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
settleFailIndex++
|
settleFailIndex++
|
||||||
|
|
||||||
pd.isForwarded = true
|
pd.isForwarded = true
|
||||||
settleFailsToForward = append(settleFailsToForward, pd)
|
|
||||||
|
// At this point we put the update into our list of
|
||||||
|
// updates that we will eventually put into the
|
||||||
|
// FwdPkg at this height.
|
||||||
|
settleFailUpdatesToForward = append(
|
||||||
|
settleFailUpdatesToForward, pd.ToLogUpdate(),
|
||||||
|
)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we've reached this point, this HTLC will be added to the
|
|
||||||
// forwarding package at the height of the remote commitment.
|
|
||||||
// We'll map the type of the PaymentDescriptor to one of the
|
|
||||||
// four messages that it corresponds to and separate the
|
|
||||||
// updates into Adds and Settle/Fail/MalformedFail such that
|
|
||||||
// they can be written in the forwarding package. Adds are
|
|
||||||
// aggregated separately from the other types of HTLCs.
|
|
||||||
switch pd.EntryType {
|
|
||||||
case Add:
|
|
||||||
addUpdates = append(addUpdates, pd.ToLogUpdate())
|
|
||||||
|
|
||||||
case Settle, Fail, MalformedFail:
|
|
||||||
settleFailUpdates = append(
|
|
||||||
settleFailUpdates, pd.ToLogUpdate(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use the remote commitment chain's tip as it will soon become the tail
|
// We use the remote commitment chain's tip as it will soon become the tail
|
||||||
@@ -5540,7 +5528,8 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
// type, construct a forwarding package using the height that the remote
|
// type, construct a forwarding package using the height that the remote
|
||||||
// commitment chain will be extended after persisting the revocation.
|
// commitment chain will be extended after persisting the revocation.
|
||||||
fwdPkg := channeldb.NewFwdPkg(
|
fwdPkg := channeldb.NewFwdPkg(
|
||||||
source, remoteChainTail, addUpdates, settleFailUpdates,
|
source, remoteChainTail, addUpdatesToForward,
|
||||||
|
settleFailUpdatesToForward,
|
||||||
)
|
)
|
||||||
|
|
||||||
// We will soon be saving the current remote commitment to revocation
|
// We will soon be saving the current remote commitment to revocation
|
||||||
@@ -5553,7 +5542,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
revocation, lc.channelState, lc.leafStore,
|
revocation, lc.channelState, lc.leafStore,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that we have a new verification nonce from them, we can refresh
|
// Now that we have a new verification nonce from them, we can refresh
|
||||||
@@ -5561,7 +5550,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
if lc.channelState.ChanType.IsTaproot() {
|
if lc.channelState.ChanType.IsTaproot() {
|
||||||
localNonce, err := revMsg.LocalNonce.UnwrapOrErrV(errNoNonce)
|
localNonce, err := revMsg.LocalNonce.UnwrapOrErrV(errNoNonce)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
session, err := lc.musigSessions.RemoteSession.Refresh(
|
session, err := lc.musigSessions.RemoteSession.Refresh(
|
||||||
@@ -5570,7 +5559,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
lc.musigSessions.RemoteSession = session
|
lc.musigSessions.RemoteSession = session
|
||||||
@@ -5586,7 +5575,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
ourOutputIndex, theirOutputIndex,
|
ourOutputIndex, theirOutputIndex,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since they revoked the current lowest height in their commitment
|
// Since they revoked the current lowest height in their commitment
|
||||||
@@ -5603,7 +5592,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
|
|
||||||
remoteHTLCs := lc.channelState.RemoteCommitment.Htlcs
|
remoteHTLCs := lc.channelState.RemoteCommitment.Htlcs
|
||||||
|
|
||||||
return fwdPkg, addsToForward, settleFailsToForward, remoteHTLCs, nil
|
return fwdPkg, remoteHTLCs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadFwdPkgs loads any pending log updates from disk and returns the payment
|
// LoadFwdPkgs loads any pending log updates from disk and returns the payment
|
||||||
|
|||||||
+84
-66
@@ -132,7 +132,7 @@ func testAddSettleWorkflow(t *testing.T, tweakless bool,
|
|||||||
// Alice then processes this revocation, sending her own revocation for
|
// Alice then processes this revocation, sending her own revocation for
|
||||||
// her prior commitment transaction. Alice shouldn't have any HTLCs to
|
// her prior commitment transaction. Alice shouldn't have any HTLCs to
|
||||||
// forward since she's sending an outgoing HTLC.
|
// forward since she's sending an outgoing HTLC.
|
||||||
fwdPkg, _, _, _, err := aliceChannel.ReceiveRevocation(bobRevocation)
|
fwdPkg, _, err := aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err, "alice unable to process bob's revocation")
|
require.NoError(t, err, "alice unable to process bob's revocation")
|
||||||
if len(fwdPkg.Adds) != 0 {
|
if len(fwdPkg.Adds) != 0 {
|
||||||
t.Fatalf("alice forwards %v add htlcs, should forward none",
|
t.Fatalf("alice forwards %v add htlcs, should forward none",
|
||||||
@@ -157,7 +157,7 @@ func testAddSettleWorkflow(t *testing.T, tweakless bool,
|
|||||||
// is fully locked in within both commitment transactions. Bob should
|
// is fully locked in within both commitment transactions. Bob should
|
||||||
// also be able to forward an HTLC now that the HTLC has been locked
|
// also be able to forward an HTLC now that the HTLC has been locked
|
||||||
// into both commitment transactions.
|
// into both commitment transactions.
|
||||||
fwdPkg, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
fwdPkg, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err, "bob unable to process alice's revocation")
|
require.NoError(t, err, "bob unable to process alice's revocation")
|
||||||
if len(fwdPkg.Adds) != 1 {
|
if len(fwdPkg.Adds) != 1 {
|
||||||
t.Fatalf("bob forwards %v add htlcs, should only forward one",
|
t.Fatalf("bob forwards %v add htlcs, should only forward one",
|
||||||
@@ -249,7 +249,7 @@ func testAddSettleWorkflow(t *testing.T, tweakless bool,
|
|||||||
aliceNewCommit, err = aliceChannel.SignNextCommitment()
|
aliceNewCommit, err = aliceChannel.SignNextCommitment()
|
||||||
require.NoError(t, err, "alice unable to sign new commitment")
|
require.NoError(t, err, "alice unable to sign new commitment")
|
||||||
|
|
||||||
fwdPkg, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation2)
|
fwdPkg, _, err = bobChannel.ReceiveRevocation(aliceRevocation2)
|
||||||
require.NoError(t, err, "bob unable to process alice's revocation")
|
require.NoError(t, err, "bob unable to process alice's revocation")
|
||||||
if len(fwdPkg.Adds) != 0 {
|
if len(fwdPkg.Adds) != 0 {
|
||||||
t.Fatalf("bob forwards %v add htlcs, should forward none",
|
t.Fatalf("bob forwards %v add htlcs, should forward none",
|
||||||
@@ -286,7 +286,7 @@ func testAddSettleWorkflow(t *testing.T, tweakless bool,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fwdPkg, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation2)
|
fwdPkg, _, err = aliceChannel.ReceiveRevocation(bobRevocation2)
|
||||||
require.NoError(t, err, "alice unable to process bob's revocation")
|
require.NoError(t, err, "alice unable to process bob's revocation")
|
||||||
if len(fwdPkg.Adds) != 0 {
|
if len(fwdPkg.Adds) != 0 {
|
||||||
// Alice should now be able to forward the settlement HTLC to
|
// Alice should now be able to forward the settlement HTLC to
|
||||||
@@ -468,7 +468,7 @@ func TestChannelZeroAddLocalHeight(t *testing.T) {
|
|||||||
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// We now restore Alice's channel as this was the point at which
|
// We now restore Alice's channel as this was the point at which
|
||||||
@@ -644,7 +644,7 @@ func testCommitHTLCSigTieBreak(t *testing.T, restart bool) {
|
|||||||
|
|
||||||
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err, "unable to revoke bob's commitment")
|
require.NoError(t, err, "unable to revoke bob's commitment")
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err, "unable to receive bob's revocation")
|
require.NoError(t, err, "unable to receive bob's revocation")
|
||||||
|
|
||||||
// Now have Bob initiate the second half of the commitment dance. Here
|
// Now have Bob initiate the second half of the commitment dance. Here
|
||||||
@@ -2556,7 +2556,7 @@ func TestUpdateFeeSenderCommits(t *testing.T) {
|
|||||||
// Alice receives the revocation of the old one, and can now assume
|
// Alice receives the revocation of the old one, and can now assume
|
||||||
// that Bob's received everything up to the signature she sent,
|
// that Bob's received everything up to the signature she sent,
|
||||||
// including the HTLC and fee update.
|
// including the HTLC and fee update.
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err, "alice unable to process bob's revocation")
|
require.NoError(t, err, "alice unable to process bob's revocation")
|
||||||
|
|
||||||
// Alice receives new signature from Bob, and assumes this covers the
|
// Alice receives new signature from Bob, and assumes this covers the
|
||||||
@@ -2584,7 +2584,7 @@ func TestUpdateFeeSenderCommits(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bob receives revocation from Alice.
|
// Bob receives revocation from Alice.
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err, "bob unable to process alice's revocation")
|
require.NoError(t, err, "bob unable to process alice's revocation")
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2644,7 +2644,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
|
|||||||
require.NoError(t, err, "unable to generate bob revocation")
|
require.NoError(t, err, "unable to generate bob revocation")
|
||||||
|
|
||||||
// Bob receives the revocation of the old commitment
|
// Bob receives the revocation of the old commitment
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err, "alice unable to process bob's revocation")
|
require.NoError(t, err, "alice unable to process bob's revocation")
|
||||||
|
|
||||||
// Alice will sign next commitment. Since she sent the revocation, she
|
// Alice will sign next commitment. Since she sent the revocation, she
|
||||||
@@ -2685,7 +2685,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
|
|||||||
|
|
||||||
// Alice receives revocation from Bob, and can now be sure that Bob
|
// Alice receives revocation from Bob, and can now be sure that Bob
|
||||||
// received the two updates, and they are considered locked in.
|
// received the two updates, and they are considered locked in.
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err, "bob unable to process alice's revocation")
|
require.NoError(t, err, "bob unable to process alice's revocation")
|
||||||
|
|
||||||
// Alice will receive the signature from Bob, which will cover what was
|
// Alice will receive the signature from Bob, which will cover what was
|
||||||
@@ -2713,7 +2713,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bob receives revocation from Alice.
|
// Bob receives revocation from Alice.
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err, "bob unable to process alice's revocation")
|
require.NoError(t, err, "bob unable to process alice's revocation")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2822,7 +2822,7 @@ func TestUpdateFeeMultipleUpdates(t *testing.T) {
|
|||||||
// Alice receives the revocation of the old one, and can now assume that
|
// Alice receives the revocation of the old one, and can now assume that
|
||||||
// Bob's received everything up to the signature she sent, including the
|
// Bob's received everything up to the signature she sent, including the
|
||||||
// HTLC and fee update.
|
// HTLC and fee update.
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err, "alice unable to process bob's revocation")
|
require.NoError(t, err, "alice unable to process bob's revocation")
|
||||||
|
|
||||||
// Alice receives new signature from Bob, and assumes this covers the
|
// Alice receives new signature from Bob, and assumes this covers the
|
||||||
@@ -2852,7 +2852,7 @@ func TestUpdateFeeMultipleUpdates(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bob receives revocation from Alice.
|
// Bob receives revocation from Alice.
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err, "bob unable to process alice's revocation")
|
require.NoError(t, err, "bob unable to process alice's revocation")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3267,13 +3267,13 @@ func testChanSyncOweCommitment(t *testing.T, chanType channeldb.ChannelType) {
|
|||||||
require.NoError(t, err, "unable to revoke bob commitment")
|
require.NoError(t, err, "unable to revoke bob commitment")
|
||||||
bobNewCommit, err := bobChannel.SignNextCommitment()
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
||||||
require.NoError(t, err, "bob unable to sign commitment")
|
require.NoError(t, err, "bob unable to sign commitment")
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err, "alice unable to recv revocation")
|
require.NoError(t, err, "alice unable to recv revocation")
|
||||||
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
||||||
require.NoError(t, err, "alice unable to rev bob's commitment")
|
require.NoError(t, err, "alice unable to rev bob's commitment")
|
||||||
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err, "alice unable to revoke commitment")
|
require.NoError(t, err, "alice unable to revoke commitment")
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err, "bob unable to recv revocation")
|
require.NoError(t, err, "bob unable to recv revocation")
|
||||||
|
|
||||||
// At this point, we'll now assert that their log states are what we
|
// At this point, we'll now assert that their log states are what we
|
||||||
@@ -3466,7 +3466,7 @@ func testChanSyncOweCommitmentPendingRemote(t *testing.T,
|
|||||||
t.Fatalf("unable to revoke commitment: %v", err)
|
t.Fatalf("unable to revoke commitment: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevoke)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevoke)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to revoke commitment: %v", err)
|
t.Fatalf("unable to revoke commitment: %v", err)
|
||||||
}
|
}
|
||||||
@@ -3502,7 +3502,7 @@ func testChanSyncOweCommitmentPendingRemote(t *testing.T,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevoke)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevoke)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -3603,7 +3603,7 @@ func testChanSyncOweRevocation(t *testing.T, chanType channeldb.ChannelType) {
|
|||||||
bobNewCommit, err := bobChannel.SignNextCommitment()
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
||||||
require.NoError(t, err, "bob unable to sign commitment")
|
require.NoError(t, err, "bob unable to sign commitment")
|
||||||
|
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err, "alice unable to recv revocation")
|
require.NoError(t, err, "alice unable to recv revocation")
|
||||||
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
||||||
require.NoError(t, err, "alice unable to rev bob's commitment")
|
require.NoError(t, err, "alice unable to rev bob's commitment")
|
||||||
@@ -3698,7 +3698,7 @@ func testChanSyncOweRevocation(t *testing.T, chanType channeldb.ChannelType) {
|
|||||||
|
|
||||||
// We'll continue by then allowing bob to process Alice's revocation
|
// We'll continue by then allowing bob to process Alice's revocation
|
||||||
// message.
|
// message.
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err, "bob unable to recv revocation")
|
require.NoError(t, err, "bob unable to recv revocation")
|
||||||
|
|
||||||
// Finally, Alice will add an HTLC over her own such that we assert the
|
// Finally, Alice will add an HTLC over her own such that we assert the
|
||||||
@@ -3916,13 +3916,13 @@ func testChanSyncOweRevocationAndCommit(t *testing.T,
|
|||||||
|
|
||||||
// We'll now finish the state transition by having Alice process both
|
// We'll now finish the state transition by having Alice process both
|
||||||
// messages, and send her final revocation.
|
// messages, and send her final revocation.
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err, "alice unable to recv revocation")
|
require.NoError(t, err, "alice unable to recv revocation")
|
||||||
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
||||||
require.NoError(t, err, "alice unable to recv bob's commitment")
|
require.NoError(t, err, "alice unable to recv bob's commitment")
|
||||||
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err, "alice unable to revoke commitment")
|
require.NoError(t, err, "alice unable to revoke commitment")
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err, "bob unable to recv revocation")
|
require.NoError(t, err, "bob unable to recv revocation")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4016,7 +4016,7 @@ func testChanSyncOweRevocationAndCommitForceTransition(t *testing.T,
|
|||||||
// local commit chain getting height > remote commit chain.
|
// local commit chain getting height > remote commit chain.
|
||||||
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err, "alice unable to revoke commitment")
|
require.NoError(t, err, "alice unable to revoke commitment")
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err, "bob unable to recv revocation")
|
require.NoError(t, err, "bob unable to recv revocation")
|
||||||
|
|
||||||
// Next, Alice will settle that incoming HTLC, then we'll start the
|
// Next, Alice will settle that incoming HTLC, then we'll start the
|
||||||
@@ -4148,7 +4148,7 @@ func testChanSyncOweRevocationAndCommitForceTransition(t *testing.T,
|
|||||||
// Now, we'll continue the exchange, sending Bob's revocation and
|
// Now, we'll continue the exchange, sending Bob's revocation and
|
||||||
// signature message to Alice, ending with Alice sending her revocation
|
// signature message to Alice, ending with Alice sending her revocation
|
||||||
// message to Bob.
|
// message to Bob.
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err, "alice unable to recv revocation")
|
require.NoError(t, err, "alice unable to recv revocation")
|
||||||
err = aliceChannel.ReceiveNewCommitment(&CommitSigs{
|
err = aliceChannel.ReceiveNewCommitment(&CommitSigs{
|
||||||
CommitSig: bobSigMsg.CommitSig,
|
CommitSig: bobSigMsg.CommitSig,
|
||||||
@@ -4158,7 +4158,7 @@ func testChanSyncOweRevocationAndCommitForceTransition(t *testing.T,
|
|||||||
require.NoError(t, err, "alice unable to rev bob's commitment")
|
require.NoError(t, err, "alice unable to rev bob's commitment")
|
||||||
aliceRevocation, _, _, err = aliceChannel.RevokeCurrentCommitment()
|
aliceRevocation, _, _, err = aliceChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err, "alice unable to revoke commitment")
|
require.NoError(t, err, "alice unable to revoke commitment")
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err, "bob unable to recv revocation")
|
require.NoError(t, err, "bob unable to recv revocation")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4584,13 +4584,13 @@ func TestChannelRetransmissionFeeUpdate(t *testing.T) {
|
|||||||
require.NoError(t, err, "unable to revoke bob commitment")
|
require.NoError(t, err, "unable to revoke bob commitment")
|
||||||
bobNewCommit, err := bobChannel.SignNextCommitment()
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
||||||
require.NoError(t, err, "bob unable to sign commitment")
|
require.NoError(t, err, "bob unable to sign commitment")
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err, "alice unable to recv revocation")
|
require.NoError(t, err, "alice unable to recv revocation")
|
||||||
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
||||||
require.NoError(t, err, "alice unable to rev bob's commitment")
|
require.NoError(t, err, "alice unable to rev bob's commitment")
|
||||||
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err, "alice unable to revoke commitment")
|
require.NoError(t, err, "alice unable to revoke commitment")
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err, "bob unable to recv revocation")
|
require.NoError(t, err, "bob unable to recv revocation")
|
||||||
|
|
||||||
// Both parties should now have the latest fee rate locked-in.
|
// Both parties should now have the latest fee rate locked-in.
|
||||||
@@ -4782,13 +4782,13 @@ func TestFeeUpdateOldDiskFormat(t *testing.T) {
|
|||||||
require.NoError(t, err, "unable to revoke bob commitment")
|
require.NoError(t, err, "unable to revoke bob commitment")
|
||||||
bobNewCommitSigs, err := bobChannel.SignNextCommitment()
|
bobNewCommitSigs, err := bobChannel.SignNextCommitment()
|
||||||
require.NoError(t, err, "bob unable to sign commitment")
|
require.NoError(t, err, "bob unable to sign commitment")
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err, "alice unable to recv revocation")
|
require.NoError(t, err, "alice unable to recv revocation")
|
||||||
err = aliceChannel.ReceiveNewCommitment(bobNewCommitSigs.CommitSigs)
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommitSigs.CommitSigs)
|
||||||
require.NoError(t, err, "alice unable to rev bob's commitment")
|
require.NoError(t, err, "alice unable to rev bob's commitment")
|
||||||
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err, "alice unable to revoke commitment")
|
require.NoError(t, err, "alice unable to revoke commitment")
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err, "bob unable to recv revocation")
|
require.NoError(t, err, "bob unable to recv revocation")
|
||||||
|
|
||||||
// Both parties should now have the latest fee rate locked-in.
|
// Both parties should now have the latest fee rate locked-in.
|
||||||
@@ -5497,7 +5497,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Alice should detect that she doesn't need to forward any HTLC's.
|
// Alice should detect that she doesn't need to forward any HTLC's.
|
||||||
fwdPkg, _, _, _, err := aliceChannel.ReceiveRevocation(bobRevocation)
|
fwdPkg, _, err := aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -5528,7 +5528,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
|
|||||||
|
|
||||||
// Bob should now detect that he now has 2 incoming HTLC's that he can
|
// Bob should now detect that he now has 2 incoming HTLC's that he can
|
||||||
// forward along.
|
// forward along.
|
||||||
fwdPkg, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
fwdPkg, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -5573,7 +5573,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
|
|||||||
// At this point, Bob receives the revocation from Alice, which is now
|
// At this point, Bob receives the revocation from Alice, which is now
|
||||||
// his signal to examine all the HTLC's that have been locked in to
|
// his signal to examine all the HTLC's that have been locked in to
|
||||||
// process.
|
// process.
|
||||||
fwdPkg, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
fwdPkg, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -5622,22 +5622,31 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
|
|||||||
|
|
||||||
// Alice should detect that she doesn't need to forward any Adds's, but
|
// Alice should detect that she doesn't need to forward any Adds's, but
|
||||||
// that the Fail has been locked in an can be forwarded.
|
// that the Fail has been locked in an can be forwarded.
|
||||||
_, adds, settleFails, _, err := aliceChannel.ReceiveRevocation(bobRevocation)
|
fwdPkg, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
adds := fwdPkg.Adds
|
||||||
|
settleFails := fwdPkg.SettleFails
|
||||||
if len(adds) != 0 {
|
if len(adds) != 0 {
|
||||||
t.Fatalf("alice shouldn't forward any HTLC's, instead wants to "+
|
t.Fatalf("alice shouldn't forward any HTLC's, instead wants to "+
|
||||||
"forward %v htlcs", len(adds))
|
"forward %v htlcs", len(fwdPkg.Adds))
|
||||||
}
|
}
|
||||||
if len(settleFails) != 1 {
|
if len(settleFails) != 1 {
|
||||||
t.Fatalf("alice should only forward %d HTLC's, instead wants to "+
|
t.Fatalf("alice should only forward %d HTLC's, instead wants to "+
|
||||||
"forward %v htlcs", 1, len(settleFails))
|
"forward %v htlcs", 1, len(fwdPkg.SettleFails))
|
||||||
}
|
}
|
||||||
if settleFails[0].ParentIndex != htlc.ID {
|
|
||||||
|
fail, ok := settleFails[0].UpdateMsg.(*lnwire.UpdateFailHTLC)
|
||||||
|
if !ok {
|
||||||
|
t.Fatalf("expected UpdateFailHTLC, got %T",
|
||||||
|
settleFails[0].UpdateMsg)
|
||||||
|
}
|
||||||
|
if fail.ID != htlc.ID {
|
||||||
t.Fatalf("alice should forward fail for htlcid=%d, instead "+
|
t.Fatalf("alice should forward fail for htlcid=%d, instead "+
|
||||||
"forwarding id=%d", htlc.ID,
|
"forwarding id=%d", htlc.ID,
|
||||||
settleFails[0].ParentIndex)
|
fail.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We'll now restart both Alice and Bob. This emulates a reconnection
|
// We'll now restart both Alice and Bob. This emulates a reconnection
|
||||||
@@ -5671,7 +5680,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
|
|||||||
|
|
||||||
// Alice should detect that she doesn't need to forward any HTLC's, as
|
// Alice should detect that she doesn't need to forward any HTLC's, as
|
||||||
// the updates haven't been committed by Bob yet.
|
// the updates haven't been committed by Bob yet.
|
||||||
fwdPkg, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
fwdPkg, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -5702,7 +5711,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
|
|||||||
|
|
||||||
// Bob should detect that he has nothing to forward, as he hasn't
|
// Bob should detect that he has nothing to forward, as he hasn't
|
||||||
// received any HTLCs.
|
// received any HTLCs.
|
||||||
fwdPkg, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
fwdPkg, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -5732,10 +5741,13 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
|
|||||||
|
|
||||||
// When Alice receives the revocation, she should detect that she
|
// When Alice receives the revocation, she should detect that she
|
||||||
// can now forward the freshly locked-in Fail.
|
// can now forward the freshly locked-in Fail.
|
||||||
_, adds, settleFails, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
fwdPkg, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
adds = fwdPkg.Adds
|
||||||
|
settleFails = fwdPkg.SettleFails
|
||||||
if len(adds) != 0 {
|
if len(adds) != 0 {
|
||||||
t.Fatalf("alice shouldn't forward any HTLC's, instead wants to "+
|
t.Fatalf("alice shouldn't forward any HTLC's, instead wants to "+
|
||||||
"forward %v htlcs", len(adds))
|
"forward %v htlcs", len(adds))
|
||||||
@@ -5744,10 +5756,16 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
|
|||||||
t.Fatalf("alice should only forward one HTLC, instead wants to "+
|
t.Fatalf("alice should only forward one HTLC, instead wants to "+
|
||||||
"forward %v htlcs", len(settleFails))
|
"forward %v htlcs", len(settleFails))
|
||||||
}
|
}
|
||||||
if settleFails[0].ParentIndex != htlc2.ID {
|
|
||||||
|
fail, ok = settleFails[0].UpdateMsg.(*lnwire.UpdateFailHTLC)
|
||||||
|
if !ok {
|
||||||
|
t.Fatalf("expected UpdateFailHTLC, got %T",
|
||||||
|
settleFails[0].UpdateMsg)
|
||||||
|
}
|
||||||
|
if fail.ID != htlc2.ID {
|
||||||
t.Fatalf("alice should forward fail for htlcid=%d, instead "+
|
t.Fatalf("alice should forward fail for htlcid=%d, instead "+
|
||||||
"forwarding id=%d", htlc2.ID,
|
"forwarding id=%d", htlc2.ID,
|
||||||
settleFails[0].ParentIndex)
|
fail.ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6347,13 +6365,13 @@ func TestMaxAsynchronousHtlcs(t *testing.T) {
|
|||||||
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err, "unable to revoke revocation")
|
require.NoError(t, err, "unable to revoke revocation")
|
||||||
|
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err, "unable to receive revocation")
|
require.NoError(t, err, "unable to receive revocation")
|
||||||
|
|
||||||
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err, "unable to revoke revocation")
|
require.NoError(t, err, "unable to revoke revocation")
|
||||||
|
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err, "unable to receive revocation")
|
require.NoError(t, err, "unable to receive revocation")
|
||||||
|
|
||||||
// Send the final Add which should succeed as in step 6.
|
// Send the final Add which should succeed as in step 6.
|
||||||
@@ -7035,7 +7053,7 @@ func TestChannelRestoreUpdateLogs(t *testing.T) {
|
|||||||
// sent. However her local commitment chain still won't include the
|
// sent. However her local commitment chain still won't include the
|
||||||
// state with the HTLC, since she hasn't received a new commitment
|
// state with the HTLC, since she hasn't received a new commitment
|
||||||
// signature from Bob yet.
|
// signature from Bob yet.
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err, "unable to receive revocation")
|
require.NoError(t, err, "unable to receive revocation")
|
||||||
|
|
||||||
// Now make Alice send and sign an additional HTLC. We don't let Bob
|
// Now make Alice send and sign an additional HTLC. We don't let Bob
|
||||||
@@ -7211,7 +7229,7 @@ func TestChannelRestoreUpdateLogsFailedHTLC(t *testing.T) {
|
|||||||
|
|
||||||
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err, "unable to revoke commitment")
|
require.NoError(t, err, "unable to revoke commitment")
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err, "bob unable to process alice's revocation")
|
require.NoError(t, err, "bob unable to process alice's revocation")
|
||||||
|
|
||||||
// At this point Alice has advanced her local commitment chain to a
|
// At this point Alice has advanced her local commitment chain to a
|
||||||
@@ -7241,7 +7259,7 @@ func TestChannelRestoreUpdateLogsFailedHTLC(t *testing.T) {
|
|||||||
// the corresponding Fail from the local update log.
|
// the corresponding Fail from the local update log.
|
||||||
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err, "unable to revoke commitment")
|
require.NoError(t, err, "unable to revoke commitment")
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err, "unable to receive revocation")
|
require.NoError(t, err, "unable to receive revocation")
|
||||||
|
|
||||||
assertInLogs(t, aliceChannel, 0, 0, 0, 0)
|
assertInLogs(t, aliceChannel, 0, 0, 0, 0)
|
||||||
@@ -7466,7 +7484,7 @@ func TestChannelRestoreCommitHeight(t *testing.T) {
|
|||||||
bobChannel = restoreAndAssertCommitHeights(t, bobChannel, true, 0, 1, 0)
|
bobChannel = restoreAndAssertCommitHeights(t, bobChannel, true, 0, 1, 0)
|
||||||
|
|
||||||
// Alice receives the revocation, ACKing her pending commitment.
|
// Alice receives the revocation, ACKing her pending commitment.
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err, "unable to receive revocation")
|
require.NoError(t, err, "unable to receive revocation")
|
||||||
|
|
||||||
// However, the HTLC is still not locked into her local commitment, so
|
// However, the HTLC is still not locked into her local commitment, so
|
||||||
@@ -7495,7 +7513,7 @@ func TestChannelRestoreCommitHeight(t *testing.T) {
|
|||||||
t, aliceChannel, false, 0, 1, 1,
|
t, aliceChannel, false, 0, 1, 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err, "unable to receive revocation")
|
require.NoError(t, err, "unable to receive revocation")
|
||||||
|
|
||||||
// Alice ACKing Bob's pending commitment shouldn't change the heights
|
// Alice ACKing Bob's pending commitment shouldn't change the heights
|
||||||
@@ -7540,7 +7558,7 @@ func TestChannelRestoreCommitHeight(t *testing.T) {
|
|||||||
bobChannel = restoreAndAssertCommitHeights(t, bobChannel, true, 1, 2, 0)
|
bobChannel = restoreAndAssertCommitHeights(t, bobChannel, true, 1, 2, 0)
|
||||||
|
|
||||||
// Alice receives the revocation, ACKing her pending commitment for Bob.
|
// Alice receives the revocation, ACKing her pending commitment for Bob.
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err, "unable to receive revocation")
|
require.NoError(t, err, "unable to receive revocation")
|
||||||
|
|
||||||
// Alice receiving Bob's revocation should bump both addCommitHeightRemote
|
// Alice receiving Bob's revocation should bump both addCommitHeightRemote
|
||||||
@@ -7578,7 +7596,7 @@ func TestChannelRestoreCommitHeight(t *testing.T) {
|
|||||||
|
|
||||||
// Bob receives the revocation, which should set both addCommitHeightRemote
|
// Bob receives the revocation, which should set both addCommitHeightRemote
|
||||||
// fields to 2.
|
// fields to 2.
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err, "unable to receive revocation")
|
require.NoError(t, err, "unable to receive revocation")
|
||||||
|
|
||||||
bobChannel = restoreAndAssertCommitHeights(t, bobChannel, true, 0, 2, 2)
|
bobChannel = restoreAndAssertCommitHeights(t, bobChannel, true, 0, 2, 2)
|
||||||
@@ -7681,7 +7699,7 @@ func TestForceCloseBorkedState(t *testing.T) {
|
|||||||
|
|
||||||
// At this point, all channel mutating methods should now fail as they
|
// At this point, all channel mutating methods should now fail as they
|
||||||
// shouldn't be able to proceed if the channel is borked.
|
// shouldn't be able to proceed if the channel is borked.
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(revokeMsg)
|
_, _, err = aliceChannel.ReceiveRevocation(revokeMsg)
|
||||||
if err != channeldb.ErrChanBorked {
|
if err != channeldb.ErrChanBorked {
|
||||||
t.Fatalf("advance commitment tail should have failed")
|
t.Fatalf("advance commitment tail should have failed")
|
||||||
}
|
}
|
||||||
@@ -9477,7 +9495,7 @@ func TestChannelUnsignedAckedFailure(t *testing.T) {
|
|||||||
// -----rev----->
|
// -----rev----->
|
||||||
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Alice should sign the next commitment and go down before
|
// Alice should sign the next commitment and go down before
|
||||||
@@ -9502,7 +9520,7 @@ func TestChannelUnsignedAckedFailure(t *testing.T) {
|
|||||||
// <----rev------
|
// <----rev------
|
||||||
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, _, _, _, err = newAliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = newAliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Now Bob sends an HTLC to Alice.
|
// Now Bob sends an HTLC to Alice.
|
||||||
@@ -9588,7 +9606,7 @@ func TestChannelLocalUnsignedUpdatesFailure(t *testing.T) {
|
|||||||
// <----rev-----
|
// <----rev-----
|
||||||
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Restart Alice and assert that she can receive Bob's next commitment
|
// Restart Alice and assert that she can receive Bob's next commitment
|
||||||
@@ -9672,7 +9690,7 @@ func TestChannelSignedAckRegression(t *testing.T) {
|
|||||||
// <----rev-----
|
// <----rev-----
|
||||||
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// <----sig-----
|
// <----sig-----
|
||||||
@@ -9699,7 +9717,7 @@ func TestChannelSignedAckRegression(t *testing.T) {
|
|||||||
// <----rev-----
|
// <----rev-----
|
||||||
bobRevocation, _, _, err = bobChannel.RevokeCurrentCommitment()
|
bobRevocation, _, _, err = bobChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Restart Bob's channel state here.
|
// Restart Bob's channel state here.
|
||||||
@@ -9712,7 +9730,7 @@ func TestChannelSignedAckRegression(t *testing.T) {
|
|||||||
// -----rev---->
|
// -----rev---->
|
||||||
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
fwdPkg, _, _, _, err := newBobChannel.ReceiveRevocation(aliceRevocation)
|
fwdPkg, _, err := newBobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Assert that the fwdpkg is not empty.
|
// Assert that the fwdpkg is not empty.
|
||||||
@@ -9804,7 +9822,7 @@ func TestIsChannelClean(t *testing.T) {
|
|||||||
// <---rev---
|
// <---rev---
|
||||||
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
|
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
|
||||||
|
|
||||||
@@ -9818,7 +9836,7 @@ func TestIsChannelClean(t *testing.T) {
|
|||||||
// ---rev--->
|
// ---rev--->
|
||||||
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
|
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
|
||||||
|
|
||||||
@@ -9839,7 +9857,7 @@ func TestIsChannelClean(t *testing.T) {
|
|||||||
// ---rev--->
|
// ---rev--->
|
||||||
aliceRevocation, _, _, err = aliceChannel.RevokeCurrentCommitment()
|
aliceRevocation, _, _, err = aliceChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
|
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
|
||||||
|
|
||||||
@@ -9853,7 +9871,7 @@ func TestIsChannelClean(t *testing.T) {
|
|||||||
// <---rev---
|
// <---rev---
|
||||||
bobRevocation, _, _, err = bobChannel.RevokeCurrentCommitment()
|
bobRevocation, _, _, err = bobChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assertCleanOrDirty(true, aliceChannel, bobChannel, t)
|
assertCleanOrDirty(true, aliceChannel, bobChannel, t)
|
||||||
|
|
||||||
@@ -9877,7 +9895,7 @@ func TestIsChannelClean(t *testing.T) {
|
|||||||
// <---rev---
|
// <---rev---
|
||||||
bobRevocation, _, _, err = bobChannel.RevokeCurrentCommitment()
|
bobRevocation, _, _, err = bobChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
|
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
|
||||||
|
|
||||||
@@ -9892,7 +9910,7 @@ func TestIsChannelClean(t *testing.T) {
|
|||||||
// ---rev--->
|
// ---rev--->
|
||||||
aliceRevocation, _, _, err = aliceChannel.RevokeCurrentCommitment()
|
aliceRevocation, _, _, err = aliceChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assertCleanOrDirty(true, aliceChannel, bobChannel, t)
|
assertCleanOrDirty(true, aliceChannel, bobChannel, t)
|
||||||
}
|
}
|
||||||
@@ -10035,7 +10053,7 @@ func testGetDustSum(t *testing.T, chantype channeldb.ChannelType) {
|
|||||||
// dust.
|
// dust.
|
||||||
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
checkDust(aliceChannel, htlc2Amt, htlc2Amt)
|
checkDust(aliceChannel, htlc2Amt, htlc2Amt)
|
||||||
checkDust(bobChannel, htlc2Amt, htlc2Amt)
|
checkDust(bobChannel, htlc2Amt, htlc2Amt)
|
||||||
@@ -10048,7 +10066,7 @@ func testGetDustSum(t *testing.T, chantype channeldb.ChannelType) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
checkDust(aliceChannel, htlc2Amt, htlc2Amt)
|
checkDust(aliceChannel, htlc2Amt, htlc2Amt)
|
||||||
checkDust(bobChannel, htlc2Amt, htlc2Amt)
|
checkDust(bobChannel, htlc2Amt, htlc2Amt)
|
||||||
@@ -11008,7 +11026,7 @@ func TestAsynchronousSendingWithFeeBuffer(t *testing.T) {
|
|||||||
|
|
||||||
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Before testing the behavior of the fee buffer, we are going to fail
|
// Before testing the behavior of the fee buffer, we are going to fail
|
||||||
|
|||||||
@@ -566,7 +566,7 @@ func ForceStateTransition(chanA, chanB *LightningChannel) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _, _, _, err = chanA.ReceiveRevocation(bobRevocation)
|
_, _, err = chanA.ReceiveRevocation(bobRevocation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -579,7 +579,7 @@ func ForceStateTransition(chanA, chanB *LightningChannel) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, _, _, _, err = chanB.ReceiveRevocation(aliceRevocation)
|
_, _, err = chanB.ReceiveRevocation(aliceRevocation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ func testVectors(t *testing.T, chanType channeldb.ChannelType, test testCase) {
|
|||||||
revMsg, _, _, err := remoteChannel.RevokeCurrentCommitment()
|
revMsg, _, _, err := remoteChannel.RevokeCurrentCommitment()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, _, _, _, err = localChannel.ReceiveRevocation(revMsg)
|
_, _, err = localChannel.ReceiveRevocation(revMsg)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
remoteNewCommit, err := remoteChannel.SignNextCommitment()
|
remoteNewCommit, err := remoteChannel.SignNextCommitment()
|
||||||
|
|||||||
Reference in new issue
Block a user