Skip to content

Commit

Permalink
Fix race condition in integration test (#1564)
Browse files Browse the repository at this point in the history
In the revoked commit tx case, both nodes are competing to claim the
HTLC outputs from the commit tx.

The test incorrectly assumed that node F would always win that race.
  • Loading branch information
t-bast authored Oct 15, 2020
1 parent 131b2e0 commit bffb7a3
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,11 @@ class AnchorOutputChannelIntegrationSpec extends ChannelIntegrationSpec {
sender.expectMsg(revokedCommitTx.txid)
// get the revoked commitment confirmed: now HTLC txs can be published
generateBlocks(bitcoincli, 2)
bitcoinClient.publishTransaction(htlcSuccess.head).pipeTo(sender.ref)
sender.expectMsg(htlcSuccess.head.txid)
bitcoinClient.publishTransaction(htlcTimeout.head).pipeTo(sender.ref)
sender.expectMsg(htlcTimeout.head.txid)
// NB: The test cannot be deterministic because there is a race between C and F here; C may publish more quickly and
// claim the HTLC outputs directly from the commit tx. As a result we may have different combinations of transactions
// if the test is run several times. It's okay, we just need to make sure that the test never fails.
bitcoinClient.publishTransaction(htlcSuccess.head)
bitcoinClient.publishTransaction(htlcTimeout.head)
// at this point C should have 6 recv transactions: its previous main output, F's main output and all htlc outputs (taken as punishment)
awaitCond({
val receivedByC = listReceivedByAddress(finalAddressC, sender)
Expand Down

0 comments on commit bffb7a3

Please sign in to comment.