@@ -1305,57 +1305,34 @@ mod tests {
1305
1305
// fail either way but if it fails intermittently it's depending on the ordering of updates.
1306
1306
let mut update_iter = updates. iter ( ) ;
1307
1307
let next_update = update_iter. next ( ) . unwrap ( ) . clone ( ) ;
1308
+ let node_b_mon = & nodes[ 1 ] . chain_monitor . chain_monitor ;
1309
+
1308
1310
// Should contain next_update when pending updates listed.
1311
+ let pending_updates = node_b_mon. list_pending_monitor_updates ( ) ;
1309
1312
#[ cfg( not( c_bindings) ) ]
1310
- assert ! ( nodes[ 1 ]
1311
- . chain_monitor
1312
- . chain_monitor
1313
- . list_pending_monitor_updates( )
1314
- . get( & channel_id)
1315
- . unwrap( )
1316
- . contains( & next_update) ) ;
1313
+ let pending_chan_updates = pending_updates. get ( & channel_id) . unwrap ( ) ;
1317
1314
#[ cfg( c_bindings) ]
1318
- assert ! ( nodes[ 1 ]
1319
- . chain_monitor
1320
- . chain_monitor
1321
- . list_pending_monitor_updates( )
1322
- . iter( )
1323
- . find( |( chan_id, _) | * chan_id == channel_id)
1324
- . unwrap( )
1325
- . 1
1326
- . contains( & next_update) ) ;
1327
- nodes[ 1 ]
1328
- . chain_monitor
1329
- . chain_monitor
1330
- . channel_monitor_updated ( channel_id, next_update. clone ( ) )
1331
- . unwrap ( ) ;
1315
+ let pending_chan_updates =
1316
+ & pending_updates. iter ( ) . find ( |( chan_id, _) | * chan_id == channel_id) . unwrap ( ) . 1 ;
1317
+ assert ! ( pending_chan_updates. contains( & next_update) ) ;
1318
+
1319
+ node_b_mon. channel_monitor_updated ( channel_id, next_update. clone ( ) ) . unwrap ( ) ;
1320
+
1332
1321
// Should not contain the previously pending next_update when pending updates listed.
1322
+ let pending_updates = node_b_mon. list_pending_monitor_updates ( ) ;
1333
1323
#[ cfg( not( c_bindings) ) ]
1334
- assert ! ( !nodes[ 1 ]
1335
- . chain_monitor
1336
- . chain_monitor
1337
- . list_pending_monitor_updates( )
1338
- . get( & channel_id)
1339
- . unwrap( )
1340
- . contains( & next_update) ) ;
1324
+ let pending_chan_updates = pending_updates. get ( & channel_id) . unwrap ( ) ;
1341
1325
#[ cfg( c_bindings) ]
1342
- assert ! ( !nodes[ 1 ]
1343
- . chain_monitor
1344
- . chain_monitor
1345
- . list_pending_monitor_updates( )
1346
- . iter( )
1347
- . find( |( chan_id, _) | * chan_id == channel_id)
1348
- . unwrap( )
1349
- . 1
1350
- . contains( & next_update) ) ;
1326
+ let pending_chan_updates =
1327
+ & pending_updates. iter ( ) . find ( |( chan_id, _) | * chan_id == channel_id) . unwrap ( ) . 1 ;
1328
+ assert ! ( !pending_chan_updates. contains( & next_update) ) ;
1329
+
1351
1330
assert ! ( nodes[ 1 ] . chain_monitor. release_pending_monitor_events( ) . is_empty( ) ) ;
1352
1331
assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1353
1332
assert ! ( nodes[ 1 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
1354
- nodes[ 1 ]
1355
- . chain_monitor
1356
- . chain_monitor
1357
- . channel_monitor_updated ( channel_id, update_iter. next ( ) . unwrap ( ) . clone ( ) )
1358
- . unwrap ( ) ;
1333
+
1334
+ let next_update = update_iter. next ( ) . unwrap ( ) . clone ( ) ;
1335
+ node_b_mon. channel_monitor_updated ( channel_id, next_update) . unwrap ( ) ;
1359
1336
1360
1337
let claim_events = nodes[ 1 ] . node . get_and_clear_pending_events ( ) ;
1361
1338
assert_eq ! ( claim_events. len( ) , 2 ) ;
0 commit comments