Skip to content

Commit a33efc9

Browse files
committed
itest: test second-level HTLC revocation in breach scenario
Add a custom-channel breach integration test that exercises revoked HTLCs which advance to second level before the honest party comes back online and sweeps them. Keep the default scenario small for normal suite runtime, but structure the itest so it can be scaled up to stress the same recovery path. Higher-count variants need additional setup discipline: the pre-breach rebalance must scale with the requested number of in-flight HTLCs, the post-settlement keysend must wait until HTLC cleanup has actually completed, and justice mining must accept the variable set of justice transactions published once more HTLCs reach second level. Make the breach test configurable through TAPD_BREACH_HODL_INVOICES_PER_SIDE while keeping the default at two HTLCs per side.
1 parent affbf4f commit a33efc9

12 files changed

Lines changed: 519 additions & 63 deletions

itest/custom_channels/assertions.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ func waitForNTxsInMempool(m *miner.HarnessMiner, n int,
367367
}
368368
}
369369

370-
// waitForAtLeastNTxsInMempool polls until finding at least n transactions
371-
// in the miner's mempool, returning all txids present.
370+
// waitForAtLeastNTxsInMempool polls until finding at least n
371+
// transactions in the miner's mempool, returning all txids present.
372372
func waitForAtLeastNTxsInMempool(m *miner.HarnessMiner, n int,
373373
timeout time.Duration) ([]*chainhash.Hash, error) {
374374

@@ -388,7 +388,8 @@ func waitForAtLeastNTxsInMempool(m *miner.HarnessMiner, n int,
388388

389389
if len(mempool) >= n {
390390
result := make(
391-
[]*chainhash.Hash, len(mempool),
391+
[]*chainhash.Hash,
392+
len(mempool),
392393
)
393394
for i := range mempool {
394395
result[i] = &mempool[i]
@@ -399,6 +400,14 @@ func waitForAtLeastNTxsInMempool(m *miner.HarnessMiner, n int,
399400
}
400401
}
401402

403+
// waitForNonEmptyMempool polls until the mempool is non-empty, then
404+
// returns a snapshot of its current contents.
405+
func waitForNonEmptyMempool(m *miner.HarnessMiner,
406+
timeout time.Duration) ([]*chainhash.Hash, error) {
407+
408+
return waitForAtLeastNTxsInMempool(m, 1, timeout)
409+
}
410+
402411
// assertTxInBlock asserts that a transaction with the given hash is included
403412
// in the block.
404413
func assertTxInBlock(t *ccHarnessTest, block *wire.MsgBlock,

0 commit comments

Comments
 (0)