Skip to content

Commit a351e04

Browse files
author
Antoine Riard
committed
Add test for onchain resolution of channel with a success, passing
preimage backwards.
1 parent 10baa3d commit a351e04

File tree

1 file changed

+0
-43
lines changed

1 file changed

+0
-43
lines changed

src/ln/channelmanager.rs

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3564,49 +3564,6 @@ mod tests {
35643564
}
35653565
}
35663566

3567-
//#[test]
3568-
fn test_htlc_on_chain_timeout() {
3569-
// Test that in case of an unilateral close onchain, we detect the state of HTLC (timeout) thanks to
3570-
// ChainWtachInterface and pass the timeout backward
3571-
// A -------> B --------> C --------> D (timeout)
3572-
// output input
3573-
3574-
let nodes = create_network(4);
3575-
3576-
// Create some initial channels
3577-
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1);
3578-
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2);
3579-
let chan_3 = create_announced_chan_between_nodes(&nodes, 2, 3);
3580-
3581-
// Rebalance the network a bit by relaying one payment through all the channels...
3582-
send_payment(&nodes[0], &vec!(&nodes[1], &nodes[2], &nodes[3])[..], 8000000);
3583-
send_payment(&nodes[0], &vec!(&nodes[1], &nodes[2], &nodes[3])[..], 8000000);
3584-
send_payment(&nodes[0], &vec!(&nodes[1], &nodes[2], &nodes[3])[..], 8000000);
3585-
3586-
let (payment_preimage, payment_hash) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2], &nodes[3]), 3000000);
3587-
3588-
// broadcast legit commitment tx from D on C's chain
3589-
let commitment_tx = nodes[3].node.channel_state.lock().unwrap().by_id.get(&chan_3.2).unwrap().last_local_commitment_txn.clone();
3590-
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42};
3591-
3592-
// broadcast timeout tx on received
3593-
nodes[2].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![commitment_tx[0].clone()]}, 1);
3594-
test_txn_broadcast(&nodes[2], &chan_3, Some(commitment_tx[0].clone()), HTLCType::TIMEOUT);
3595-
let events = nodes[2].node.get_and_clear_pending_events();
3596-
assert_eq!(events.len(), 1); //should be an UpdateFailHTLC event, verify it
3597-
3598-
let commitment_tx = nodes[1].node.channel_state.lock().unwrap().by_id.get(&chan_2.2).unwrap().last_local_commitment_txn.clone();
3599-
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42};
3600-
nodes[1].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![commitment_tx[0].clone()]}, 200);
3601-
let node_txn = test_txn_broadcast(&nodes[1], &chan_3, Some(commitment_tx[0].clone()), HTLCType::TIMEOUT);
3602-
let events = nodes[1].node.get_and_clear_pending_events();
3603-
assert_eq!(events.len(), 1); //should be an UpdateFailHTLC event, verify it
3604-
3605-
3606-
//assert!(nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &events[0].updates.update_fulfill_htlcs[0]).is_ok());
3607-
}
3608-
3609-
#[test]
36103567
fn test_htlc_ignore_latest_remote_commitment() {
36113568
// Test that HTLC transactions spending the latest remote commitment transaction are simply
36123569
// ignored if we cannot claim them. This originally tickled an invalid unwrap().

0 commit comments

Comments
 (0)