Skip to content

Commit 1fd6c6f

Browse files
Merge pull request #1481 from TheBlueMatt/2022-05-new-chain-tests
Test coverage for `transaction_unconfirmed`
2 parents 3de59ce + b083870 commit 1fd6c6f

File tree

6 files changed

+182
-79
lines changed

6 files changed

+182
-79
lines changed

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn test_monitor_and_persister_update_fail() {
103103
// Because we will connect a block at height 200 below, we need the TestBroadcaster to know
104104
// that we are at height 200 so that it doesn't think we're violating the time lock
105105
// requirements of transactions broadcasted at that point.
106-
blocks: Arc::new(Mutex::new(vec![(genesis_block(Network::Testnet).header, 200); 200])),
106+
blocks: Arc::new(Mutex::new(vec![(genesis_block(Network::Testnet), 200); 200])),
107107
};
108108
let chain_mon = {
109109
let monitor = nodes[0].chain_monitor.chain_monitor.get_monitor(outpoint).unwrap();

lightning/src/ln/functional_test_utils.rs

Lines changed: 80 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -77,28 +77,60 @@ pub fn confirm_transaction_at<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, tx: &T
7777
}
7878

7979
/// The possible ways we may notify a ChannelManager of a new block
80-
#[derive(Clone, Copy, PartialEq)]
80+
#[derive(Clone, Copy, Debug, PartialEq)]
8181
pub enum ConnectStyle {
82-
/// Calls best_block_updated first, detecting transactions in the block only after receiving the
83-
/// header and height information.
82+
/// Calls `best_block_updated` first, detecting transactions in the block only after receiving
83+
/// the header and height information.
8484
BestBlockFirst,
85-
/// The same as BestBlockFirst, however when we have multiple blocks to connect, we only
86-
/// make a single best_block_updated call.
85+
/// The same as `BestBlockFirst`, however when we have multiple blocks to connect, we only
86+
/// make a single `best_block_updated` call.
8787
BestBlockFirstSkippingBlocks,
88-
/// Calls transactions_confirmed first, detecting transactions in the block before updating the
89-
/// header and height information.
88+
/// The same as `BestBlockFirst` when connecting blocks. During disconnection only
89+
/// `transaction_unconfirmed` is called.
90+
BestBlockFirstReorgsOnlyTip,
91+
/// Calls `transactions_confirmed` first, detecting transactions in the block before updating
92+
/// the header and height information.
9093
TransactionsFirst,
91-
/// The same as TransactionsFirst, however when we have multiple blocks to connect, we only
92-
/// make a single best_block_updated call.
94+
/// The same as `TransactionsFirst`, however when we have multiple blocks to connect, we only
95+
/// make a single `best_block_updated` call.
9396
TransactionsFirstSkippingBlocks,
94-
/// Provides the full block via the chain::Listen interface. In the current code this is
95-
/// equivalent to TransactionsFirst with some additional assertions.
97+
/// The same as `TransactionsFirst` when connecting blocks. During disconnection only
98+
/// `transaction_unconfirmed` is called.
99+
TransactionsFirstReorgsOnlyTip,
100+
/// Provides the full block via the `chain::Listen` interface. In the current code this is
101+
/// equivalent to `TransactionsFirst` with some additional assertions.
96102
FullBlockViaListen,
97103
}
98104

