+ // positive case
+ let (route, payment_hash_success, payment_preimage_success, payment_secret_success) = get_route_and_payment_hash!(nodes[0], nodes[2], 40_000);
+ nodes[0].node.send_payment(&route, payment_hash_success, &Some(payment_secret_success)).unwrap();
+ check_added_monitors!(nodes[0], 1);
+ pass_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], 40_000, payment_hash_success, payment_secret_success);
+ claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], payment_preimage_success);
+
+ // If the hop gives fee_insufficient but enough fees were provided, then the previous hop
+ // malleated the payment before forwarding, taking funds when they shouldn't have.
+ let (_, payment_hash, payment_secret) = get_payment_preimage_hash!(nodes[2]);
+ let short_channel_id = channels[0].0.contents.short_channel_id;
+ run_onion_failure_test("fee_insufficient", 0, &nodes, &route, &payment_hash, &payment_secret, |msg| {
+ msg.amount_msat -= 1;
+ }, || {}, true, Some(UPDATE|12), Some(NetworkUpdate::ChannelClosed { short_channel_id, is_permanent: true}), Some(short_channel_id));
+
+ // In an earlier version, we spuriously failed to forward payments if the expected feerate
+ // changed between the channel open and the payment.
+ {
+ let mut feerate_lock = chanmon_cfgs[1].fee_estimator.sat_per_kw.lock().unwrap();
+ *feerate_lock *= 2;
+ }
+
+ let (payment_preimage_success, payment_hash_success, payment_secret_success) = get_payment_preimage_hash!(nodes[2]);
+ nodes[0].node.send_payment(&route, payment_hash_success, &Some(payment_secret_success)).unwrap();
+ check_added_monitors!(nodes[0], 1);
+ pass_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], 40_000, payment_hash_success, payment_secret_success);
+ claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], payment_preimage_success);
+}
+
+#[test]
+fn test_onion_failure() {