mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 01:36:24 +01:00
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
5 changed files with 1399 additions and 15 deletions
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
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)
|
||||
|
||||
responder, responderChan, initiatorChan, cleanUp, err := createTestPeer(
|
||||
notifier, broadcastTxChan)
|
||||
notifier, broadcastTxChan,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test channels: %v", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue