Skip to content

Commit 830a618

Browse files
committed
f - fix failing test
1 parent 8029647 commit 830a618

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::ln::peer_handler::IgnoringMessageHandler;
2424
use crate::onion_message::OnionMessenger;
2525
use crate::routing::gossip::{P2PGossipSync, NetworkGraph, NetworkUpdate};
2626
use crate::routing::router::{self, PaymentParameters, Route, RouteParameters};
27-
use crate::sign::EntropySource;
27+
use crate::sign::{EntropySource, RandomBytes};
2828
use crate::util::config::{UserConfig, MaxDustHTLCExposure};
2929
use crate::util::errors::APIError;
3030
#[cfg(test)]
@@ -49,6 +49,7 @@ use alloc::rc::Rc;
4949
use core::cell::RefCell;
5050
use core::iter::repeat;
5151
use core::mem;
52+
use core::ops::Deref;
5253
use crate::io;
5354
use crate::prelude::*;
5455
use crate::sync::{Arc, Mutex, LockTestExt, RwLock};
@@ -411,14 +412,25 @@ type TestChannelManager<'node_cfg, 'chan_mon_cfg> = ChannelManager<
411412
>;
412413

413414
type TestOnionMessenger<'chan_man, 'node_cfg, 'chan_mon_cfg> = OnionMessenger<
414-
&'node_cfg test_utils::TestKeysInterface,
415+
DedicatedEntropy,
415416
&'node_cfg test_utils::TestKeysInterface,
416417
&'chan_mon_cfg test_utils::TestLogger,
417418
&'node_cfg test_utils::TestMessageRouter<'chan_mon_cfg>,
418419
&'chan_man TestChannelManager<'node_cfg, 'chan_mon_cfg>,
419420
IgnoringMessageHandler,
420421
>;
421422

423+
/// For use with [`OnionMessenger`] otherwise `test_restored_packages_retry` will fail. This is
424+
/// because that test uses older serialized data produced by calling [`EntropySource`] in a specific
425+
/// manner. Using the same [`EntropySource`] with [`OnionMessenger`] would introduce another call,
426+
/// causing the produced data to no longer match.
427+
pub struct DedicatedEntropy(RandomBytes);
428+
429+
impl Deref for DedicatedEntropy {
430+
type Target = RandomBytes;
431+
fn deref(&self) -> &Self::Target { &self.0 }
432+
}
433+
422434
pub struct Node<'chan_man, 'node_cfg: 'chan_man, 'chan_mon_cfg: 'node_cfg> {
423435
pub chain_source: &'chan_mon_cfg test_utils::TestChainSource,
424436
pub tx_broadcaster: &'chan_mon_cfg test_utils::TestBroadcaster,
@@ -2954,8 +2966,9 @@ pub fn create_network<'a, 'b: 'a, 'c: 'b>(node_count: usize, cfgs: &'b Vec<NodeC
29542966
let connect_style = Rc::new(RefCell::new(ConnectStyle::random_style()));
29552967

29562968
for i in 0..node_count {
2969+
let dedicated_entropy = DedicatedEntropy(RandomBytes::new([i as u8; 32]));
29572970
let onion_messenger = OnionMessenger::new(
2958-
cfgs[i].keys_manager, cfgs[i].keys_manager, cfgs[i].logger, &cfgs[i].message_router,
2971+
dedicated_entropy, cfgs[i].keys_manager, cfgs[i].logger, &cfgs[i].message_router,
29592972
&chan_mgrs[i], IgnoringMessageHandler {},
29602973
);
29612974
let gossip_sync = P2PGossipSync::new(cfgs[i].network_graph.as_ref(), None, cfgs[i].logger);

lightning/src/sign/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,9 +1874,9 @@ impl PhantomKeysManager {
18741874
}
18751875
}
18761876

1877-
/// An implementation of [`EntropySource`] using [`ChaCha20`].
1877+
/// An implementation of [`EntropySource`] using ChaCha20.
18781878
#[derive(Debug)]
1879-
struct RandomBytes {
1879+
pub struct RandomBytes {
18801880
/// Seed from which all randomness produced is derived from.
18811881
seed: [u8; 32],
18821882
/// Tracks the number of times we've produced randomness to ensure we don't return the same

0 commit comments

Comments
 (0)