X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Ffunctional_tests.rs;h=5185acfd63dbf7b29cae0d9ff7566791d1c9f534;hb=d15b7cb86efb4d7e5cf0337b7b2fd1d68081a8d1;hp=eb6d7032fee67d7714005f807d2ac121c48a9a8d;hpb=22c367b13b7210a8ee082cc32bf175c42c16ce6c;p=rust-lightning diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index eb6d7032..5185acfd 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -558,6 +558,7 @@ fn do_test_sanity_on_in_flight_opens(steps: u8) { confirm_transaction_at(&nodes[0], &tx, 2); connect_blocks(&nodes[0], CHAN_CONFIRM_DEPTH); create_chan_between_nodes_with_value_confirm_second(&nodes[1], &nodes[0]); + expect_channel_ready_event(&nodes[0], &nodes[1].node.get_our_node_id()); } #[test] @@ -2951,26 +2952,8 @@ fn do_test_htlc_on_chain_timeout(connect_style: ConnectStyle) { mine_transaction(&nodes[1], &timeout_tx); check_added_monitors!(nodes[1], 1); check_closed_broadcast!(nodes[1], true); - { - // B will rebroadcast a fee-bumped timeout transaction here. - let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0); - assert_eq!(node_txn.len(), 1); - check_spends!(node_txn[0], commitment_tx[0]); - } connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1); - { - // B may rebroadcast its own holder commitment transaction here, as a safeguard against - // some incredibly unlikely partial-eclipse-attack scenarios. That said, because the - // original commitment_tx[0] (also spending chan_2.3) has reached ANTI_REORG_DELAY B really - // shouldn't broadcast anything here, and in some connect style scenarios we do not. - let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0); - if node_txn.len() == 1 { - check_spends!(node_txn[0], chan_2.3); - } else { - assert_eq!(node_txn.len(), 0); - } - } expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCDestination::NextHopChannel { node_id: Some(nodes[2].node.get_our_node_id()), channel_id: chan_2.2 }]); check_added_monitors!(nodes[1], 1); @@ -3711,11 +3694,23 @@ fn do_test_drop_messages_peer_disconnect(messages_delivered: u8, simulate_broken } let events_1 = nodes[1].node.get_and_clear_pending_events(); - assert_eq!(events_1.len(), 1); - match events_1[0] { - Event::PendingHTLCsForwardable { .. } => { }, - _ => panic!("Unexpected event"), - }; + if messages_delivered == 0 { + assert_eq!(events_1.len(), 2); + match events_1[0] { + Event::ChannelReady { .. } => { }, + _ => panic!("Unexpected event"), + }; + match events_1[1] { + Event::PendingHTLCsForwardable { .. } => { }, + _ => panic!("Unexpected event"), + }; + } else { + assert_eq!(events_1.len(), 1); + match events_1[0] { + Event::PendingHTLCsForwardable { .. } => { }, + _ => panic!("Unexpected event"), + }; + } nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false); nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false); @@ -3952,6 +3947,8 @@ fn test_funding_peer_disconnect() { }, _ => panic!("Unexpected event {:?}", events_6[0]), }; + expect_channel_ready_event(&nodes[0], &nodes[1].node.get_our_node_id()); + expect_channel_ready_event(&nodes[1], &nodes[0].node.get_our_node_id()); // When we deliver nodes[1]'s announcement_signatures to nodes[0], nodes[0] should immediately // broadcast the channel announcement globally, as well as re-send its (now-public) @@ -8001,22 +7998,6 @@ fn test_bump_penalty_txn_on_revoked_htlcs() { connect_block(&nodes[0], &Block { header: header_130, txdata: penalty_txn }); let header_131 = BlockHeader { version: 0x20000000, prev_blockhash: header_130.block_hash(), merkle_root: TxMerkleNode::all_zeros(), time: 42, bits: 42, nonce: 42 }; connect_block(&nodes[0], &Block { header: header_131, txdata: Vec::new() }); - { - let mut node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap(); - assert_eq!(node_txn.len(), 2); // 2 bumped penalty txn on revoked commitment tx - - check_spends!(node_txn[0], revoked_local_txn[0]); - check_spends!(node_txn[1], revoked_local_txn[0]); - // Note that these are both bogus - they spend outputs already claimed in block 129: - if node_txn[0].input[0].previous_output == revoked_htlc_txn[0].input[0].previous_output { - assert_eq!(node_txn[1].input[0].previous_output, revoked_htlc_txn[2].input[0].previous_output); - } else { - assert_eq!(node_txn[0].input[0].previous_output, revoked_htlc_txn[2].input[0].previous_output); - assert_eq!(node_txn[1].input[0].previous_output, revoked_htlc_txn[0].input[0].previous_output); - } - - node_txn.clear(); - }; // Few more blocks to confirm penalty txn connect_blocks(&nodes[0], 4); @@ -9429,6 +9410,7 @@ fn test_duplicate_chan_id() { let (channel_ready, _) = create_chan_between_nodes_with_value_confirm(&nodes[0], &nodes[1], &tx); let (announcement, as_update, bs_update) = create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &channel_ready); update_nodes_with_chan_announce(&nodes, 0, 1, &announcement, &as_update, &bs_update); + send_payment(&nodes[0], &[&nodes[1]], 8000000); }