105+
impl ConnectStyle {
106+
fn random_style() -> ConnectStyle {
107+
#[cfg(feature = "std")] {
108+
use core::hash::{BuildHasher, Hasher};
109+
// Get a random value using the only std API to do so - the DefaultHasher
110+
let rand_val = std::collections::hash_map::RandomState::new().build_hasher().finish();
111+
let res = match rand_val % 7 {
112+
0 => ConnectStyle::BestBlockFirst,
113+
1 => ConnectStyle::BestBlockFirstSkippingBlocks,
114+
2 => ConnectStyle::BestBlockFirstReorgsOnlyTip,
115+
3 => ConnectStyle::TransactionsFirst,
116+
4 => ConnectStyle::TransactionsFirstSkippingBlocks,
117+
5 => ConnectStyle::TransactionsFirstReorgsOnlyTip,
118+
6 => ConnectStyle::FullBlockViaListen,
119+
_ => unreachable!(),
120+
};
121+
eprintln!("Using Block Connection Style: {:?}", res);
122+
res
123+
}
124+
#[cfg(not(feature = "std"))] {
125+
ConnectStyle::FullBlockViaListen
126+
}
127+
}
128+
}
129+
99130
pub fn connect_blocks<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, depth: u32) -> BlockHash {
100131
let skip_intermediaries = match *node.connect_style.borrow() {
101-
ConnectStyle::BestBlockFirstSkippingBlocks|ConnectStyle::TransactionsFirstSkippingBlocks => true,
132+
ConnectStyle::BestBlockFirstSkippingBlocks|ConnectStyle::TransactionsFirstSkippingBlocks|
133+
ConnectStyle::BestBlockFirstReorgsOnlyTip|ConnectStyle::TransactionsFirstReorgsOnlyTip => true,
102134
_ => false,
103135
};
104136

@@ -109,18 +141,20 @@ pub fn connect_blocks<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, depth: u32) ->
109141
};
110142
assert!(depth >= 1);
111143
for i in 1..depth {
112-
do_connect_block(node, &block, skip_intermediaries);
144+
let prev_blockhash = block.header.block_hash();
145+
do_connect_block(node, block, skip_intermediaries);
113146
block = Block {
114-
header: BlockHeader { version: 0x20000000, prev_blockhash: block.header.block_hash(), merkle_root: Default::default(), time: height + i, bits: 42, nonce: 42 },
147+
header: BlockHeader { version: 0x20000000, prev_blockhash, merkle_root: Default::default(), time: height + i, bits: 42, nonce: 42 },
115148
txdata: vec![],
116149
};
117150
}
118-
connect_block(node, &block);
119-
block.header.block_hash()
151+
let hash = block.header.block_hash();
152+
do_connect_block(node, block, false);
153+
hash
120154
}
121155

122156
pub fn connect_block<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, block: &Block) {
123-
do_connect_block(node, block, false);
157+
do_connect_block(node, block.clone(), false);
124158
}
125159

126160
fn call_claimable_balances<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>) {
@@ -130,20 +164,23 @@ fn call_claimable_balances<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>) {
130164
}
131165
}
132166

