mirror of https://github.com/BTCPrivate/lnd.git
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:
parent
a1e2560b12
commit
f8adab1f1c
|
@ -42,6 +42,8 @@ const (
|
||||||
defaultNoEncryptWallet = false
|
defaultNoEncryptWallet = false
|
||||||
defaultTrickleDelay = 30 * 1000
|
defaultTrickleDelay = 30 * 1000
|
||||||
|
|
||||||
|
defaultBroadcastDelta = 10
|
||||||
|
|
||||||
// minTimeLockDelta is the minimum timelock we require for incoming
|
// minTimeLockDelta is the minimum timelock we require for incoming
|
||||||
// HTLCs on our channels.
|
// HTLCs on our channels.
|
||||||
minTimeLockDelta = 4
|
minTimeLockDelta = 4
|
||||||
|
|
|
@ -1345,7 +1345,7 @@ func (c *commitSweepResolver) Resolve() (ContractResolver, error) {
|
||||||
return nil, fmt.Errorf("quitting")
|
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)
|
c.chanPoint, confInfo.BlockHeight)
|
||||||
|
|
||||||
case <-c.Quit:
|
case <-c.Quit:
|
||||||
|
|
|
@ -941,9 +941,13 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
|
||||||
// add it to to our preimage cache. By doing this, we ensure
|
// add it to to our preimage cache. By doing this, we ensure
|
||||||
// any contested contracts watched by any on-chain arbitrators
|
// any contested contracts watched by any on-chain arbitrators
|
||||||
// can now sweep this HTLC on-chain.
|
// can now sweep this HTLC on-chain.
|
||||||
if err := l.cfg.PreimageCache.AddPreimage(pre[:]); err != nil {
|
go func() {
|
||||||
log.Errorf("unable to add preimage=%x to cache", pre[:])
|
err := l.cfg.PreimageCache.AddPreimage(pre[:])
|
||||||
}
|
if err != nil {
|
||||||
|
log.Errorf("unable to add preimage=%x to "+
|
||||||
|
"cache", pre[:])
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
case *lnwire.UpdateFailMalformedHTLC:
|
case *lnwire.UpdateFailMalformedHTLC:
|
||||||
// Convert the failure type encoded within the HTLC fail
|
// Convert the failure type encoded within the HTLC fail
|
||||||
|
|
1397
lnd_test.go
1397
lnd_test.go
File diff suppressed because it is too large
Load Diff
|
@ -238,7 +238,8 @@ func TestPeerChannelClosureFeeNegotiationsResponder(t *testing.T) {
|
||||||
broadcastTxChan := make(chan *wire.MsgTx)
|
broadcastTxChan := make(chan *wire.MsgTx)
|
||||||
|
|
||||||
responder, responderChan, initiatorChan, cleanUp, err := createTestPeer(
|
responder, responderChan, initiatorChan, cleanUp, err := createTestPeer(
|
||||||
notifier, broadcastTxChan)
|
notifier, broadcastTxChan,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create test channels: %v", err)
|
t.Fatalf("unable to create test channels: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue