test: add comprehensive integration tests for on-chain HTLC handling

In this commit, we add 6 new integration tests to test the various
actions that may need to be performed when either side goes on-chain to
fully resolve HTLC’s. Many of the tests are mirrors of each other as
they test sweeping/resolving HTLC’s from both commitment transactions.
This commit is contained in:
Olaoluwa Osuntokun committed 2018-01-22 19:20:02 -08:00
1 parent a1e2560b12
commit f8adab1f1c
5 files changed
+1399 -15

No files matched your search

+2
View File
@@ -42,6 +42,8 @@ const (
defaultNoEncryptWallet = false
defaultTrickleDelay = 30 * 1000
defaultBroadcastDelta = 10
// minTimeLockDelta is the minimum timelock we require for incoming
// HTLCs on our channels.
minTimeLockDelta = 4
+1 -1
View File
@@ -1345,7 +1345,7 @@ func (c *commitSweepResolver) Resolve() (ContractResolver, error) {
return nil, fmt.Errorf("quitting")
}
log.Infof("ChannelPoint(%v) is fully closed, at height: %v",
log.Infof("ChannelPoint(%v) commit tx is fully resolved, at height: %v",
c.chanPoint, confInfo.BlockHeight)
case <-c.Quit:
+7 -3
View File
@@ -941,9 +941,13 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
// add it to to our preimage cache. By doing this, we ensure
// any contested contracts watched by any on-chain arbitrators
// can now sweep this HTLC on-chain.
if err := l.cfg.PreimageCache.AddPreimage(pre[:]); err != nil {
log.Errorf("unable to add preimage=%x to cache", pre[:])
}
go func() {
err := l.cfg.PreimageCache.AddPreimage(pre[:])
if err != nil {
log.Errorf("unable to add preimage=%x to "+
"cache", pre[:])
}
}()
case *lnwire.UpdateFailMalformedHTLC:
// Convert the failure type encoded within the HTLC fail
+1387 -10
View File
File diff suppressed because it is too large. Load diff
+2 -1
View File
@@ -238,7 +238,8 @@ func TestPeerChannelClosureFeeNegotiationsResponder(t *testing.T) {
broadcastTxChan := make(chan *wire.MsgTx)
responder, responderChan, initiatorChan, cleanUp, err := createTestPeer(
notifier, broadcastTxChan)
notifier, broadcastTxChan,
)
if err != nil {
t.Fatalf("unable to create test channels: %v", err)
}