htlcswitch+peer: remove ShutdownIfChannelClean

This commit is contained in:
Keagan McClelland
2023-11-28 16:05:33 -08:00
parent 64fda6ca65
commit ec55831229
5 changed files with 0 additions and 150 deletions

View File

@ -6666,94 +6666,6 @@ func TestPendingCommitTicker(t *testing.T) {
}
}
// TestShutdownIfChannelClean tests that a link will exit the htlcManager loop
// if and only if the underlying channel state is clean.
func TestShutdownIfChannelClean(t *testing.T) {
t.Parallel()
const chanAmt = btcutil.SatoshiPerBitcoin * 5
const chanReserve = btcutil.SatoshiPerBitcoin * 1
aliceLink, bobChannel, batchTicker, start, _, err :=
newSingleLinkTestHarness(t, chanAmt, chanReserve)
require.NoError(t, err)
var (
coreLink = aliceLink.(*channelLink)
aliceMsgs = coreLink.cfg.Peer.(*mockPeer).sentMsgs
)
shutdownAssert := func(expectedErr error) {
err = aliceLink.ShutdownIfChannelClean()
if expectedErr != nil {
require.Error(t, err, expectedErr)
} else {
require.NoError(t, err)
}
}
err = start()
require.NoError(t, err)
ctx := linkTestContext{
t: t,
aliceLink: aliceLink,
bobChannel: bobChannel,
aliceMsgs: aliceMsgs,
}
// First send an HTLC from Bob to Alice and assert that the link can't
// be shutdown while the update is outstanding.
htlc := generateHtlc(t, coreLink, 0)
// <---add-----
ctx.sendHtlcBobToAlice(htlc)
// <---sig-----
ctx.sendCommitSigBobToAlice(1)
// ----rev---->
ctx.receiveRevAndAckAliceToBob()
shutdownAssert(ErrLinkFailedShutdown)
// ----sig---->
ctx.receiveCommitSigAliceToBob(1)
shutdownAssert(ErrLinkFailedShutdown)
// <---rev-----
ctx.sendRevAndAckBobToAlice()
shutdownAssert(ErrLinkFailedShutdown)
// ---settle-->
ctx.receiveSettleAliceToBob()
shutdownAssert(ErrLinkFailedShutdown)
// ----sig---->
ctx.receiveCommitSigAliceToBob(0)
shutdownAssert(ErrLinkFailedShutdown)
// <---rev-----
ctx.sendRevAndAckBobToAlice()
shutdownAssert(ErrLinkFailedShutdown)
// There is currently no controllable breakpoint between Alice
// receiving the CommitSig and her sending out the RevokeAndAck. As
// soon as the RevokeAndAck is generated, the channel becomes clean.
// This can happen right after the CommitSig is received, so there is
// no shutdown assertion here.
// <---sig-----
ctx.sendCommitSigBobToAlice(0)
// ----rev---->
ctx.receiveRevAndAckAliceToBob()
shutdownAssert(nil)
// Now that the link has exited the htlcManager loop, attempt to
// trigger the batch ticker. It should not be possible.
select {
case batchTicker <- time.Now():
t.Fatalf("expected batch ticker to be inactive")
case <-time.After(5 * time.Second):
}
}
// TestPipelineSettle tests that a link should only pipeline a settle if the
// related add is fully locked-in meaning it is on both sides' commitment txns.
func TestPipelineSettle(t *testing.T) {