@@ -28,7 +28,7 @@ use util::enforcing_trait_impls::EnforcingChannelKeys;
28
28
use util:: { byte_utils, test_utils} ;
29
29
use util:: events:: { Event , EventsProvider , MessageSendEvent , MessageSendEventsProvider } ;
30
30
use util:: errors:: APIError ;
31
- use util:: ser:: { Writeable , ReadableArgs , Readable } ;
31
+ use util:: ser:: { Writeable , ReadableArgs } ;
32
32
use util:: config:: UserConfig ;
33
33
34
34
use bitcoin:: hashes:: sha256d:: Hash as Sha256dHash ;
@@ -4326,13 +4326,14 @@ fn test_no_txn_manager_serialize_deserialize() {
4326
4326
persister = test_utils:: TestPersister :: new ( ) ;
4327
4327
new_chain_monitor = test_utils:: TestChainMonitor :: new ( Some ( nodes[ 0 ] . chain_source ) , nodes[ 0 ] . tx_broadcaster . clone ( ) , & logger, & fee_estimator, & persister) ;
4328
4328
nodes[ 0 ] . chain_monitor = & new_chain_monitor;
4329
+ keys_manager = test_utils:: TestKeysInterface :: new ( & nodes[ 0 ] . node_seed , Network :: Testnet ) ;
4329
4330
let mut chan_0_monitor_read = & chan_0_monitor_serialized. 0 [ ..] ;
4330
- let ( _, mut chan_0_monitor) = <( BlockHash , ChannelMonitor < EnforcingChannelKeys > ) >:: read ( & mut chan_0_monitor_read) . unwrap ( ) ;
4331
+ let ( _, mut chan_0_monitor) = <( BlockHash , ChannelMonitor < EnforcingChannelKeys > ) >:: read (
4332
+ & mut chan_0_monitor_read, & keys_manager) . unwrap ( ) ;
4331
4333
assert ! ( chan_0_monitor_read. is_empty( ) ) ;
4332
4334
4333
4335
let mut nodes_0_read = & nodes_0_serialized[ ..] ;
4334
4336
let config = UserConfig :: default ( ) ;
4335
- keys_manager = test_utils:: TestKeysInterface :: new ( & nodes[ 0 ] . node_seed , Network :: Testnet ) ;
4336
4337
let ( _, nodes_0_deserialized_tmp) = {
4337
4338
let mut channel_monitors = HashMap :: new ( ) ;
4338
4339
channel_monitors. insert ( chan_0_monitor. get_funding_txo ( ) . 0 , & mut chan_0_monitor) ;
@@ -4434,14 +4435,15 @@ fn test_manager_serialize_deserialize_events() {
4434
4435
logger = test_utils:: TestLogger :: new ( ) ;
4435
4436
persister = test_utils:: TestPersister :: new ( ) ;
4436
4437
new_chain_monitor = test_utils:: TestChainMonitor :: new ( Some ( nodes[ 0 ] . chain_source ) , nodes[ 0 ] . tx_broadcaster . clone ( ) , & logger, & fee_estimator, & persister) ;
4438
+ keys_manager = test_utils:: TestKeysInterface :: new ( & nodes[ 0 ] . node_seed , Network :: Testnet ) ;
4437
4439
nodes[ 0 ] . chain_monitor = & new_chain_monitor;
4438
4440
let mut chan_0_monitor_read = & chan_0_monitor_serialized. 0 [ ..] ;
4439
- let ( _, mut chan_0_monitor) = <( BlockHash , ChannelMonitor < EnforcingChannelKeys > ) >:: read ( & mut chan_0_monitor_read) . unwrap ( ) ;
4441
+ let ( _, mut chan_0_monitor) = <( BlockHash , ChannelMonitor < EnforcingChannelKeys > ) >:: read (
4442
+ & mut chan_0_monitor_read, & keys_manager) . unwrap ( ) ;
4440
4443
assert ! ( chan_0_monitor_read. is_empty( ) ) ;
4441
4444
4442
4445
let mut nodes_0_read = & nodes_0_serialized[ ..] ;
4443
4446
let config = UserConfig :: default ( ) ;
4444
- keys_manager = test_utils:: TestKeysInterface :: new ( & nodes[ 0 ] . node_seed , Network :: Testnet ) ;
4445
4447
let ( _, nodes_0_deserialized_tmp) = {
4446
4448
let mut channel_monitors = HashMap :: new ( ) ;
4447
4449
channel_monitors. insert ( chan_0_monitor. get_funding_txo ( ) . 0 , & mut chan_0_monitor) ;
@@ -4526,13 +4528,14 @@ fn test_simple_manager_serialize_deserialize() {
4526
4528
fee_estimator = test_utils:: TestFeeEstimator { sat_per_kw : 253 } ;
4527
4529
persister = test_utils:: TestPersister :: new ( ) ;
4528
4530
new_chain_monitor = test_utils:: TestChainMonitor :: new ( Some ( nodes[ 0 ] . chain_source ) , nodes[ 0 ] . tx_broadcaster . clone ( ) , & logger, & fee_estimator, & persister) ;
4531
+ keys_manager = test_utils:: TestKeysInterface :: new ( & nodes[ 0 ] . node_seed , Network :: Testnet ) ;
4529
4532
nodes[ 0 ] . chain_monitor = & new_chain_monitor;
4530
4533
let mut chan_0_monitor_read = & chan_0_monitor_serialized. 0 [ ..] ;
4531
- let ( _, mut chan_0_monitor) = <( BlockHash , ChannelMonitor < EnforcingChannelKeys > ) >:: read ( & mut chan_0_monitor_read) . unwrap ( ) ;
4534
+ let ( _, mut chan_0_monitor) = <( BlockHash , ChannelMonitor < EnforcingChannelKeys > ) >:: read (
4535
+ & mut chan_0_monitor_read, & keys_manager) . unwrap ( ) ;
4532
4536
assert ! ( chan_0_monitor_read. is_empty( ) ) ;
4533
4537
4534
4538
let mut nodes_0_read = & nodes_0_serialized[ ..] ;
4535
- keys_manager = test_utils:: TestKeysInterface :: new ( & nodes[ 0 ] . node_seed , Network :: Testnet ) ;
4536
4539
let ( _, nodes_0_deserialized_tmp) = {
4537
4540
let mut channel_monitors = HashMap :: new ( ) ;
4538
4541
channel_monitors. insert ( chan_0_monitor. get_funding_txo ( ) . 0 , & mut chan_0_monitor) ;
@@ -4608,24 +4611,24 @@ fn test_manager_serialize_deserialize_inconsistent_monitor() {
4608
4611
new_chain_monitor = test_utils:: TestChainMonitor :: new ( Some ( nodes[ 0 ] . chain_source ) , nodes[ 0 ] . tx_broadcaster . clone ( ) , & logger, & fee_estimator, & persister) ;
4609
4612
nodes[ 0 ] . chain_monitor = & new_chain_monitor;
4610
4613
4614
+ keys_manager = test_utils:: TestKeysInterface :: new ( & nodes[ 0 ] . node_seed , Network :: Testnet ) ;
4615
+
4611
4616
let mut node_0_stale_monitors = Vec :: new ( ) ;
4612
4617
for serialized in node_0_stale_monitors_serialized. iter ( ) {
4613
4618
let mut read = & serialized[ ..] ;
4614
- let ( _, monitor) = <( BlockHash , ChannelMonitor < EnforcingChannelKeys > ) >:: read ( & mut read) . unwrap ( ) ;
4619
+ let ( _, monitor) = <( BlockHash , ChannelMonitor < EnforcingChannelKeys > ) >:: read ( & mut read, & keys_manager ) . unwrap ( ) ;
4615
4620
assert ! ( read. is_empty( ) ) ;
4616
4621
node_0_stale_monitors. push ( monitor) ;
4617
4622
}
4618
4623
4619
4624
let mut node_0_monitors = Vec :: new ( ) ;
4620
4625
for serialized in node_0_monitors_serialized. iter ( ) {
4621
4626
let mut read = & serialized[ ..] ;
4622
- let ( _, monitor) = <( BlockHash , ChannelMonitor < EnforcingChannelKeys > ) >:: read ( & mut read) . unwrap ( ) ;
4627
+ let ( _, monitor) = <( BlockHash , ChannelMonitor < EnforcingChannelKeys > ) >:: read ( & mut read, & keys_manager ) . unwrap ( ) ;
4623
4628
assert ! ( read. is_empty( ) ) ;
4624
4629
node_0_monitors. push ( monitor) ;
4625
4630
}
4626
4631
4627
- keys_manager = test_utils:: TestKeysInterface :: new ( & nodes[ 0 ] . node_seed , Network :: Testnet ) ;
4628
-
4629
4632
let mut nodes_0_read = & nodes_0_serialized[ ..] ;
4630
4633
if let Err ( msgs:: DecodeError :: InvalidValue ) =
4631
4634
<( BlockHash , ChannelManager < EnforcingChannelKeys , & test_utils:: TestChainMonitor , & test_utils:: TestBroadcaster , & test_utils:: TestKeysInterface , & test_utils:: TestFeeEstimator , & test_utils:: TestLogger > ) >:: read ( & mut nodes_0_read, ChannelManagerReadArgs {
@@ -7442,11 +7445,11 @@ fn test_data_loss_protect() {
7442
7445
7443
7446
// Restore node A from previous state
7444
7447
logger = test_utils:: TestLogger :: with_id ( format ! ( "node {}" , 0 ) ) ;
7445
- let mut chain_monitor = <( BlockHash , ChannelMonitor < EnforcingChannelKeys > ) >:: read ( & mut :: std:: io:: Cursor :: new ( previous_chain_monitor_state. 0 ) ) . unwrap ( ) . 1 ;
7448
+ keys_manager = test_utils:: TestKeysInterface :: new ( & nodes[ 0 ] . node_seed , Network :: Testnet ) ;
7449
+ let mut chain_monitor = <( BlockHash , ChannelMonitor < EnforcingChannelKeys > ) >:: read ( & mut :: std:: io:: Cursor :: new ( previous_chain_monitor_state. 0 ) , & keys_manager) . unwrap ( ) . 1 ;
7446
7450
chain_source = test_utils:: TestChainSource :: new ( Network :: Testnet ) ;
7447
7451
tx_broadcaster = test_utils:: TestBroadcaster { txn_broadcasted : Mutex :: new ( Vec :: new ( ) ) } ;
7448
7452
fee_estimator = test_utils:: TestFeeEstimator { sat_per_kw : 253 } ;
7449
- keys_manager = test_utils:: TestKeysInterface :: new ( & nodes[ 0 ] . node_seed , Network :: Testnet ) ;
7450
7453
persister = test_utils:: TestPersister :: new ( ) ;
7451
7454
monitor = test_utils:: TestChainMonitor :: new ( Some ( & chain_source) , & tx_broadcaster, & logger, & fee_estimator, & persister) ;
7452
7455
node_state_0 = {
@@ -8316,7 +8319,7 @@ fn test_update_err_monitor_lockdown() {
8316
8319
let mut w = test_utils:: TestVecWriter ( Vec :: new ( ) ) ;
8317
8320
monitor. write ( & mut w) . unwrap ( ) ;
8318
8321
let new_monitor = <( BlockHash , channelmonitor:: ChannelMonitor < EnforcingChannelKeys > ) >:: read (
8319
- & mut :: std:: io:: Cursor :: new ( & w. 0 ) ) . unwrap ( ) . 1 ;
8322
+ & mut :: std:: io:: Cursor :: new ( & w. 0 ) , & test_utils :: OnlyReadsKeysInterface { } ) . unwrap ( ) . 1 ;
8320
8323
assert ! ( new_monitor == * monitor) ;
8321
8324
let watchtower = test_utils:: TestChainMonitor :: new ( Some ( & chain_source) , & chanmon_cfgs[ 0 ] . tx_broadcaster , & logger, & chanmon_cfgs[ 0 ] . fee_estimator , & persister) ;
8322
8325
assert ! ( watchtower. watch_channel( outpoint, new_monitor) . is_ok( ) ) ;
@@ -8375,7 +8378,7 @@ fn test_concurrent_monitor_claim() {
8375
8378
let mut w = test_utils:: TestVecWriter ( Vec :: new ( ) ) ;
8376
8379
monitor. write ( & mut w) . unwrap ( ) ;
8377
8380
let new_monitor = <( BlockHash , channelmonitor:: ChannelMonitor < EnforcingChannelKeys > ) >:: read (
8378
- & mut :: std:: io:: Cursor :: new ( & w. 0 ) ) . unwrap ( ) . 1 ;
8381
+ & mut :: std:: io:: Cursor :: new ( & w. 0 ) , & test_utils :: OnlyReadsKeysInterface { } ) . unwrap ( ) . 1 ;
8379
8382
assert ! ( new_monitor == * monitor) ;
8380
8383
let watchtower = test_utils:: TestChainMonitor :: new ( Some ( & chain_source) , & chanmon_cfgs[ 0 ] . tx_broadcaster , & logger, & chanmon_cfgs[ 0 ] . fee_estimator , & persister) ;
8381
8384
assert ! ( watchtower. watch_channel( outpoint, new_monitor) . is_ok( ) ) ;
@@ -8401,7 +8404,7 @@ fn test_concurrent_monitor_claim() {
8401
8404
let mut w = test_utils:: TestVecWriter ( Vec :: new ( ) ) ;
8402
8405
monitor. write ( & mut w) . unwrap ( ) ;
8403
8406
let new_monitor = <( BlockHash , channelmonitor:: ChannelMonitor < EnforcingChannelKeys > ) >:: read (
8404
- & mut :: std:: io:: Cursor :: new ( & w. 0 ) ) . unwrap ( ) . 1 ;
8407
+ & mut :: std:: io:: Cursor :: new ( & w. 0 ) , & test_utils :: OnlyReadsKeysInterface { } ) . unwrap ( ) . 1 ;
8405
8408
assert ! ( new_monitor == * monitor) ;
8406
8409
let watchtower = test_utils:: TestChainMonitor :: new ( Some ( & chain_source) , & chanmon_cfgs[ 0 ] . tx_broadcaster , & logger, & chanmon_cfgs[ 0 ] . fee_estimator , & persister) ;
8407
8410
assert ! ( watchtower. watch_channel( outpoint, new_monitor) . is_ok( ) ) ;
0 commit comments