Skip to content

Commit 07a0ad7

Browse files
committed
Clean up static_spendable_outputs_justice_tx_revoked_htlc_timeout_tx
Add a few comments to make it clear whats going on a bit more and don't test/confirm a bogus transaction.
1 parent e7678d4 commit 07a0ad7

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lightning/src/ln/functional_tests.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5038,23 +5038,32 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_timeout_tx() {
50385038

50395039
let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
50405040
assert_eq!(node_txn.len(), 4); // ChannelMonitor: justice tx on revoked commitment, justice tx on revoked HTLC-timeout, adjusted justice tx, ChannelManager: local commitment tx
5041+
// The first transaction generated is bogus - it spends both outputs of revoked_local_txn[0]
5042+
// including the one already spent by revoked_htlc_txn[0]. That's OK, we'll spend with valid
5043+
// transactions next...
50415044
assert_eq!(node_txn[0].input.len(), 2);
50425045
check_spends!(node_txn[0], revoked_local_txn[0]);
5046+
50435047
check_spends!(node_txn[1], chan_1.3);
5048+
50445049
assert_eq!(node_txn[2].input.len(), 1);
50455050
check_spends!(node_txn[2], revoked_htlc_txn[0]);
50465051
assert_eq!(node_txn[3].input.len(), 1);
50475052
check_spends!(node_txn[3], revoked_local_txn[0]);
50485053

50495054
let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
5050-
nodes[1].block_notifier.block_connected(&Block { header: header_1, txdata: vec![node_txn[0].clone(), node_txn[2].clone()] }, 1);
5055+
nodes[1].block_notifier.block_connected(&Block { header: header_1, txdata: vec![node_txn[2].clone(), node_txn[3].clone()] }, 1);
50515056
connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.block_hash());
50525057

5053-
// Check B's ChannelMonitor was able to generate the right spendable output descriptor
5058+
// Note that nodes[1]'s tx_broadcaster is still locked, so if we get here the channelmonitor
5059+
// didn't try to generate any new transactions.
5060+
5061+
// Check B's ChannelMonitor was able to generate the right spendable output descriptor which
5062+
// allows the user to spend the newly-confirmed outputs.
50545063
let spend_txn = check_spendable_outputs!(nodes[1], 1, node_cfgs[1].keys_manager, 100000);
50555064
assert_eq!(spend_txn.len(), 2);
5056-
check_spends!(spend_txn[0], node_txn[0]);
5057-
check_spends!(spend_txn[1], node_txn[2]);
5065+
check_spends!(spend_txn[0], node_txn[2]);
5066+
check_spends!(spend_txn[1], node_txn[3]);
50585067
}
50595068

50605069
#[test]

0 commit comments

Comments
 (0)