133-
fn do_connect_block<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, block: &Block, skip_intermediaries: bool) {
167+
fn do_connect_block<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, block: Block, skip_intermediaries: bool) {
134168
call_claimable_balances(node);
135169
let height = node.best_block_info().1 + 1;
170+
#[cfg(feature = "std")] {
171+
eprintln!("Connecting block using Block Connection Style: {:?}", *node.connect_style.borrow());
172+
}
136173
if !skip_intermediaries {
137174
let txdata: Vec<_> = block.txdata.iter().enumerate().collect();
138175
match *node.connect_style.borrow() {
139-
ConnectStyle::BestBlockFirst|ConnectStyle::BestBlockFirstSkippingBlocks => {
176+
ConnectStyle::BestBlockFirst|ConnectStyle::BestBlockFirstSkippingBlocks|ConnectStyle::BestBlockFirstReorgsOnlyTip => {
140177
node.chain_monitor.chain_monitor.best_block_updated(&block.header, height);
141178
call_claimable_balances(node);
142179
node.chain_monitor.chain_monitor.transactions_confirmed(&block.header, &txdata, height);
143180
node.node.best_block_updated(&block.header, height);
144181
node.node.transactions_confirmed(&block.header, &txdata, height);
145182
},
146-
ConnectStyle::TransactionsFirst|ConnectStyle::TransactionsFirstSkippingBlocks => {
183+
ConnectStyle::TransactionsFirst|ConnectStyle::TransactionsFirstSkippingBlocks|ConnectStyle::TransactionsFirstReorgsOnlyTip => {
147184
node.chain_monitor.chain_monitor.transactions_confirmed(&block.header, &txdata, height);
148185
call_claimable_balances(node);
149186
node.chain_monitor.chain_monitor.best_block_updated(&block.header, height);
@@ -158,30 +195,39 @@ fn do_connect_block<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, block: &Block, s
158195
}
159196
call_claimable_balances(node);
160197
node.node.test_process_background_events();
161-
node.blocks.lock().unwrap().push((block.header, height));
198+
node.blocks.lock().unwrap().push((block, height));
162199
}
163200

164201
pub fn disconnect_blocks<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, count: u32) {
165202
call_claimable_balances(node);
203+
#[cfg(feature = "std")] {
204+
eprintln!("Disconnecting {} blocks using Block Connection Style: {:?}", count, *node.connect_style.borrow());
205+
}
166206
for i in 0..count {
167-
let orig_header = node.blocks.lock().unwrap().pop().unwrap();
168-
assert!(orig_header.1 > 0); // Cannot disconnect genesis
169-
let prev_header = node.blocks.lock().unwrap().last().unwrap().clone();
207+
let orig = node.blocks.lock().unwrap().pop().unwrap();
208+
assert!(orig.1 > 0); // Cannot disconnect genesis
209+
let prev = node.blocks.lock().unwrap().last().unwrap().clone();
170210

171211
match *node.connect_style.borrow() {
172212
ConnectStyle::FullBlockViaListen => {
173-
node.chain_monitor.chain_monitor.block_disconnected(&orig_header.0, orig_header.1);
174-
Listen::block_disconnected(node.node, &orig_header.0, orig_header.1);
213+
node.chain_monitor.chain_monitor.block_disconnected(&orig.0.header, orig.1);
214+
Listen::block_disconnected(node.node, &orig.0.header, orig.1);
175215
},
176216
ConnectStyle::BestBlockFirstSkippingBlocks|ConnectStyle::TransactionsFirstSkippingBlocks => {
177217
if i == count - 1 {
178-
node.chain_monitor.chain_monitor.best_block_updated(&prev_header.0, prev_header.1);
179-
node.node.best_block_updated(&prev_header.0, prev_header.1);
218+
node.chain_monitor.chain_monitor.best_block_updated(&prev.0.header, prev.1);
219+
node.node.best_block_updated(&prev.0.header, prev.1);
220+
}
221+
},
222+
ConnectStyle::BestBlockFirstReorgsOnlyTip|ConnectStyle::TransactionsFirstReorgsOnlyTip => {
223+
for tx in orig.0.txdata {
224+
node.chain_monitor.chain_monitor.transaction_unconfirmed(&tx.txid());
225+
node.node.transaction_unconfirmed(&tx.txid());
180226
}
181227
},
182228
_ => {
183-
node.chain_monitor.chain_monitor.best_block_updated(&prev_header.0, prev_header.1);
184-
node.node.best_block_updated(&prev_header.0, prev_header.1);
229+
node.chain_monitor.chain_monitor.best_block_updated(&prev.0.header, prev.1);
230+
node.node.best_block_updated(&prev.0.header, prev.1);
185231
},
186232
}
187233
call_claimable_balances(node);
@@ -227,7 +273,7 @@ pub struct Node<'a, 'b: 'a, 'c: 'b> {
227273
pub network_payment_count: Rc<RefCell<u8>>,
228274
pub network_chan_count: Rc<RefCell<u32>>,
229275
pub logger: &'c test_utils::TestLogger,
230-
pub blocks: Arc<Mutex<Vec<(BlockHeader, u32)>>>,
276+
pub blocks: Arc<Mutex<Vec<(Block, u32)>>>,
231277
pub connect_style: Rc<RefCell<ConnectStyle>>,
232278
}
233279
impl<'a, 'b, 'c> Node<'a, 'b, 'c> {
@@ -238,7 +284,7 @@ impl<'a, 'b, 'c> Node<'a, 'b, 'c> {
238284
self.blocks.lock().unwrap().last().map(|(a, b)| (a.block_hash(), *b)).unwrap()
239285
}
240286
pub fn get_block_header(&self, height: u32) -> BlockHeader {
241-
self.blocks.lock().unwrap()[height as usize].0
287+
self.blocks.lock().unwrap()[height as usize].0.header
242288
}
243289
}
244290

@@ -1821,7 +1867,7 @@ pub fn create_chanmon_cfgs(node_count: usize) -> Vec<TestChanMonCfg> {
18211867
for i in 0..node_count {
18221868
let tx_broadcaster = test_utils::TestBroadcaster {
18231869
txn_broadcasted: Mutex::new(Vec::new()),
1824-
blocks: Arc::new(Mutex::new(vec![(genesis_block(Network::Testnet).header, 0)])),
1870+
blocks: Arc::new(Mutex::new(vec![(genesis_block(Network::Testnet), 0)])),
18251871
};
18261872
let fee_estimator = test_utils::TestFeeEstimator { sat_per_kw: Mutex::new(253) };
18271873
let chain_source = test_utils::TestChainSource::new(Network::Testnet);
@@ -1895,7 +1941,7 @@ pub fn create_network<'a, 'b: 'a, 'c: 'b>(node_count: usize, cfgs: &'b Vec<NodeC
18951941
let mut nodes = Vec::new();
18961942
let chan_count = Rc::new(RefCell::new(0));
18971943
let payment_count = Rc::new(RefCell::new(0));
1898-
let connect_style = Rc::new(RefCell::new(ConnectStyle::FullBlockViaListen));
1944+
let connect_style = Rc::new(RefCell::new(ConnectStyle::random_style()));
18991945

19001946
for i in 0..node_count {
19011947
let net_graph_msg_handler = NetGraphMsgHandler::new(cfgs[i].network_graph, None, cfgs[i].logger);

lightning/src/ln/functional_tests.rs

Lines changed: 68 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,23 +1280,41 @@ fn test_duplicate_htlc_different_direction_onchain() {
12801280
check_closed_event!(nodes[0], 1, ClosureReason::CommitmentTxConfirmed);
12811281
connect_blocks(&nodes[0], TEST_FINAL_CLTV - 1); // Confirm blocks until the HTLC expires
12821282

1283-
// Check we only broadcast 1 timeout tx
12841283
let claim_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().clone();
12851284
assert_eq!(claim_txn.len(), 8);
1286-
assert_eq!(claim_txn[1], claim_txn[4]);
1287-
assert_eq!(claim_txn[2], claim_txn[5]);
1288-
check_spends!(claim_txn[1], chan_1.3);
1289-
check_spends!(claim_txn[2], claim_txn[1]);
1290-
check_spends!(claim_txn[7], claim_txn[1]);
1285+
1286+
check_spends!(claim_txn[0], remote_txn[0]); // Immediate HTLC claim with preimage
1287+
1288+
check_spends!(claim_txn[1], chan_1.3); // Alternative commitment tx
1289+
check_spends!(claim_txn[2], claim_txn[1]); // HTLC spend in alternative commitment tx
1290+
1291+
let bump_tx = if claim_txn[1] == claim_txn[4] {
1292+
assert_eq!(claim_txn[1], claim_txn[4]);
1293+
assert_eq!(claim_txn[2], claim_txn[5]);
1294+
1295+
check_spends!(claim_txn[7], claim_txn[1]); // HTLC timeout on alternative commitment tx
1296+
1297+
check_spends!(claim_txn[3], remote_txn[0]); // HTLC timeout on broadcasted commitment tx
1298+
&claim_txn[3]
1299+
} else {
1300+
assert_eq!(claim_txn[1], claim_txn[3]);
1301+
assert_eq!(claim_txn[2], claim_txn[4]);
1302+
1303+
check_spends!(claim_txn[5], claim_txn[1]); // HTLC timeout on alternative commitment tx
1304+
1305+
check_spends!(claim_txn[7], remote_txn[0]); // HTLC timeout on broadcasted commitment tx
1306+
1307+
&claim_txn[7]
1308+
};
12911309

12921310
assert_eq!(claim_txn[0].input.len(), 1);
1293-
assert_eq!(claim_txn[3].input.len(), 1);
1294-
assert_eq!(claim_txn[0].input[0].previous_output, claim_txn[3].input[0].previous_output);
1311+
assert_eq!(bump_tx.input.len(), 1);
1312+
assert_eq!(claim_txn[0].input[0].previous_output, bump_tx.input[0].previous_output);
12951313

12961314
assert_eq!(claim_txn[0].input.len(), 1);
12971315
assert_eq!(claim_txn[0].input[0].witness.last().unwrap().len(), OFFERED_HTLC_SCRIPT_WEIGHT); // HTLC 1 <--> 0, preimage tx
1298-
check_spends!(claim_txn[0], remote_txn[0]);
12991316
assert_eq!(remote_txn[0].output[claim_txn[0].input[0].previous_output.vout as usize].value, 800);
1317+
13001318
assert_eq!(claim_txn[6].input.len(), 1);
13011319
assert_eq!(claim_txn[6].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT); // HTLC 0 <--> 1, timeout tx
13021320
check_spends!(claim_txn[6], remote_txn[0]);
@@ -2351,7 +2369,8 @@ fn test_justice_tx() {
23512369
chanmon_cfgs[1].keys_manager.disable_revocation_policy_check = true;
23522370
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
23532371
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &user_cfgs);
2354-
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
2372+
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
2373+
*nodes[0].connect_style.borrow_mut() = ConnectStyle::FullBlockViaListen;
23552374
// Create some new channels:
23562375
let chan_5 = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
23572376

@@ -2583,11 +2602,7 @@ fn claim_htlc_outputs_single_tx() {
25832602
expect_payment_failed!(nodes[1], payment_hash_2, true);
25842603

25852604
let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
2586-
assert_eq!(node_txn.len(), 9);
2587-
// ChannelMonitor: justice tx revoked offered htlc, justice tx revoked received htlc, justice tx revoked to_local (3)
2588-
// ChannelManager: local commmitment + local HTLC-timeout (2)
2589-
// ChannelMonitor: bumped justice tx, after one increase, bumps on HTLC aren't generated not being substantial anymore, bump on revoked to_local isn't generated due to more room for expiration (2)
2590-
// ChannelMonitor: local commitment + local HTLC-timeout (2)
2605+
assert!(node_txn.len() == 9 || node_txn.len() == 10);
25912606

25922607
// Check the pair local commitment and HTLC-timeout broadcast due to HTLC expiration
25932608
assert_eq!(node_txn[0].input.len(), 1);
@@ -5286,21 +5301,30 @@ fn test_duplicate_payment_hash_one_failure_one_success() {
52865301
let htlc_timeout_tx;
52875302
{ // Extract one of the two HTLC-Timeout transaction
52885303
let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
5289-
// ChannelMonitor: timeout tx * 3, ChannelManager: local commitment tx
5290-
assert_eq!(node_txn.len(), 4);
5304+
// ChannelMonitor: timeout tx * 2-or-3, ChannelManager: local commitment tx
5305+
assert!(node_txn.len() == 4 || node_txn.len() == 3);
52915306
check_spends!(node_txn[0], chan_2.3);
52925307

52935308
check_spends!(node_txn[1], commitment_txn[0]);
52945309
assert_eq!(node_txn[1].input.len(), 1);
5295-
check_spends!(node_txn[2], commitment_txn[0]);
5296-
assert_eq!(node_txn[2].input.len(), 1);
5297-
assert_eq!(node_txn[1].input[0].previous_output, node_txn[2].input[0].previous_output);
5298-
check_spends!(node_txn[3], commitment_txn[0]);
5299-
assert_ne!(node_txn[1].input[0].previous_output, node_txn[3].input[0].previous_output);
5310+
5311+
if node_txn.len() > 3 {
5312+
check_spends!(node_txn[2], commitment_txn[0]);
5313+
assert_eq!(node_txn[2].input.len(), 1);
5314+
assert_eq!(node_txn[1].input[0].previous_output, node_txn[2].input[0].previous_output);
5315+
5316+
check_spends!(node_txn[3], commitment_txn[0]);
5317+
assert_ne!(node_txn[1].input[0].previous_output, node_txn[3].input[0].previous_output);
5318+
} else {
5319+
check_spends!(node_txn[2], commitment_txn[0]);
5320+
assert_ne!(node_txn[1].input[0].previous_output, node_txn[2].input[0].previous_output);
5321+
}
53005322

53015323
assert_eq!(node_txn[1].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT);
53025324
assert_eq!(node_txn[2].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT);
5303-
assert_eq!(node_txn[3].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT);
5325+
if node_txn.len() > 3 {
5326+
assert_eq!(node_txn[3].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT);
5327+
}
53045328
htlc_timeout_tx = node_txn[1].clone();
53055329
}
53065330

@@ -7960,13 +7984,24 @@ fn test_bump_penalty_txn_on_remote_commitment() {
79607984
assert_eq!(node_txn[6].input.len(), 1);
79617985
check_spends!(node_txn[0], remote_txn[0]);
79627986
check_spends!(node_txn[6], remote_txn[0]);
7963-
assert_eq!(node_txn[0].input[0].previous_output, node_txn[3].input[0].previous_output);
7964-
preimage_bump = node_txn[3].clone();
79657987

79667988
check_spends!(node_txn[1], chan.3);
79677989
check_spends!(node_txn[2], node_txn[1]);
7968-
assert_eq!(node_txn[1], node_txn[4]);
7969-
assert_eq!(node_txn[2], node_txn[5]);
7990+
7991+
if node_txn[0].input[0].previous_output == node_txn[3].input[0].previous_output {
7992+
preimage_bump = node_txn[3].clone();
7993+
check_spends!(node_txn[3], remote_txn[0]);
7994+
7995+
assert_eq!(node_txn[1], node_txn[4]);
7996+
assert_eq!(node_txn[2], node_txn[5]);
7997+
} else {
7998+
preimage_bump = node_txn[7].clone();
7999+
check_spends!(node_txn[7], remote_txn[0]);
8000+
assert_eq!(node_txn[0].input[0].previous_output, node_txn[7].input[0].previous_output);
8001+
8002+
assert_eq!(node_txn[1], node_txn[3]);
8003+
assert_eq!(node_txn[2], node_txn[4]);
8004+
}
79708005

79718006
timeout = node_txn[6].txid();
79728007
let index = node_txn[6].input[0].previous_output.vout;
@@ -8714,10 +8749,11 @@ fn test_update_err_monitor_lockdown() {
87148749
watchtower
87158750
};
87168751
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
8752+
let block = Block { header, txdata: vec![] };
87178753
// Make the tx_broadcaster aware of enough blocks that it doesn't think we're violating
87188754
// transaction lock time requirements here.
8719-
chanmon_cfgs[0].tx_broadcaster.blocks.lock().unwrap().resize(200, (header, 0));
8720-
watchtower.chain_monitor.block_connected(&Block { header, txdata: vec![] }, 200);
8755+
chanmon_cfgs[0].tx_broadcaster.blocks.lock().unwrap().resize(200, (block.clone(), 0));
8756+
watchtower.chain_monitor.block_connected(&block, 200);
87218757

87228758
// Try to update ChannelMonitor
87238759
assert!(nodes[1].node.claim_funds(preimage));
@@ -8775,10 +8811,11 @@ fn test_concurrent_monitor_claim() {
87758811
watchtower
87768812
};
87778813
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
8814+
let block = Block { header, txdata: vec![] };
87788815
// Make the tx_broadcaster aware of enough blocks that it doesn't think we're violating
87798816
// transaction lock time requirements here.
8780-
chanmon_cfgs[0].tx_broadcaster.blocks.lock().unwrap().resize((CHAN_CONFIRM_DEPTH + 1 + TEST_FINAL_CLTV + LATENCY_GRACE_PERIOD_BLOCKS) as usize, (header, 0));
8781-
watchtower_alice.chain_monitor.block_connected(&Block { header, txdata: vec![] }, CHAN_CONFIRM_DEPTH + 1 + TEST_FINAL_CLTV + LATENCY_GRACE_PERIOD_BLOCKS);
8817+
chanmon_cfgs[0].tx_broadcaster.blocks.lock().unwrap().resize((CHAN_CONFIRM_DEPTH + 1 + TEST_FINAL_CLTV + LATENCY_GRACE_PERIOD_BLOCKS) as usize, (block.clone(), 0));
8818+
watchtower_alice.chain_monitor.block_connected(&block, CHAN_CONFIRM_DEPTH + 1 + TEST_FINAL_CLTV + LATENCY_GRACE_PERIOD_BLOCKS);
87828819

87838820
// Watchtower Alice should have broadcast a commitment/HTLC-timeout
87848821
{

0 commit comments

Comments
 (0)