Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lightning/src/blinded_path/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ mod tests {
// Taken from the spec example for aggregating blinded payment info. See
// https://github.com/lightning/bolts/blob/master/proposals/route-blinding.md#blinded-payments
let dummy_pk = PublicKey::from_slice(&[2; 33]).unwrap();
let intermediate_nodes = vec![
let intermediate_nodes = [
PaymentForwardNode {
node_id: dummy_pk,
tlvs: ForwardTlvs {
Expand Down Expand Up @@ -944,7 +944,7 @@ mod tests {
// If no hops charge fees, the htlc_minimum_msat should just be the maximum htlc_minimum_msat
// along the path.
let dummy_pk = PublicKey::from_slice(&[2; 33]).unwrap();
let intermediate_nodes = vec![
let intermediate_nodes = [
PaymentForwardNode {
node_id: dummy_pk,
tlvs: ForwardTlvs {
Expand Down Expand Up @@ -1003,7 +1003,7 @@ mod tests {
// Create a path with varying fees and htlc_mins, and make sure htlc_minimum_msat ends up as the
// max (htlc_min - following_fees) along the path.
let dummy_pk = PublicKey::from_slice(&[2; 33]).unwrap();
let intermediate_nodes = vec![
let intermediate_nodes = [
PaymentForwardNode {
node_id: dummy_pk,
tlvs: ForwardTlvs {
Expand Down Expand Up @@ -1072,7 +1072,7 @@ mod tests {
// Create a path with varying fees and `htlc_maximum_msat`s, and make sure the aggregated max
// htlc ends up as the min (htlc_max - following_fees) along the path.
let dummy_pk = PublicKey::from_slice(&[2; 33]).unwrap();
let intermediate_nodes = vec![
let intermediate_nodes = [
PaymentForwardNode {
node_id: dummy_pk,
tlvs: ForwardTlvs {
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/crypto/chacha20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ mod test {
keystream: Vec<u8>,
}
// taken from http://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-04
let test_vectors = vec![
let test_vectors = [
TestVector {
key: [
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down Expand Up @@ -464,7 +464,7 @@ mod test {
keystream: Vec<u8>,
}
// taken from http://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-04
let test_vectors = vec![
let test_vectors = [
TestVector {
key: [
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ fn do_test_forming_justice_tx_from_monitor_updates(broadcast_initial_commitment:
let chanmon_cfgs = create_chanmon_cfgs(2);
let destination_script0 = chanmon_cfgs[0].keys_manager.get_destination_script([0; 32]).unwrap();
let destination_script1 = chanmon_cfgs[1].keys_manager.get_destination_script([0; 32]).unwrap();
let persisters = vec![
let persisters = [
WatchtowerPersister::new(destination_script0),
WatchtowerPersister::new(destination_script1),
];
Expand Down
9 changes: 2 additions & 7 deletions lightning/src/ln/interactivetxs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1492,12 +1492,6 @@ enum StateMachine {
NegotiationAborted(NegotiationAborted),
}

impl Default for StateMachine {
fn default() -> Self {
Self::Indeterminate
}
}

// The `StateMachine` internally executes the actual transition between two states and keeps
// track of the current state. This macro defines _how_ those state transitions happen to
// update the internal state.
Expand Down Expand Up @@ -1932,7 +1926,8 @@ impl InteractiveTxMessageSend {
// This macro executes a state machine transition based on a provided action.
macro_rules! do_state_transition {
($self: ident, $transition: ident, $msg: expr) => {{
let state_machine = core::mem::take(&mut $self.state_machine);
let mut state_machine = StateMachine::Indeterminate;
core::mem::swap(&mut state_machine, &mut $self.state_machine);
$self.state_machine = state_machine.$transition($msg);
match &$self.state_machine {
StateMachine::NegotiationAborted(state) => Err(state.0.clone()),
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/offers/invoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3002,7 +3002,7 @@ mod tests {
let secp_ctx = Secp256k1::new();
let payment_id = PaymentId([1; 32]);

let paths = vec![
let paths = [
BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/offers/refund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ mod tests {
#[test]
fn parses_refund_with_optional_fields() {
let past_expiry = Duration::from_secs(0);
let paths = vec![
let paths = [
BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
Expand Down
50 changes: 26 additions & 24 deletions lightning/src/routing/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4053,7 +4053,7 @@ mod tests {

// Simple route to 2 via 1

let our_chans = vec![get_channel_details(Some(2), our_id, InitFeatures::from_le_bytes(vec![0b11]), 100000)];
let our_chans = [get_channel_details(Some(2), our_id, InitFeatures::from_le_bytes(vec![0b11]), 100000)];

let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100);
if let Err(err) = get_route(&our_id,
Expand Down Expand Up @@ -4472,7 +4472,7 @@ mod tests {
} else { panic!(); }

// If we specify a channel to node7, that overrides our local channel view and that gets used
let our_chans = vec![get_channel_details(Some(42), nodes[7].clone(),
let our_chans = [get_channel_details(Some(42), nodes[7].clone(),
InitFeatures::from_le_bytes(vec![0b11]), 250_000_000)];
route_params.payment_params.max_path_length = 2;
let route = get_route(&our_id, &route_params, &network_graph.read_only(),
Expand Down Expand Up @@ -4520,7 +4520,7 @@ mod tests {
} else { panic!(); }

// If we specify a channel to node7, that overrides our local channel view and that gets used
let our_chans = vec![get_channel_details(Some(42), nodes[7].clone(),
let our_chans = [get_channel_details(Some(42), nodes[7].clone(),
InitFeatures::from_le_bytes(vec![0b11]), 250_000_000)];
let route = get_route(&our_id, &route_params, &network_graph.read_only(),
Some(&our_chans.iter().collect::<Vec<_>>()), Arc::clone(&logger), &scorer,
Expand Down Expand Up @@ -4585,7 +4585,7 @@ mod tests {
// If we specify a channel to node7, that overrides our local channel view and that gets used
let payment_params = PaymentParameters::from_node_id(nodes[2], 42);
let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100);
let our_chans = vec![get_channel_details(Some(42), nodes[7].clone(),
let our_chans = [get_channel_details(Some(42), nodes[7].clone(),
InitFeatures::from_le_bytes(vec![0b11]), 250_000_000)];
let route = get_route(&our_id, &route_params, &network_graph.read_only(),
Some(&our_chans.iter().collect::<Vec<_>>()), Arc::clone(&logger), &scorer,
Expand Down Expand Up @@ -5136,7 +5136,7 @@ mod tests {
let random_seed_bytes = [42; 32];

// Simple test with outbound channel to 4 to test that last_hops and first_hops connect
let our_chans = vec![get_channel_details(Some(42), nodes[3].clone(), InitFeatures::from_le_bytes(vec![0b11]), 250_000_000)];
let our_chans = [get_channel_details(Some(42), nodes[3].clone(), InitFeatures::from_le_bytes(vec![0b11]), 250_000_000)];
let mut last_hops = last_hops(&nodes);
let payment_params = PaymentParameters::from_node_id(nodes[6], 42)
.with_route_hints(last_hops.clone()).unwrap();
Expand Down Expand Up @@ -5264,7 +5264,7 @@ mod tests {
htlc_maximum_msat: last_hop_htlc_max,
}]);
let payment_params = PaymentParameters::from_node_id(target_node_id, 42).with_route_hints(vec![last_hops]).unwrap();
let our_chans = vec![get_channel_details(Some(42), middle_node_id, InitFeatures::from_le_bytes(vec![0b11]), outbound_capacity_msat)];
let our_chans = [get_channel_details(Some(42), middle_node_id, InitFeatures::from_le_bytes(vec![0b11]), outbound_capacity_msat)];
let scorer = ln_test_utils::TestScorer::new();
let random_seed_bytes = [42; 32];
let logger = ln_test_utils::TestLogger::new();
Expand Down Expand Up @@ -5441,7 +5441,7 @@ mod tests {
});

// Now, limit the first_hop by the next_outbound_htlc_limit_msat of 200_000 sats.
let our_chans = vec![get_channel_details(Some(42), nodes[0].clone(), InitFeatures::from_le_bytes(vec![0b11]), 200_000_000)];
let our_chans = [get_channel_details(Some(42), nodes[0].clone(), InitFeatures::from_le_bytes(vec![0b11]), 200_000_000)];

{
// Attempt to route more than available results in a failure.
Expand Down Expand Up @@ -7826,7 +7826,7 @@ mod tests {

let our_node_id = ln_test_utils::pubkey(42);
let intermed_node_id = ln_test_utils::pubkey(43);
let first_hop = vec![get_channel_details(Some(42), intermed_node_id, InitFeatures::from_le_bytes(vec![0b11]), 10_000_000)];
let first_hop = [get_channel_details(Some(42), intermed_node_id, InitFeatures::from_le_bytes(vec![0b11]), 10_000_000)];

let amt_msat = 900_000;
let max_htlc_msat = 500_000;
Expand Down Expand Up @@ -7873,7 +7873,7 @@ mod tests {

// Re-run but with two first hop channels connected to the same route hint peers that must be
// split between.
let first_hops = vec![
let first_hops = [
get_channel_details(Some(42), intermed_node_id, InitFeatures::from_le_bytes(vec![0b11]), amt_msat - 10),
get_channel_details(Some(43), intermed_node_id, InitFeatures::from_le_bytes(vec![0b11]), amt_msat - 10),
];
Expand Down Expand Up @@ -8285,8 +8285,9 @@ mod tests {
fee_proportional_millionths: 0,
excess_data: Vec::new()
});
let first_hops = vec![
get_channel_details(Some(1), nodes[1], InitFeatures::from_le_bytes(vec![0b11]), 10_000_000)];
let first_hops = [
get_channel_details(Some(1), nodes[1], InitFeatures::from_le_bytes(vec![0b11]), 10_000_000)
];

let blinded_payinfo = BlindedPayInfo {
fee_base_msat: 1000,
Expand Down Expand Up @@ -8346,9 +8347,10 @@ mod tests {
// Values are taken from the fuzz input that uncovered this panic.
let amt_msat = 21_7020_5185_1403_2640;
let (_, _, _, nodes) = get_nodes(&secp_ctx);
let first_hops = vec![
let first_hops = [
get_channel_details(Some(1), nodes[1], channelmanager::provided_init_features(&config),
18446744073709551615)];
18446744073709551615),
];

let blinded_payinfo = BlindedPayInfo {
fee_base_msat: 5046_2720,
Expand Down Expand Up @@ -8492,7 +8494,7 @@ mod tests {
let amt_msat = 7_4009_8048;
let (_, our_id, _, nodes) = get_nodes(&secp_ctx);
let first_hop_outbound_capacity = 2_7345_2000;
let first_hops = vec![get_channel_details(
let first_hops = [get_channel_details(
Some(200), nodes[0], channelmanager::provided_init_features(&config),
first_hop_outbound_capacity
)];
Expand Down Expand Up @@ -8565,7 +8567,7 @@ mod tests {
// Values are taken from the fuzz input that uncovered this panic.
let amt_msat = 52_4288;
let (_, our_id, _, nodes) = get_nodes(&secp_ctx);
let first_hops = vec![get_channel_details(
let first_hops = [get_channel_details(
Some(161), nodes[0], channelmanager::provided_init_features(&config), 486_4000
), get_channel_details(
Some(122), nodes[0], channelmanager::provided_init_features(&config), 179_5000
Expand Down Expand Up @@ -8640,7 +8642,7 @@ mod tests {
// Values are taken from the fuzz input that uncovered this panic.
let amt_msat = 7_4009_8048;
let (_, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
let first_hops = vec![get_channel_details(
let first_hops = [get_channel_details(
Some(200), nodes[0], channelmanager::provided_init_features(&config), 2_7345_2000
)];

Expand Down Expand Up @@ -8704,7 +8706,7 @@ mod tests {
// Values are taken from the fuzz input that uncovered this panic.
let amt_msat = 562_0000;
let (_, our_id, _, nodes) = get_nodes(&secp_ctx);
let first_hops = vec![
let first_hops = [
get_channel_details(
Some(83), nodes[0], channelmanager::provided_init_features(&config), 2199_0000,
),
Expand Down Expand Up @@ -8848,9 +8850,8 @@ mod tests {

// First create an insufficient first hop for channel with SCID 1 and check we'd use the
// route hint.
let first_hop = get_channel_details(Some(1), nodes[0],
channelmanager::provided_init_features(&config), 999_999);
let first_hops = vec![first_hop];
let first_hops = [get_channel_details(Some(1), nodes[0],
channelmanager::provided_init_features(&config), 999_999)];

let route = get_route(&our_node_id, &route_params.clone(), &network_graph.read_only(),
Some(&first_hops.iter().collect::<Vec<_>>()), Arc::clone(&logger), &scorer,
Expand All @@ -8866,7 +8867,7 @@ mod tests {
// for a first hop channel.
let mut first_hop = get_channel_details(Some(1), nodes[0], channelmanager::provided_init_features(&config), 999_999);
first_hop.outbound_scid_alias = Some(44);
let first_hops = vec![first_hop];
let first_hops = [first_hop];

let route_res = get_route(&our_node_id, &route_params.clone(), &network_graph.read_only(),
Some(&first_hops.iter().collect::<Vec<_>>()), Arc::clone(&logger), &scorer,
Expand All @@ -8878,7 +8879,7 @@ mod tests {
let mut first_hop = get_channel_details(Some(1), nodes[0],
channelmanager::provided_init_features(&config), 10_000_000);
first_hop.outbound_scid_alias = Some(44);
let first_hops = vec![first_hop];
let first_hops = [first_hop];

let route = get_route(&our_node_id, &route_params.clone(), &network_graph.read_only(),
Some(&first_hops.iter().collect::<Vec<_>>()), Arc::clone(&logger), &scorer,
Expand Down Expand Up @@ -9001,8 +9002,9 @@ mod tests {
let amt_msat = 1_000_000;
let dest_node_id = nodes[1];

let first_hop = get_channel_details(Some(1), nodes[0], channelmanager::provided_init_features(&config), 10_000_000);
let first_hops = vec![first_hop];
let first_hops = [
get_channel_details(Some(1), nodes[0], channelmanager::provided_init_features(&config), 10_000_000),
];

let route_hint = RouteHint(vec![RouteHintHop {
src_node_id: our_node_id,
Expand Down
Loading