Skip to content

Commit 651a152

Browse files
committed
Expose ChannelManager's current config and use it in reload in tests
1 parent b04720a commit 651a152

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,11 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
851851
}
852852
}
853853

854+
/// Gets the current configuration applied to all new channels, as
855+
pub fn get_current_default_configuration(&self) -> &UserConfig {
856+
&self.default_configuration
857+
}
858+
854859
/// Creates a new outbound channel to the given remote node and with the given value.
855860
///
856861
/// user_id will be provided back as user_channel_id in FundingGenerationReady events to allow

lightning/src/ln/functional_test_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn mine_transaction<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, tx: &Transac
6262
pub fn confirm_transaction_at<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, tx: &Transaction, conf_height: u32) {
6363
let first_connect_height = node.best_block_info().1 + 1;
6464
assert!(first_connect_height <= conf_height);
65-
if conf_height - first_connect_height >= 1 {
65+
if conf_height > first_connect_height {
6666
connect_blocks(node, conf_height - first_connect_height);
6767
}
6868
let mut block = Block {
@@ -281,7 +281,7 @@ impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> {
281281
let mut w = test_utils::TestVecWriter(Vec::new());
282282
self.node.write(&mut w).unwrap();
283283
<(BlockHash, ChannelManager<EnforcingSigner, &test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestLogger>)>::read(&mut ::std::io::Cursor::new(w.0), ChannelManagerReadArgs {
284-
default_config: UserConfig::default(),
284+
default_config: *self.node.get_current_default_configuration(),
285285
keys_manager: self.keys_manager,
286286
fee_estimator: &test_utils::TestFeeEstimator { sat_per_kw: 253 },
287287
chain_monitor: self.chain_monitor,

lightning/src/ln/reorg_tests.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use chain::Watch;
1414
use ln::channelmanager::{ChannelManager, ChannelManagerReadArgs};
1515
use ln::features::InitFeatures;
1616
use ln::msgs::{ChannelMessageHandler, ErrorAction, HTLCFailChannelUpdate};
17-
use util::config::UserConfig;
1817
use util::enforcing_trait_impls::EnforcingSigner;
1918
use util::events::{Event, EventsProvider, MessageSendEvent, MessageSendEventsProvider};
2019
use util::test_utils;
@@ -233,14 +232,13 @@ fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool, connect_styl
233232
assert!(chan_0_monitor_read.is_empty());
234233

235234
let mut nodes_0_read = &nodes_0_serialized[..];
236-
let config = UserConfig::default();
237235
nodes_0_deserialized = {
238236
let mut channel_monitors = HashMap::new();
239237
channel_monitors.insert(chan_0_monitor.get_funding_txo().0, &mut chan_0_monitor);
240238
<(BlockHash, ChannelManager<EnforcingSigner, &test_utils::TestChainMonitor, &test_utils::TestBroadcaster,
241239
&test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestLogger>)>::read(
242240
&mut nodes_0_read, ChannelManagerReadArgs {
243-
default_config: config,
241+
default_config: *nodes[0].node.get_current_default_configuration(),
244242
keys_manager,
245243
fee_estimator: node_cfgs[0].fee_estimator,
246244
chain_monitor: nodes[0].chain_monitor,

0 commit comments

Comments
 (0)