@@ -24,7 +24,7 @@ use crate::ln::peer_handler::IgnoringMessageHandler;
24
24
use crate :: onion_message:: OnionMessenger ;
25
25
use crate :: routing:: gossip:: { P2PGossipSync , NetworkGraph , NetworkUpdate } ;
26
26
use crate :: routing:: router:: { self , PaymentParameters , Route , RouteParameters } ;
27
- use crate :: sign:: EntropySource ;
27
+ use crate :: sign:: { EntropySource , RandomBytes } ;
28
28
use crate :: util:: config:: { UserConfig , MaxDustHTLCExposure } ;
29
29
use crate :: util:: errors:: APIError ;
30
30
#[ cfg( test) ]
@@ -49,6 +49,7 @@ use alloc::rc::Rc;
49
49
use core:: cell:: RefCell ;
50
50
use core:: iter:: repeat;
51
51
use core:: mem;
52
+ use core:: ops:: Deref ;
52
53
use crate :: io;
53
54
use crate :: prelude:: * ;
54
55
use crate :: sync:: { Arc , Mutex , LockTestExt , RwLock } ;
@@ -411,14 +412,25 @@ type TestChannelManager<'node_cfg, 'chan_mon_cfg> = ChannelManager<
411
412
> ;
412
413
413
414
type TestOnionMessenger < ' chan_man , ' node_cfg , ' chan_mon_cfg > = OnionMessenger <
414
- & ' node_cfg test_utils :: TestKeysInterface ,
415
+ DedicatedEntropy ,
415
416
& ' node_cfg test_utils:: TestKeysInterface ,
416
417
& ' chan_mon_cfg test_utils:: TestLogger ,
417
418
& ' node_cfg test_utils:: TestMessageRouter < ' chan_mon_cfg > ,
418
419
& ' chan_man TestChannelManager < ' node_cfg , ' chan_mon_cfg > ,
419
420
IgnoringMessageHandler ,
420
421
> ;
421
422
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
+
422
434
pub struct Node < ' chan_man , ' node_cfg : ' chan_man , ' chan_mon_cfg : ' node_cfg > {
423
435
pub chain_source : & ' chan_mon_cfg test_utils:: TestChainSource ,
424
436
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
2954
2966
let connect_style = Rc :: new ( RefCell :: new ( ConnectStyle :: random_style ( ) ) ) ;
2955
2967
2956
2968
for i in 0 ..node_count {
2969
+ let dedicated_entropy = DedicatedEntropy ( RandomBytes :: new ( [ i as u8 ; 32 ] ) ) ;
2957
2970
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 ,
2959
2972
& chan_mgrs[ i] , IgnoringMessageHandler { } ,
2960
2973
) ;
2961
2974
let gossip_sync = P2PGossipSync :: new ( cfgs[ i] . network_graph . as_ref ( ) , None , cfgs[ i] . logger ) ;
0 commit comments