X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Ffunctional_tests.rs;h=d21f558a65f5c365414171005167ea82ad55de84;hb=6497465762ec566f6d422f155d60864ca0834aff;hp=5ef085752aa8f20af4ebb11c366f999890c09555;hpb=093fcaba68ab9d96e4570d0a4d9bcbdecc03a67f;p=rust-lightning diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index 5ef08575..d21f558a 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -1,3 +1,12 @@ +// This file is Copyright its original authors, visible in version control +// history. +// +// This file is licensed under the Apache License, Version 2.0 or the MIT license +// , at your option. +// You may not use this file except in accordance with one or both of these +// licenses. + //! Tests that test standing up a network of ChannelManagers, creating channels, sending //! payments/messages between them, and often checking the resulting ChannelMonitors are able to //! claim outputs on-chain. @@ -1884,6 +1893,25 @@ fn test_chan_reserve_violation_inbound_htlc_inbound_chan() { check_added_monitors!(nodes[1], 1); } +#[test] +fn test_inbound_outbound_capacity_is_not_zero() { + let chanmon_cfgs = create_chanmon_cfgs(2); + let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); + let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]); + let nodes = create_network(2, &node_cfgs, &node_chanmgrs); + let _ = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 95000000, InitFeatures::known(), InitFeatures::known()); + let channels0 = node_chanmgrs[0].list_channels(); + let channels1 = node_chanmgrs[1].list_channels(); + assert_eq!(channels0.len(), 1); + assert_eq!(channels1.len(), 1); + + assert_eq!(channels0[0].inbound_capacity_msat, 95000000); + assert_eq!(channels1[0].outbound_capacity_msat, 95000000); + + assert_eq!(channels0[0].outbound_capacity_msat, 100000 * 1000 - 95000000); + assert_eq!(channels1[0].inbound_capacity_msat, 100000 * 1000 - 95000000); +} + fn commit_tx_fee_msat(feerate: u32, num_htlcs: u64) -> u64 { (COMMITMENT_TX_BASE_WEIGHT + num_htlcs * COMMITMENT_TX_WEIGHT_PER_HTLC) * feerate as u64 / 1000 * 1000 } @@ -6098,7 +6126,7 @@ fn test_onion_failure() { let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]); let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs); for node in nodes.iter() { - *node.keys_manager.override_session_priv.lock().unwrap() = Some(SecretKey::from_slice(&[3; 32]).unwrap()); + *node.keys_manager.override_session_priv.lock().unwrap() = Some([3; 32]); } let channels = [create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()), create_announced_chan_between_nodes(&nodes, 1, 2, InitFeatures::known(), InitFeatures::known())]; let (_, payment_hash) = get_payment_preimage_hash!(nodes[0]);