Skip to content
Open
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
59 changes: 22 additions & 37 deletions smite-scenarios/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3354,6 +3354,21 @@ mod tests {
instrs
}

fn recv_channel_ready_instructions(confirmations: u8) -> Vec<Instruction> {
let mut instrs = send_funding_created_and_recv_funding_signed_instructions();
instrs.extend([
Instruction {
operation: Operation::MineBlocks(confirmations),
inputs: vec![],
},
Instruction {
operation: Operation::RecvChannelReady,
inputs: vec![],
},
]);
instrs
}

#[test]
fn execute_send_funding_created_and_recv_funding_signed() {
let mock_cli = MockBitcoinCli {
Expand Down Expand Up @@ -3878,17 +3893,7 @@ mod tests {
.open_channel
.funding_pubkey = sample_pubkey(1);

let mut instrs = send_funding_created_and_recv_funding_signed_instructions();
instrs.extend([
Instruction {
operation: Operation::MineBlocks(8),
inputs: vec![],
},
Instruction {
operation: Operation::RecvChannelReady,
inputs: vec![],
},
]);
let instrs = recv_channel_ready_instructions(8);

// With invalid funding outpoint the target does not owe us a
// `channel_ready`, so `RecvChannelReady` must be a no-op.
Expand All @@ -3912,19 +3917,9 @@ mod tests {
fn execute_recv_channel_ready_below_minimum_depth_is_noop() {
let (mut executor, channel_id, _) = recv_channel_ready_executor();

let mut instrs = send_funding_created_and_recv_funding_signed_instructions();
instrs.extend([
Instruction {
// Mine one block fewer than the `minimum_depth` negotiated in
// `accept_channel` by `sample_funding_negotiation()`.
operation: Operation::MineBlocks(5),
inputs: vec![],
},
Instruction {
operation: Operation::RecvChannelReady,
inputs: vec![],
},
]);
// Mine one block fewer than the `minimum_depth` negotiated in `accept_channel` by
// `sample_funding_negotiation()`.
let instrs = recv_channel_ready_instructions(5);

// With fewer than the negotiated `minimum_depth` confirmations the target
// does not yet owe us a `channel_ready`, so `RecvChannelReady` must be a
Expand All @@ -3950,19 +3945,9 @@ mod tests {
fn execute_recv_channel_ready_at_minimum_depth_records_point() {
let (mut executor, channel_id, target_pcp) = recv_channel_ready_executor();

let mut instrs = send_funding_created_and_recv_funding_signed_instructions();
instrs.extend([
Instruction {
// Mine exactly the `minimum_depth` negotiated in
// `accept_channel` by `sample_funding_negotiation()`.
operation: Operation::MineBlocks(6),
inputs: vec![],
},
Instruction {
operation: Operation::RecvChannelReady,
inputs: vec![],
},
]);
// Mine exactly the `minimum_depth` negotiated in `accept_channel` by
// `sample_funding_negotiation()`.
let instrs = recv_channel_ready_instructions(6);

// At the negotiated `minimum_depth` confirmations the target owes us a
// `channel_ready`, which `RecvChannelReady` receives and records.
Expand Down