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 2018-01-22 18:59:44 -08:00
parent a1e2560b12
commit f8adab1f1c
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
5 changed files with 1399 additions and 15 deletions

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

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:

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

File diff suppressed because it is too large Load Diff

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)
}