Skip to content

Commit 3607ad7

Browse files
committed
temp: update tests to use private field
1 parent 568638a commit 3607ad7

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

lightning/src/ln/accountable_tests.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use crate::ln::channelmanager::{
22
HTLCForwardInfo, PaymentId, PendingAddHTLCInfo, PendingHTLCInfo, RecipientOnionFields, Retry,
33
};
44
use crate::ln::functional_test_utils::*;
5-
use crate::ln::msgs::{accountable_from_bool, ChannelMessageHandler, ExperimentalAccountable};
5+
use crate::ln::msgs::ChannelMessageHandler;
66
use crate::routing::router::{PaymentParameters, RouteParameters};
77

88
fn test_accountable_forwarding_with_override(
9-
override_accountable: ExperimentalAccountable, expected_forwarded: bool,
9+
override_accountable: Option<u8>, expected_forwarded: bool,
1010
) {
1111
let chanmon_cfgs = create_chanmon_cfgs(3);
1212
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
@@ -32,11 +32,11 @@ fn test_accountable_forwarding_with_override(
3232
let updates_ab = get_htlc_update_msgs(&nodes[0], &nodes[1].node.get_our_node_id());
3333
assert_eq!(updates_ab.update_add_htlcs.len(), 1);
3434
let mut htlc_ab = updates_ab.update_add_htlcs[0].clone();
35-
assert_eq!(htlc_ab.accountable, accountable_from_bool(false));
35+
assert_eq!(htlc_ab.is_accountable(), false);
3636

3737
// Override accountable value if requested
38-
if let Some(override_value) = override_accountable {
39-
htlc_ab.accountable = Some(override_value);
38+
if override_accountable.is_some() {
39+
htlc_ab.set_accountable(override_accountable)
4040
}
4141

4242
nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &htlc_ab);
@@ -47,11 +47,11 @@ fn test_accountable_forwarding_with_override(
4747
let updates_bc = get_htlc_update_msgs(&nodes[1], &nodes[2].node.get_our_node_id());
4848
assert_eq!(updates_bc.update_add_htlcs.len(), 1);
4949
let htlc_bc = &updates_bc.update_add_htlcs[0];
50-
let expected_acountable_signal = accountable_from_bool(expected_forwarded);
5150
assert_eq!(
52-
htlc_bc.accountable, expected_acountable_signal,
51+
htlc_bc.is_accountable(),
52+
expected_forwarded,
5353
"B -> C should have accountable = {:?}",
54-
expected_acountable_signal
54+
expected_forwarded
5555
);
5656

5757
nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), htlc_bc);

lightning/src/ln/msgs.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,12 @@ impl UpdateAddHTLC {
803803
pub fn is_accountable(&self) -> bool {
804804
self.accountable.is_some_and(|v| v == 7)
805805
}
806+
807+
/// Helper to mutate values in tests.
808+
#[cfg(any(test, feature = "_test_utils"))]
809+
pub fn set_accountable(&mut self, accountable: Option<u8>) {
810+
self.accountable = accountable
811+
}
806812
}
807813

808814
/// An [`onion message`] to be sent to or received from a peer.

0 commit comments

Comments
 (0)