Skip to content

Commit 88c301c

Browse files
committed
Test transaction watch registration in channelmonitor tests
1 parent a611ae4 commit 88c301c

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/ln/channelmanager.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,7 +1839,7 @@ mod tests {
18391839
use bitcoin::util::misc::hex_bytes;
18401840
use bitcoin::util::hash::Sha256dHash;
18411841
use bitcoin::util::uint::Uint256;
1842-
use bitcoin::blockdata::block::BlockHeader;
1842+
use bitcoin::blockdata::block::{Block, BlockHeader};
18431843
use bitcoin::blockdata::transaction::{Transaction, TxOut};
18441844
use bitcoin::network::constants::Network;
18451845
use bitcoin::network::serialize::serialize;
@@ -2010,6 +2010,7 @@ mod tests {
20102010
}
20112011

20122012
fn confirm_transaction(chain: &chaininterface::ChainWatchInterfaceUtil, tx: &Transaction, chan_id: u32) {
2013+
assert!(chain.does_match_tx(tx));
20132014
let mut header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
20142015
chain.block_connected_checked(&header, 1, &[tx; 1], &[chan_id; 1]);
20152016
for i in 2..100 {
@@ -2792,9 +2793,9 @@ mod tests {
27922793
// Simple case with no pending HTLCs:
27932794
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), true);
27942795
{
2795-
let node_txn = test_txn_broadcast(&nodes[1], &chan_1, None, HTLCType::NONE);
2796+
let mut node_txn = test_txn_broadcast(&nodes[1], &chan_1, None, HTLCType::NONE);
27962797
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
2797-
nodes[0].chain_monitor.block_connected_checked(&header, 1, &[&node_txn[0]; 1], &[4; 1]);
2798+
nodes[0].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![node_txn.drain(..).next().unwrap()] }, 1);
27982799
assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().len(), 0);
27992800
}
28002801
get_announce_close_broadcast_events(&nodes, 0, 1);
@@ -2807,9 +2808,9 @@ mod tests {
28072808
// Simple case of one pending HTLC to HTLC-Timeout
28082809
nodes[1].node.peer_disconnected(&nodes[2].node.get_our_node_id(), true);
28092810
{
2810-
let node_txn = test_txn_broadcast(&nodes[1], &chan_2, None, HTLCType::TIMEOUT);
2811+
let mut node_txn = test_txn_broadcast(&nodes[1], &chan_2, None, HTLCType::TIMEOUT);
28112812
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
2812-
nodes[2].chain_monitor.block_connected_checked(&header, 1, &[&node_txn[0]; 1], &[4; 1]);
2813+
nodes[2].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![node_txn.drain(..).next().unwrap()] }, 1);
28132814
assert_eq!(nodes[2].tx_broadcaster.txn_broadcasted.lock().unwrap().len(), 0);
28142815
}
28152816
get_announce_close_broadcast_events(&nodes, 1, 2);
@@ -2848,7 +2849,7 @@ mod tests {
28482849
claim_funds!(nodes[3], nodes[2], payment_preimage_1);
28492850

28502851
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
2851-
nodes[3].chain_monitor.block_connected_checked(&header, 1, &[&node_txn[0]; 1], &[4; 1]);
2852+
nodes[3].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![node_txn[0].clone()] }, 1);
28522853

28532854
check_preimage_claim(&nodes[3], &node_txn);
28542855
}
@@ -2882,7 +2883,7 @@ mod tests {
28822883
test_txn_broadcast(&nodes[4], &chan_4, None, HTLCType::SUCCESS);
28832884

28842885
header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
2885-
nodes[4].chain_monitor.block_connected_checked(&header, TEST_FINAL_CLTV - 5, &[&node_txn[0]; 1], &[4; 1]);
2886+
nodes[4].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![node_txn[0].clone()] }, TEST_FINAL_CLTV - 5);
28862887

28872888
check_preimage_claim(&nodes[4], &node_txn);
28882889
}
@@ -2902,7 +2903,7 @@ mod tests {
29022903

29032904
{
29042905
let mut header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
2905-
nodes[1].chain_monitor.block_connected_checked(&header, 1, &vec![&revoked_local_txn[0]; 1], &[4; 1]);
2906+
nodes[1].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1);
29062907
{
29072908
let mut node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
29082909
assert_eq!(node_txn.len(), 1);
@@ -2914,10 +2915,10 @@ mod tests {
29142915
node_txn.clear();
29152916
}
29162917

2917-
nodes[0].chain_monitor.block_connected_checked(&header, 1, &vec![&revoked_local_txn[0]; 1], &[4; 0]);
2918+
nodes[0].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1);
29182919
let node_txn = test_txn_broadcast(&nodes[0], &chan_5, Some(revoked_local_txn[0].clone()), HTLCType::TIMEOUT);
29192920
header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
2920-
nodes[1].chain_monitor.block_connected_checked(&header, 1, &[&node_txn[1]; 1], &[4; 1]);
2921+
nodes[1].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![node_txn[1].clone()] }, 1);
29212922

29222923
//TODO: At this point nodes[1] should claim the revoked HTLC-Timeout output, but that's
29232924
//not yet implemented in ChannelMonitor

0 commit comments

Comments
 (0)