|
|
|
@ -124,7 +124,7 @@ func testAddSettleWorkflow(t *testing.T, tweakless bool,
|
|
|
|
|
// we expect the messages to be ordered, Bob will receive the HTLC we
|
|
|
|
|
// just sent before he receives this signature, so the signature will
|
|
|
|
|
// cover the HTLC.
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "alice unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// Bob receives this signature message, and checks that this covers the
|
|
|
|
@ -142,7 +142,7 @@ func testAddSettleWorkflow(t *testing.T, tweakless bool,
|
|
|
|
|
// This signature will cover the HTLC, since Bob will first send the
|
|
|
|
|
// revocation just created. The revocation also acks every received
|
|
|
|
|
// HTLC up to the point where Alice sent here signature.
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "bob unable to sign alice's commitment")
|
|
|
|
|
|
|
|
|
|
// Alice then processes this revocation, sending her own revocation for
|
|
|
|
@ -255,14 +255,14 @@ func testAddSettleWorkflow(t *testing.T, tweakless bool,
|
|
|
|
|
t.Fatalf("alice unable to accept settle of outbound htlc: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "bob unable to sign settle commitment")
|
|
|
|
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err, "alice unable to process bob's new commitment")
|
|
|
|
|
|
|
|
|
|
aliceRevocation2, _, _, err := aliceChannel.RevokeCurrentCommitment()
|
|
|
|
|
require.NoError(t, err, "alice unable to generate revocation")
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "alice unable to sign new commitment")
|
|
|
|
|
|
|
|
|
|
fwdPkg, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation2)
|
|
|
|
@ -468,7 +468,7 @@ func TestChannelZeroAddLocalHeight(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Bob should send a commitment signature to Alice.
|
|
|
|
|
// <----sig------
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
|
|
|
@ -499,7 +499,7 @@ func TestChannelZeroAddLocalHeight(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Bob should now send a commitment signature to Alice.
|
|
|
|
|
// <----sig-----
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
// Alice should accept the commitment. Previously she would
|
|
|
|
@ -634,7 +634,7 @@ func testCommitHTLCSigTieBreak(t *testing.T, restart bool) {
|
|
|
|
|
// tie-breaking for commitment sorting won't affect the commitment
|
|
|
|
|
// signed by Alice because received HTLC scripts commit to the CLTV
|
|
|
|
|
// directly, so the outputs will have different scriptPubkeys.
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign alice's commitment")
|
|
|
|
|
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommit.CommitSigs)
|
|
|
|
@ -649,7 +649,7 @@ func testCommitHTLCSigTieBreak(t *testing.T, restart bool) {
|
|
|
|
|
// the offered HTLC scripts he adds for Alice will need to have the
|
|
|
|
|
// tie-breaking applied because the CLTV is not committed, but instead
|
|
|
|
|
// implicit via the construction of the second-level transactions.
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign bob's commitment")
|
|
|
|
|
|
|
|
|
|
if len(bobNewCommit.PendingHTLCs) != numHtlcs {
|
|
|
|
@ -1510,7 +1510,7 @@ func TestHTLCSigNumber(t *testing.T) {
|
|
|
|
|
// ===================================================================
|
|
|
|
|
aliceChannel, bobChannel := createChanWithHTLC(aboveDust, aboveDust)
|
|
|
|
|
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "Error signing next commitment")
|
|
|
|
|
|
|
|
|
|
if len(aliceNewCommit.HtlcSigs) != 2 {
|
|
|
|
@ -1533,7 +1533,7 @@ func TestHTLCSigNumber(t *testing.T) {
|
|
|
|
|
// ===================================================================
|
|
|
|
|
aliceChannel, bobChannel = createChanWithHTLC(aboveDust)
|
|
|
|
|
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "Error signing next commitment")
|
|
|
|
|
|
|
|
|
|
if len(aliceNewCommit.HtlcSigs) != 1 {
|
|
|
|
@ -1555,7 +1555,7 @@ func TestHTLCSigNumber(t *testing.T) {
|
|
|
|
|
// ==============================================================
|
|
|
|
|
aliceChannel, bobChannel = createChanWithHTLC(belowDust)
|
|
|
|
|
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "Error signing next commitment")
|
|
|
|
|
|
|
|
|
|
// Since the HTLC is below Bob's dust limit, Alice won't need to send
|
|
|
|
@ -1573,7 +1573,7 @@ func TestHTLCSigNumber(t *testing.T) {
|
|
|
|
|
// ================================================================
|
|
|
|
|
aliceChannel, bobChannel = createChanWithHTLC(aboveDust)
|
|
|
|
|
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "Error signing next commitment")
|
|
|
|
|
|
|
|
|
|
// Since the HTLC is above Bob's dust limit, Alice should send a
|
|
|
|
@ -1594,7 +1594,7 @@ func TestHTLCSigNumber(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Alice should produce only one signature, since one HTLC is below
|
|
|
|
|
// dust.
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "Error signing next commitment")
|
|
|
|
|
|
|
|
|
|
if len(aliceNewCommit.HtlcSigs) != 1 {
|
|
|
|
@ -2344,7 +2344,7 @@ func TestUpdateFeeFail(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Alice sends signature for commitment that does not cover any fee
|
|
|
|
|
// update.
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "alice unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// Bob verifies this commit, meaning that he checks that it is
|
|
|
|
@ -2387,11 +2387,11 @@ func TestUpdateFeeConcurrentSig(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Alice signs a commitment, and sends this to bob.
|
|
|
|
|
aliceNewCommits, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommits, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "alice unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// At the same time, Bob signs a commitment.
|
|
|
|
|
bobNewCommits, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommits, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "bob unable to sign alice's commitment")
|
|
|
|
|
|
|
|
|
|
// ...that Alice receives.
|
|
|
|
@ -2458,7 +2458,7 @@ func TestUpdateFeeSenderCommits(t *testing.T) {
|
|
|
|
|
// Alice signs a commitment, which will cover everything sent to Bob
|
|
|
|
|
// (the HTLC and the fee update), and everything acked by Bob (nothing
|
|
|
|
|
// so far).
|
|
|
|
|
aliceNewCommits, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommits, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "alice unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// Bob receives this signature message, and verifies that it is
|
|
|
|
@ -2488,7 +2488,7 @@ func TestUpdateFeeSenderCommits(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Bob commits to all updates he has received from Alice. This includes
|
|
|
|
|
// the HTLC he received, and the fee update.
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "bob unable to sign alice's commitment")
|
|
|
|
|
|
|
|
|
|
// Alice receives the revocation of the old one, and can now assume
|
|
|
|
@ -2562,7 +2562,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
|
|
|
|
|
// Bob commits to every change he has sent since last time (none). He
|
|
|
|
|
// does not commit to the received HTLC and fee update, since Alice
|
|
|
|
|
// cannot know if he has received them.
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "alice unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// Alice receives this signature message, and verifies that it is
|
|
|
|
@ -2583,7 +2583,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
|
|
|
|
|
// Alice will sign next commitment. Since she sent the revocation, she
|
|
|
|
|
// also ack'ed everything received, but in this case this is nothing.
|
|
|
|
|
// Since she sent the two updates, this signature will cover those two.
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "bob unable to sign alice's commitment")
|
|
|
|
|
|
|
|
|
|
// Bob gets the signature for the new commitment from Alice. He assumes
|
|
|
|
@ -2613,7 +2613,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Bob will send a new signature, which will cover what he just acked:
|
|
|
|
|
// the HTLC and fee update.
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "alice unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// Alice receives revocation from Bob, and can now be sure that Bob
|
|
|
|
@ -2703,7 +2703,7 @@ func TestUpdateFeeMultipleUpdates(t *testing.T) {
|
|
|
|
|
// Alice signs a commitment, which will cover everything sent to Bob
|
|
|
|
|
// (the HTLC and the fee update), and everything acked by Bob (nothing
|
|
|
|
|
// so far).
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "alice unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
bobChannel.ReceiveUpdateFee(fee1)
|
|
|
|
@ -2749,7 +2749,7 @@ func TestUpdateFeeMultipleUpdates(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Bob commits to all updates he has received from Alice. This includes
|
|
|
|
|
// the HTLC he received, and the fee update.
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "bob unable to sign alice's commitment")
|
|
|
|
|
|
|
|
|
|
// Alice receives the revocation of the old one, and can now assume that
|
|
|
|
@ -2855,7 +2855,9 @@ func assertNoChanSyncNeeded(t *testing.T, aliceChannel *LightningChannel,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bobMsgsToSend, _, _, err := bobChannel.ProcessChanSyncMsg(aliceChanSyncMsg)
|
|
|
|
|
bobMsgsToSend, _, _, err := bobChannel.ProcessChanSyncMsg(
|
|
|
|
|
testQuit, aliceChanSyncMsg,
|
|
|
|
|
)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("line #%v: unable to process ChannelReestablish "+
|
|
|
|
|
"msg: %v", line, err)
|
|
|
|
@ -2865,7 +2867,9 @@ func assertNoChanSyncNeeded(t *testing.T, aliceChannel *LightningChannel,
|
|
|
|
|
"instead wants to send: %v", line, spew.Sdump(bobMsgsToSend))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aliceMsgsToSend, _, _, err := aliceChannel.ProcessChanSyncMsg(bobChanSyncMsg)
|
|
|
|
|
aliceMsgsToSend, _, _, err := aliceChannel.ProcessChanSyncMsg(
|
|
|
|
|
testQuit, bobChanSyncMsg,
|
|
|
|
|
)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("line #%v: unable to process ChannelReestablish "+
|
|
|
|
|
"msg: %v", line, err)
|
|
|
|
@ -3055,7 +3059,7 @@ func testChanSyncOweCommitment(t *testing.T, chanType channeldb.ChannelType) {
|
|
|
|
|
// Now we'll begin the core of the test itself. Alice will extend a new
|
|
|
|
|
// commitment to Bob, but the connection drops before Bob can process
|
|
|
|
|
// it.
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// If this is a taproot channel, then we'll generate fresh verification
|
|
|
|
@ -3080,7 +3084,7 @@ func testChanSyncOweCommitment(t *testing.T, chanType channeldb.ChannelType) {
|
|
|
|
|
// above.
|
|
|
|
|
assertAliceCommitRetransmit := func() *lnwire.CommitSig {
|
|
|
|
|
aliceMsgsToSend, _, _, err := aliceChannel.ProcessChanSyncMsg(
|
|
|
|
|
bobSyncMsg,
|
|
|
|
|
testQuit, bobSyncMsg,
|
|
|
|
|
)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("unable to process chan sync msg: %v", err)
|
|
|
|
@ -3170,7 +3174,9 @@ func testChanSyncOweCommitment(t *testing.T, chanType channeldb.ChannelType) {
|
|
|
|
|
|
|
|
|
|
// From Bob's Pov he has nothing else to send, so he should conclude he
|
|
|
|
|
// has no further action remaining.
|
|
|
|
|
bobMsgsToSend, _, _, err := bobChannel.ProcessChanSyncMsg(aliceSyncMsg)
|
|
|
|
|
bobMsgsToSend, _, _, err := bobChannel.ProcessChanSyncMsg(
|
|
|
|
|
testQuit, aliceSyncMsg,
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, err, "unable to process chan sync msg")
|
|
|
|
|
if len(bobMsgsToSend) != 0 {
|
|
|
|
|
t.Fatalf("expected bob to send %v messages instead will "+
|
|
|
|
@ -3198,7 +3204,7 @@ func testChanSyncOweCommitment(t *testing.T, chanType channeldb.ChannelType) {
|
|
|
|
|
require.NoError(t, err, "bob unable to process alice's commitment")
|
|
|
|
|
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
|
|
|
|
require.NoError(t, err, "unable to revoke bob commitment")
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "bob unable to sign commitment")
|
|
|
|
|
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
|
|
|
|
require.NoError(t, err, "alice unable to recv revocation")
|
|
|
|
@ -3393,7 +3399,7 @@ func TestChanSyncOweCommitmentAuxSigner(t *testing.T) {
|
|
|
|
|
fn.Some(sigBlobBuf.Bytes()), nil,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
_, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
_, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
_, err = aliceChannel.GenMusigNonces()
|
|
|
|
@ -3405,7 +3411,7 @@ func TestChanSyncOweCommitmentAuxSigner(t *testing.T) {
|
|
|
|
|
require.NoError(t, err, "unable to produce chan sync msg")
|
|
|
|
|
|
|
|
|
|
aliceMsgsToSend, _, _, err := aliceChannel.ProcessChanSyncMsg(
|
|
|
|
|
bobSyncMsg,
|
|
|
|
|
testQuit, bobSyncMsg,
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.Len(t, aliceMsgsToSend, 2)
|
|
|
|
@ -3497,7 +3503,7 @@ func TestAuxSignerShutdown(t *testing.T) {
|
|
|
|
|
fn.Some(sigBlobBuf.Bytes()), nil,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
_, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
_, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.ErrorIs(t, err, auxSignerShutdownErr)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -3510,7 +3516,9 @@ func testChanSyncOweCommitmentPendingRemote(t *testing.T,
|
|
|
|
|
require.NoError(t, err, "unable to create test channels")
|
|
|
|
|
|
|
|
|
|
var fakeOnionBlob [lnwire.OnionPacketSize]byte
|
|
|
|
|
copy(fakeOnionBlob[:], bytes.Repeat([]byte{0x05}, lnwire.OnionPacketSize))
|
|
|
|
|
copy(fakeOnionBlob[:], bytes.Repeat(
|
|
|
|
|
[]byte{0x05}, lnwire.OnionPacketSize,
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
// We'll start off the scenario where Bob send two htlcs to Alice in a
|
|
|
|
|
// single state update.
|
|
|
|
@ -3549,7 +3557,10 @@ func testChanSyncOweCommitmentPendingRemote(t *testing.T,
|
|
|
|
|
|
|
|
|
|
// Next, Alice settles the HTLCs from Bob in distinct state updates.
|
|
|
|
|
for i := 0; i < numHtlcs; i++ {
|
|
|
|
|
err = aliceChannel.SettleHTLC(preimages[i], uint64(i), nil, nil, nil)
|
|
|
|
|
err = aliceChannel.SettleHTLC(
|
|
|
|
|
preimages[i], uint64(i), nil, nil, nil,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("unable to settle htlc: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -3558,7 +3569,9 @@ func testChanSyncOweCommitmentPendingRemote(t *testing.T,
|
|
|
|
|
t.Fatalf("unable to settle htlc: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(
|
|
|
|
|
testQuit,
|
|
|
|
|
)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("unable to sign commitment: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -3596,7 +3609,7 @@ func testChanSyncOweCommitmentPendingRemote(t *testing.T,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Bob signs the commitment he owes.
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// This commitment is expected to contain no htlcs anymore.
|
|
|
|
@ -3705,14 +3718,14 @@ func testChanSyncOweRevocation(t *testing.T, chanType channeldb.ChannelType) {
|
|
|
|
|
//
|
|
|
|
|
// Alice signs the next state, then Bob receives and sends his
|
|
|
|
|
// revocation message.
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err, "bob unable to process alice's commitment")
|
|
|
|
|
|
|
|
|
|
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
|
|
|
|
require.NoError(t, err, "unable to revoke bob commitment")
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "bob unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
|
|
|
@ -3748,7 +3761,7 @@ func testChanSyncOweRevocation(t *testing.T, chanType channeldb.ChannelType) {
|
|
|
|
|
t.Helper()
|
|
|
|
|
|
|
|
|
|
aliceMsgsToSend, _, _, err := aliceChannel.ProcessChanSyncMsg(
|
|
|
|
|
bobSyncMsg,
|
|
|
|
|
testQuit, bobSyncMsg,
|
|
|
|
|
)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("unable to process chan sync msg: %v", err)
|
|
|
|
@ -3779,7 +3792,9 @@ func testChanSyncOweRevocation(t *testing.T, chanType channeldb.ChannelType) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// From Bob's PoV he shouldn't think that he owes Alice any messages.
|
|
|
|
|
bobMsgsToSend, _, _, err := bobChannel.ProcessChanSyncMsg(aliceSyncMsg)
|
|
|
|
|
bobMsgsToSend, _, _, err := bobChannel.ProcessChanSyncMsg(
|
|
|
|
|
testQuit, aliceSyncMsg,
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, err, "unable to process chan sync msg")
|
|
|
|
|
if len(bobMsgsToSend) != 0 {
|
|
|
|
|
t.Fatalf("expected bob to not retransmit, instead has: %v",
|
|
|
|
@ -3908,7 +3923,7 @@ func testChanSyncOweRevocationAndCommit(t *testing.T,
|
|
|
|
|
|
|
|
|
|
// Progressing the exchange: Alice will send her signature, Bob will
|
|
|
|
|
// receive, send a revocation and also a signature for Alice's state.
|
|
|
|
|
aliceNewCommits, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommits, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommits.CommitSigs)
|
|
|
|
|
require.NoError(t, err, "bob unable to process alice's commitment")
|
|
|
|
@ -3917,7 +3932,7 @@ func testChanSyncOweRevocationAndCommit(t *testing.T,
|
|
|
|
|
// reach Alice before the connection dies.
|
|
|
|
|
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
|
|
|
|
require.NoError(t, err, "unable to revoke bob commitment")
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "bob unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// If we now attempt to resync, then Alice should conclude that she
|
|
|
|
@ -3939,7 +3954,9 @@ func testChanSyncOweRevocationAndCommit(t *testing.T,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aliceMsgsToSend, _, _, err := aliceChannel.ProcessChanSyncMsg(bobSyncMsg)
|
|
|
|
|
aliceMsgsToSend, _, _, err := aliceChannel.ProcessChanSyncMsg(
|
|
|
|
|
testQuit, bobSyncMsg,
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, err, "unable to process chan sync msg")
|
|
|
|
|
if len(aliceMsgsToSend) != 0 {
|
|
|
|
|
t.Fatalf("expected alice to not retransmit, instead she's "+
|
|
|
|
@ -3950,7 +3967,7 @@ func testChanSyncOweRevocationAndCommit(t *testing.T,
|
|
|
|
|
t.Helper()
|
|
|
|
|
|
|
|
|
|
bobMsgsToSend, _, _, err := bobChannel.ProcessChanSyncMsg(
|
|
|
|
|
aliceSyncMsg,
|
|
|
|
|
testQuit, aliceSyncMsg,
|
|
|
|
|
)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("unable to process chan sync msg: %v", err)
|
|
|
|
@ -4116,7 +4133,7 @@ func testChanSyncOweRevocationAndCommitForceTransition(t *testing.T,
|
|
|
|
|
addAndReceiveHTLC(t, bobChannel, aliceChannel, bobHtlc[1], nil)
|
|
|
|
|
|
|
|
|
|
// Bob signs the new state update, and sends the signature to Alice.
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "bob unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
|
|
|
@ -4140,7 +4157,7 @@ func testChanSyncOweRevocationAndCommitForceTransition(t *testing.T,
|
|
|
|
|
|
|
|
|
|
// Progressing the exchange: Alice will send her signature, with Bob
|
|
|
|
|
// processing the new state locally.
|
|
|
|
|
aliceNewCommits, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommits, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommits.CommitSigs)
|
|
|
|
|
require.NoError(t, err, "bob unable to process alice's commitment")
|
|
|
|
@ -4170,7 +4187,9 @@ func testChanSyncOweRevocationAndCommitForceTransition(t *testing.T,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aliceMsgsToSend, _, _, err := aliceChannel.ProcessChanSyncMsg(bobSyncMsg)
|
|
|
|
|
aliceMsgsToSend, _, _, err := aliceChannel.ProcessChanSyncMsg(
|
|
|
|
|
testQuit, bobSyncMsg,
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, err, "unable to process chan sync msg")
|
|
|
|
|
if len(aliceMsgsToSend) != 0 {
|
|
|
|
|
t.Fatalf("expected alice to not retransmit, instead she's "+
|
|
|
|
@ -4181,7 +4200,9 @@ func testChanSyncOweRevocationAndCommitForceTransition(t *testing.T,
|
|
|
|
|
// send his RevokeAndAck message again. Additionally, the CommitSig
|
|
|
|
|
// message that he sends should be sufficient to finalize the state
|
|
|
|
|
// transition.
|
|
|
|
|
bobMsgsToSend, _, _, err := bobChannel.ProcessChanSyncMsg(aliceSyncMsg)
|
|
|
|
|
bobMsgsToSend, _, _, err := bobChannel.ProcessChanSyncMsg(
|
|
|
|
|
testQuit, aliceSyncMsg,
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, err, "unable to process chan sync msg")
|
|
|
|
|
if len(bobMsgsToSend) != 2 {
|
|
|
|
|
t.Fatalf("expected bob to send %v messages, instead "+
|
|
|
|
@ -4374,7 +4395,9 @@ func TestChanSyncFailure(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
addAndReceiveHTLC(t, bobChannel, aliceChannel, bobHtlc, nil)
|
|
|
|
|
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(
|
|
|
|
|
testQuit,
|
|
|
|
|
)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("unable to sign next commit: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -4399,7 +4422,7 @@ func TestChanSyncFailure(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Alice should detect from Bob's message that she lost state.
|
|
|
|
|
_, _, _, err = aliceOld.ProcessChanSyncMsg(bobSyncMsg)
|
|
|
|
|
_, _, _, err = aliceOld.ProcessChanSyncMsg(testQuit, bobSyncMsg)
|
|
|
|
|
if _, ok := err.(*ErrCommitSyncLocalDataLoss); !ok {
|
|
|
|
|
t.Fatalf("wrong error, expected "+
|
|
|
|
|
"ErrCommitSyncLocalDataLoss instead got: %v",
|
|
|
|
@ -4407,7 +4430,9 @@ func TestChanSyncFailure(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Bob should detect that Alice probably lost state.
|
|
|
|
|
_, _, _, err = bobChannel.ProcessChanSyncMsg(aliceSyncMsg)
|
|
|
|
|
_, _, _, err = bobChannel.ProcessChanSyncMsg(
|
|
|
|
|
testQuit, aliceSyncMsg,
|
|
|
|
|
)
|
|
|
|
|
if err != ErrCommitSyncRemoteDataLoss {
|
|
|
|
|
t.Fatalf("wrong error, expected "+
|
|
|
|
|
"ErrCommitSyncRemoteDataLoss instead got: %v",
|
|
|
|
@ -4468,7 +4493,7 @@ func TestChanSyncFailure(t *testing.T) {
|
|
|
|
|
bobSyncMsg, err := bobChannel.channelState.ChanSyncMsg()
|
|
|
|
|
require.NoError(t, err, "unable to produce chan sync msg")
|
|
|
|
|
bobSyncMsg.LocalUnrevokedCommitPoint = nil
|
|
|
|
|
_, _, _, err = aliceOld.ProcessChanSyncMsg(bobSyncMsg)
|
|
|
|
|
_, _, _, err = aliceOld.ProcessChanSyncMsg(testQuit, bobSyncMsg)
|
|
|
|
|
if err != ErrCannotSyncCommitChains {
|
|
|
|
|
t.Fatalf("wrong error, expected ErrCannotSyncCommitChains "+
|
|
|
|
|
"instead got: %v", err)
|
|
|
|
@ -4480,7 +4505,7 @@ func TestChanSyncFailure(t *testing.T) {
|
|
|
|
|
bobSyncMsg, err = bobChannel.channelState.ChanSyncMsg()
|
|
|
|
|
require.NoError(t, err, "unable to produce chan sync msg")
|
|
|
|
|
bobSyncMsg.NextLocalCommitHeight++
|
|
|
|
|
_, _, _, err = aliceChannel.ProcessChanSyncMsg(bobSyncMsg)
|
|
|
|
|
_, _, _, err = aliceChannel.ProcessChanSyncMsg(testQuit, bobSyncMsg)
|
|
|
|
|
if err != ErrCannotSyncCommitChains {
|
|
|
|
|
t.Fatalf("wrong error, expected ErrCannotSyncCommitChains "+
|
|
|
|
|
"instead got: %v", err)
|
|
|
|
@ -4491,7 +4516,7 @@ func TestChanSyncFailure(t *testing.T) {
|
|
|
|
|
bobSyncMsg, err = bobChannel.channelState.ChanSyncMsg()
|
|
|
|
|
require.NoError(t, err, "unable to produce chan sync msg")
|
|
|
|
|
bobSyncMsg.NextLocalCommitHeight--
|
|
|
|
|
_, _, _, err = aliceChannel.ProcessChanSyncMsg(bobSyncMsg)
|
|
|
|
|
_, _, _, err = aliceChannel.ProcessChanSyncMsg(testQuit, bobSyncMsg)
|
|
|
|
|
if err != ErrCommitSyncRemoteDataLoss {
|
|
|
|
|
t.Fatalf("wrong error, expected ErrCommitSyncRemoteDataLoss "+
|
|
|
|
|
"instead got: %v", err)
|
|
|
|
@ -4507,7 +4532,7 @@ func TestChanSyncFailure(t *testing.T) {
|
|
|
|
|
require.NoError(t, err, "unable to parse pubkey")
|
|
|
|
|
|
|
|
|
|
bobSyncMsg.LocalUnrevokedCommitPoint = modCommitPoint
|
|
|
|
|
_, _, _, err = aliceChannel.ProcessChanSyncMsg(bobSyncMsg)
|
|
|
|
|
_, _, _, err = aliceChannel.ProcessChanSyncMsg(testQuit, bobSyncMsg)
|
|
|
|
|
if err != ErrInvalidLocalUnrevokedCommitPoint {
|
|
|
|
|
t.Fatalf("wrong error, expected "+
|
|
|
|
|
"ErrInvalidLocalUnrevokedCommitPoint instead got: %v",
|
|
|
|
@ -4527,7 +4552,7 @@ func TestChanSyncFailure(t *testing.T) {
|
|
|
|
|
bobSyncMsg, err = bobChannel.channelState.ChanSyncMsg()
|
|
|
|
|
require.NoError(t, err, "unable to produce chan sync msg")
|
|
|
|
|
bobSyncMsg.LocalUnrevokedCommitPoint = modCommitPoint
|
|
|
|
|
_, _, _, err = aliceChannel.ProcessChanSyncMsg(bobSyncMsg)
|
|
|
|
|
_, _, _, err = aliceChannel.ProcessChanSyncMsg(testQuit, bobSyncMsg)
|
|
|
|
|
if err != ErrInvalidLocalUnrevokedCommitPoint {
|
|
|
|
|
t.Fatalf("wrong error, expected "+
|
|
|
|
|
"ErrInvalidLocalUnrevokedCommitPoint instead got: %v",
|
|
|
|
@ -4594,7 +4619,7 @@ func TestChannelRetransmissionFeeUpdate(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Now, Alice will send a new commitment to Bob, but we'll simulate a
|
|
|
|
|
// connection failure, so Bob doesn't get her signature.
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// Restart both channels to simulate a connection restart.
|
|
|
|
@ -4612,7 +4637,9 @@ func TestChannelRetransmissionFeeUpdate(t *testing.T) {
|
|
|
|
|
require.NoError(t, err, "unable to produce chan sync msg")
|
|
|
|
|
|
|
|
|
|
// Bob should detect that he doesn't need to send anything to Alice.
|
|
|
|
|
bobMsgsToSend, _, _, err := bobChannel.ProcessChanSyncMsg(aliceSyncMsg)
|
|
|
|
|
bobMsgsToSend, _, _, err := bobChannel.ProcessChanSyncMsg(
|
|
|
|
|
testQuit, aliceSyncMsg,
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, err, "unable to process chan sync msg")
|
|
|
|
|
if len(bobMsgsToSend) != 0 {
|
|
|
|
|
t.Fatalf("expected bob to send %v messages instead "+
|
|
|
|
@ -4624,7 +4651,7 @@ func TestChannelRetransmissionFeeUpdate(t *testing.T) {
|
|
|
|
|
// that she needs to first send a new UpdateFee message, and also a
|
|
|
|
|
// CommitSig.
|
|
|
|
|
aliceMsgsToSend, _, _, err := aliceChannel.ProcessChanSyncMsg(
|
|
|
|
|
bobSyncMsg,
|
|
|
|
|
testQuit, bobSyncMsg,
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, err, "unable to process chan sync msg")
|
|
|
|
|
if len(aliceMsgsToSend) != 2 {
|
|
|
|
@ -4680,7 +4707,7 @@ func TestChannelRetransmissionFeeUpdate(t *testing.T) {
|
|
|
|
|
require.NoError(t, err, "bob unable to process alice's commitment")
|
|
|
|
|
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
|
|
|
|
require.NoError(t, err, "unable to revoke bob commitment")
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "bob unable to sign commitment")
|
|
|
|
|
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
|
|
|
|
require.NoError(t, err, "alice unable to recv revocation")
|
|
|
|
@ -4811,7 +4838,7 @@ func TestFeeUpdateOldDiskFormat(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Now, Alice will send a new commitment to Bob, but we'll simulate a
|
|
|
|
|
// connection failure, so Bob doesn't get the signature.
|
|
|
|
|
aliceNewCommitSig, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommitSig, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// Before restarting Alice, to mimic the old format, we fetch the
|
|
|
|
@ -4868,7 +4895,7 @@ func TestFeeUpdateOldDiskFormat(t *testing.T) {
|
|
|
|
|
require.NoError(t, err, "bob unable to process alice's commitment")
|
|
|
|
|
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
|
|
|
|
|
require.NoError(t, err, "unable to revoke bob commitment")
|
|
|
|
|
bobNewCommitSigs, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommitSigs, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "bob unable to sign commitment")
|
|
|
|
|
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
|
|
|
|
|
require.NoError(t, err, "alice unable to recv revocation")
|
|
|
|
@ -4944,11 +4971,11 @@ func TestChanSyncUnableToSync(t *testing.T) {
|
|
|
|
|
NextLocalCommitHeight: 1000,
|
|
|
|
|
RemoteCommitTailHeight: 9000,
|
|
|
|
|
}
|
|
|
|
|
_, _, _, err = bobChannel.ProcessChanSyncMsg(badChanSync)
|
|
|
|
|
_, _, _, err = bobChannel.ProcessChanSyncMsg(testQuit, badChanSync)
|
|
|
|
|
if err != ErrCannotSyncCommitChains {
|
|
|
|
|
t.Fatalf("expected error instead have: %v", err)
|
|
|
|
|
}
|
|
|
|
|
_, _, _, err = aliceChannel.ProcessChanSyncMsg(badChanSync)
|
|
|
|
|
_, _, _, err = aliceChannel.ProcessChanSyncMsg(testQuit, badChanSync)
|
|
|
|
|
if err != ErrCannotSyncCommitChains {
|
|
|
|
|
t.Fatalf("expected error instead have: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -5016,7 +5043,7 @@ func TestChanSyncInvalidLastSecret(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Alice's former self should conclude that she possibly lost data as
|
|
|
|
|
// Bob is sending a valid commit secret for the latest state.
|
|
|
|
|
_, _, _, err = aliceOld.ProcessChanSyncMsg(bobChanSync)
|
|
|
|
|
_, _, _, err = aliceOld.ProcessChanSyncMsg(testQuit, bobChanSync)
|
|
|
|
|
if _, ok := err.(*ErrCommitSyncLocalDataLoss); !ok {
|
|
|
|
|
t.Fatalf("wrong error, expected ErrCommitSyncLocalDataLoss "+
|
|
|
|
|
"instead got: %v", err)
|
|
|
|
@ -5024,7 +5051,7 @@ func TestChanSyncInvalidLastSecret(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Bob should conclude that he should force close the channel, as Alice
|
|
|
|
|
// cannot continue operation.
|
|
|
|
|
_, _, _, err = bobChannel.ProcessChanSyncMsg(aliceChanSync)
|
|
|
|
|
_, _, _, err = bobChannel.ProcessChanSyncMsg(testQuit, aliceChanSync)
|
|
|
|
|
if err != ErrInvalidLastCommitSecret {
|
|
|
|
|
t.Fatalf("wrong error, expected ErrInvalidLastCommitSecret, "+
|
|
|
|
|
"instead got: %v", err)
|
|
|
|
@ -5505,7 +5532,7 @@ func TestSignCommitmentFailNotLockedIn(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// If we now try to initiate a state update, then it should fail as
|
|
|
|
|
// Alice is unable to actually create a new state.
|
|
|
|
|
_, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
_, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
if err != ErrNoWindow {
|
|
|
|
|
t.Fatalf("expected ErrNoWindow, instead have: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -5534,7 +5561,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// We'll now manually initiate a state transition between Alice and
|
|
|
|
|
// bob.
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
@ -5563,7 +5590,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Now, have Bob initiate a transition to lock in the Adds sent by
|
|
|
|
|
// Alice.
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
@ -5608,7 +5635,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// We'll now initiate another state transition, but this time Bob will
|
|
|
|
|
// lead.
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
@ -5643,7 +5670,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Now, begin another state transition led by Alice, and fail the second
|
|
|
|
|
// HTLC part-way through the dance.
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
@ -5707,7 +5734,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Have Alice initiate a state transition, which does not include the
|
|
|
|
|
// HTLCs just re-added to the channel state.
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
@ -5736,7 +5763,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Now initiate a final update from Bob to lock in the final Fail.
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
@ -5768,7 +5795,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Finally, have Bob initiate a state transition that locks in the Fail
|
|
|
|
|
// added after the restart.
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
@ -5821,7 +5848,7 @@ func TestInvalidCommitSigError(t *testing.T) {
|
|
|
|
|
addAndReceiveHTLC(t, aliceChannel, bobChannel, htlc, nil)
|
|
|
|
|
|
|
|
|
|
// Alice will now attempt to initiate a state transition.
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign new commit")
|
|
|
|
|
|
|
|
|
|
// Before the signature gets to Bob, we'll mutate it, such that the
|
|
|
|
@ -6013,7 +6040,7 @@ func TestChannelUnilateralClosePendingCommit(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// With the HTLC added, we'll now manually initiate a state transition
|
|
|
|
|
// from Alice to Bob.
|
|
|
|
|
_, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
_, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
@ -6245,7 +6272,7 @@ func TestMaxAcceptedHTLCs(t *testing.T) {
|
|
|
|
|
addAndReceiveHTLC(t, aliceChannel, bobChannel, htlc, nil)
|
|
|
|
|
|
|
|
|
|
// Add a commitment to Bob's commitment chain.
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign next commitment")
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err, "unable to recv new commitment")
|
|
|
|
@ -6340,7 +6367,7 @@ func TestMaxAsynchronousHtlcs(t *testing.T) {
|
|
|
|
|
t.Fatalf("unable to receive fail htlc: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign next commitment")
|
|
|
|
|
|
|
|
|
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
|
|
|
@ -6348,7 +6375,7 @@ func TestMaxAsynchronousHtlcs(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Cover the HTLC referenced with id equal to numHTLCs-1 with a new
|
|
|
|
|
// signature (step 3).
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign next commitment")
|
|
|
|
|
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommit.CommitSigs)
|
|
|
|
@ -6373,7 +6400,7 @@ func TestMaxAsynchronousHtlcs(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Receiving the commitment should succeed as in step 7 since space was
|
|
|
|
|
// made.
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign next commitment")
|
|
|
|
|
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommit.CommitSigs)
|
|
|
|
@ -6997,7 +7024,7 @@ func TestChannelRestoreUpdateLogs(t *testing.T) {
|
|
|
|
|
addAndReceiveHTLC(t, aliceChannel, bobChannel, htlcAlice, nil)
|
|
|
|
|
|
|
|
|
|
// Let Alice sign a new state, which will include the HTLC just sent.
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// Bob receives this commitment signature, and revokes his old state.
|
|
|
|
@ -7027,7 +7054,7 @@ func TestChannelRestoreUpdateLogs(t *testing.T) {
|
|
|
|
|
// and remote commit chains are updated in an async fashion. Since the
|
|
|
|
|
// remote chain was updated with the latest state (since Bob sent the
|
|
|
|
|
// revocation earlier) we can keep advancing the remote commit chain.
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// After Alice has signed this commitment, her local commitment will
|
|
|
|
@ -7171,7 +7198,7 @@ func TestChannelRestoreUpdateLogsFailedHTLC(t *testing.T) {
|
|
|
|
|
restoreAndAssert(t, aliceChannel, 1, 0, 0, 0)
|
|
|
|
|
|
|
|
|
|
// Bob sends a signature.
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err, "unable to receive commitment")
|
|
|
|
@ -7198,7 +7225,7 @@ func TestChannelRestoreUpdateLogsFailedHTLC(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Now send a signature from Alice. This will give Bob a new commitment
|
|
|
|
|
// where the HTLC is removed.
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err, "unable to receive commitment")
|
|
|
|
@ -7261,7 +7288,7 @@ func TestDuplicateFailRejection(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// We'll now have Bob sign a new commitment to lock in the HTLC fail
|
|
|
|
|
// for Alice.
|
|
|
|
|
_, err = bobChannel.SignNextCommitment()
|
|
|
|
|
_, err = bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commit")
|
|
|
|
|
|
|
|
|
|
// We'll now force a restart for Bob and Alice, so we can test the
|
|
|
|
@ -7324,7 +7351,7 @@ func TestDuplicateSettleRejection(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// We'll now have Bob sign a new commitment to lock in the HTLC fail
|
|
|
|
|
// for Alice.
|
|
|
|
|
_, err = bobChannel.SignNextCommitment()
|
|
|
|
|
_, err = bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commit")
|
|
|
|
|
|
|
|
|
|
// We'll now force a restart for Bob and Alice, so we can test the
|
|
|
|
@ -7403,7 +7430,7 @@ func TestChannelRestoreCommitHeight(t *testing.T) {
|
|
|
|
|
addAndReceiveHTLC(t, aliceChannel, bobChannel, htlcAlice, nil)
|
|
|
|
|
|
|
|
|
|
// Let Alice sign a new state, which will include the HTLC just sent.
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// The HTLC should only be on the pending remote commitment, so the
|
|
|
|
@ -7435,7 +7462,7 @@ func TestChannelRestoreCommitHeight(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Now let Bob send the commitment signature making the HTLC lock in on
|
|
|
|
|
// Alice's commitment.
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// At this stage Bob has a pending remote commitment. Make sure
|
|
|
|
@ -7468,7 +7495,7 @@ func TestChannelRestoreCommitHeight(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Send a new signature from Alice to Bob, making Alice have a pending
|
|
|
|
|
// remote commitment.
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// A restoration should keep the add heights iof the first HTLC, and
|
|
|
|
@ -7507,7 +7534,7 @@ func TestChannelRestoreCommitHeight(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Sign a new state for Alice, making Bob have a pending remote
|
|
|
|
|
// commitment.
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// The signing of a new commitment for Alice should have given the new
|
|
|
|
@ -7544,7 +7571,7 @@ func TestChannelRestoreCommitHeight(t *testing.T) {
|
|
|
|
|
require.NoError(t, err, "unable to recv htlc cancel")
|
|
|
|
|
|
|
|
|
|
// Now Bob signs for the fail update.
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// Bob has a pending commitment for Alice, it shouldn't affect the add
|
|
|
|
@ -7602,13 +7629,13 @@ func TestForceCloseBorkedState(t *testing.T) {
|
|
|
|
|
// Do the commitment dance until Bob sends a revocation so Alice is
|
|
|
|
|
// able to receive the revocation, and then also make a new state
|
|
|
|
|
// herself.
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commit")
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err, "unable to receive commitment")
|
|
|
|
|
revokeMsg, _, _, err := bobChannel.RevokeCurrentCommitment()
|
|
|
|
|
require.NoError(t, err, "unable to revoke bob commitment")
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commit")
|
|
|
|
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err, "unable to receive commitment")
|
|
|
|
@ -7642,7 +7669,7 @@ func TestForceCloseBorkedState(t *testing.T) {
|
|
|
|
|
// We manually advance the commitment tail here since the above
|
|
|
|
|
// ReceiveRevocation call will fail before it's actually advanced.
|
|
|
|
|
aliceChannel.remoteCommitChain.advanceTail()
|
|
|
|
|
_, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
_, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
if err != channeldb.ErrChanBorked {
|
|
|
|
|
t.Fatalf("sign commitment should have failed: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -8109,7 +8136,7 @@ func TestChannelFeeRateFloor(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check that alice can still sign commitments.
|
|
|
|
|
aliceNewCommit, err := alice.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := alice.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "alice unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// Check that bob can still receive commitments.
|
|
|
|
@ -9413,7 +9440,7 @@ func TestChannelUnsignedAckedFailure(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Bob should send a commitment signature to Alice.
|
|
|
|
|
// <----sig------
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -9428,7 +9455,7 @@ func TestChannelUnsignedAckedFailure(t *testing.T) {
|
|
|
|
|
// Alice should sign the next commitment and go down before
|
|
|
|
|
// sending it.
|
|
|
|
|
// -----sig-----X
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
newAliceChannel, err := NewLightningChannel(
|
|
|
|
@ -9459,7 +9486,7 @@ func TestChannelUnsignedAckedFailure(t *testing.T) {
|
|
|
|
|
// Bob sends the final signature to Alice and Alice should not
|
|
|
|
|
// reject it, given that we properly restore the unsigned acked
|
|
|
|
|
// updates and therefore our update log is structured correctly.
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = newAliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -9517,7 +9544,7 @@ func TestChannelLocalUnsignedUpdatesFailure(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Alice should send a commitment signature to Bob.
|
|
|
|
|
// -----sig---->
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -9541,7 +9568,7 @@ func TestChannelLocalUnsignedUpdatesFailure(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Bob sends the final signature and Alice should not reject it.
|
|
|
|
|
// <----sig-----
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = newAliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -9600,7 +9627,7 @@ func TestChannelSignedAckRegression(t *testing.T) {
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
// -----sig---->
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -9612,7 +9639,7 @@ func TestChannelSignedAckRegression(t *testing.T) {
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
// <----sig-----
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -9624,7 +9651,7 @@ func TestChannelSignedAckRegression(t *testing.T) {
|
|
|
|
|
addAndReceiveHTLC(t, aliceChannel, bobChannel, htlc2, nil)
|
|
|
|
|
|
|
|
|
|
// -----sig---->
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -9654,7 +9681,7 @@ func TestChannelSignedAckRegression(t *testing.T) {
|
|
|
|
|
// Bob should no longer fail to sign this commitment due to faulty
|
|
|
|
|
// update logs.
|
|
|
|
|
// <----sig-----
|
|
|
|
|
bobNewCommit, err = newBobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err = newBobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
// Alice should receive the new commitment without hiccups.
|
|
|
|
@ -9725,7 +9752,7 @@ func TestIsChannelClean(t *testing.T) {
|
|
|
|
|
// removed from both commitments.
|
|
|
|
|
|
|
|
|
|
// ---sig--->
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -9739,7 +9766,7 @@ func TestIsChannelClean(t *testing.T) {
|
|
|
|
|
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
|
|
|
|
|
|
|
|
|
|
// <---sig---
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -9760,7 +9787,7 @@ func TestIsChannelClean(t *testing.T) {
|
|
|
|
|
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
|
|
|
|
|
|
|
|
|
|
// <---sig---
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -9774,7 +9801,7 @@ func TestIsChannelClean(t *testing.T) {
|
|
|
|
|
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
|
|
|
|
|
|
|
|
|
|
// ---sig--->
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -9798,7 +9825,7 @@ func TestIsChannelClean(t *testing.T) {
|
|
|
|
|
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
|
|
|
|
|
|
|
|
|
|
// ---sig--->
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -9812,7 +9839,7 @@ func TestIsChannelClean(t *testing.T) {
|
|
|
|
|
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
|
|
|
|
|
|
|
|
|
|
// <---sig---
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err = bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -9943,7 +9970,7 @@ func testGetDustSum(t *testing.T, chantype channeldb.ChannelType) {
|
|
|
|
|
checkDust(bobChannel, htlc2Amt, htlc2Amt)
|
|
|
|
|
|
|
|
|
|
// Alice signs for this HTLC and neither perspective should change.
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -9962,7 +9989,7 @@ func testGetDustSum(t *testing.T, chantype channeldb.ChannelType) {
|
|
|
|
|
|
|
|
|
|
// The rest of the dance is completed and neither perspective should
|
|
|
|
|
// change.
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -10764,7 +10791,7 @@ func TestAsynchronousSendingContraint(t *testing.T) {
|
|
|
|
|
// Bob signs the new state for alice, which ONLY has his htlc on it
|
|
|
|
|
// because he only includes acked updates of alice.
|
|
|
|
|
// <----sig-------|---------------
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment()
|
|
|
|
|
bobNewCommit, err := bobChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
|
|
|
|
@ -10780,7 +10807,7 @@ func TestAsynchronousSendingContraint(t *testing.T) {
|
|
|
|
|
// incoming htlc in her commitment sig to bob, but this will dip her
|
|
|
|
|
// local balance below her reserve because she already used everything
|
|
|
|
|
// up when adding her htlc.
|
|
|
|
|
_, err = aliceChannel.SignNextCommitment()
|
|
|
|
|
_, err = aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.ErrorIs(t, err, ErrBelowChanReserve)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -10905,7 +10932,7 @@ func TestAsynchronousSendingWithFeeBuffer(t *testing.T) {
|
|
|
|
|
// Force a state transition, this will lock-in the htlc of bob.
|
|
|
|
|
// ------sig-----> (includes bob's htlc)
|
|
|
|
|
// <----rev------ (locks in bob's htlc for alice)
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceNewCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = bobChannel.ReceiveNewCommitment(aliceNewCommit.CommitSigs)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -11147,7 +11174,7 @@ func TestBlindingPointPersistence(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Now, Alice will send a new commitment to Bob, which will persist our
|
|
|
|
|
// pending HTLC to disk.
|
|
|
|
|
aliceCommit, err := aliceChannel.SignNextCommitment()
|
|
|
|
|
aliceCommit, err := aliceChannel.SignNextCommitment(testQuit)
|
|
|
|
|
require.NoError(t, err, "unable to sign commitment")
|
|
|
|
|
|
|
|
|
|
// Restart alice to force fetching state from disk.
|
|
|
|
|