Impl Base AMP in the receive pipeline and expose payment_secret
[rust-lightning] / fuzz / src / chanmon_consistency.rs
index 3a25ad1ef8851c6d18e2d7017f7e1f07f99732f2..1d549bf76308b2124cd979a1c339a7c841ea5175 100644 (file)
@@ -85,7 +85,7 @@ pub struct TestChannelMonitor {
 impl TestChannelMonitor {
        pub fn new(chain_monitor: Arc<dyn chaininterface::ChainWatchInterface>, broadcaster: Arc<dyn chaininterface::BroadcasterInterface>, logger: Arc<dyn Logger>, feeest: Arc<dyn chaininterface::FeeEstimator>) -> Self {
                Self {
-                       simple_monitor: channelmonitor::SimpleManyChannelMonitor::new(chain_monitor, broadcaster, logger, feeest),
+                       simple_monitor: Arc::new(channelmonitor::SimpleManyChannelMonitor::new(chain_monitor, broadcaster, logger, feeest)),
                        update_ret: Mutex::new(Ok(())),
                        latest_good_update: Mutex::new(HashMap::new()),
                        latest_update_good: Mutex::new(HashMap::new()),
@@ -191,7 +191,7 @@ pub fn do_test(data: &[u8]) {
                        config.channel_options.fee_proportional_millionths = 0;
                        config.channel_options.announced_channel = true;
                        config.peer_channel_config_limits.min_dust_limit_satoshis = 0;
-                       (ChannelManager::new(Network::Bitcoin, fee_est.clone(), monitor.clone(), broadcast.clone(), Arc::clone(&logger), keys_manager.clone(), config, 0).unwrap(),
+                       (Arc::new(ChannelManager::new(Network::Bitcoin, fee_est.clone(), monitor.clone() as Arc<channelmonitor::ManyChannelMonitor>, broadcast.clone(), Arc::clone(&logger), keys_manager.clone(), config, 0).unwrap()),
                        monitor)
                } }
        }
@@ -222,14 +222,14 @@ pub fn do_test(data: &[u8]) {
                        let read_args = ChannelManagerReadArgs {
                                keys_manager,
                                fee_estimator: fee_est.clone(),
-                               monitor: monitor.clone(),
+                               monitor: monitor.clone() as Arc<channelmonitor::ManyChannelMonitor>,
                                tx_broadcaster: broadcast.clone(),
                                logger,
                                default_config: config,
                                channel_monitors: &mut monitor_refs,
                        };
 
-                       let res = (<(Sha256d, ChannelManager<EnforcingChannelKeys>)>::read(&mut Cursor::new(&$ser.0), read_args).expect("Failed to read manager").1, monitor);
+                       let res = (<(Sha256d, ChannelManager<EnforcingChannelKeys, Arc<channelmonitor::ManyChannelMonitor>>)>::read(&mut Cursor::new(&$ser.0), read_args).expect("Failed to read manager").1, monitor);
                        for (_, was_good) in $old_monitors.latest_updates_good_at_last_ser.lock().unwrap().iter() {
                                if !was_good {
                                        // If the last time we updated a monitor we didn't successfully update (and we
@@ -421,7 +421,7 @@ pub fn do_test(data: &[u8]) {
                                                fee_msat: 5000000,
                                                cltv_expiry_delta: 200,
                                        }],
-                               }, PaymentHash(payment_hash.into_inner())) {
+                               }, PaymentHash(payment_hash.into_inner()), None) {
                                        // Probably ran out of funds
                                        test_return!();
                                }
@@ -445,7 +445,7 @@ pub fn do_test(data: &[u8]) {
                                                fee_msat: 5000000,
                                                cltv_expiry_delta: 200,
                                        }],
-                               }, PaymentHash(payment_hash.into_inner())) {
+                               }, PaymentHash(payment_hash.into_inner()), None) {
                                        // Probably ran out of funds
                                        test_return!();
                                }
@@ -606,9 +606,9 @@ pub fn do_test(data: &[u8]) {
                                                events::Event::PaymentReceived { payment_hash, .. } => {
                                                        if claim_set.insert(payment_hash.0) {
                                                                if $fail {
-                                                                       assert!(nodes[$node].fail_htlc_backwards(&payment_hash));
+                                                                       assert!(nodes[$node].fail_htlc_backwards(&payment_hash, &None));
                                                                } else {
-                                                                       assert!(nodes[$node].claim_funds(PaymentPreimage(payment_hash.0), 5_000_000));
+                                                                       assert!(nodes[$node].claim_funds(PaymentPreimage(payment_hash.0), &None, 5_000_000));
                                                                }
                                                        }
                                                },