Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor tx_template and init_graph fn to use Cow
Browse files Browse the repository at this point in the history
- refactor tx_template struct and init_graph
to use Cow type
- update the chain test_tx_graph test to use the
updated tx_template struct and init_graph fn
- update the test_tx_graph_conflicts to use the
updated tx_template and init_graph fn

[Issue: 1754]
tvpeter committed Jan 17, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 0223527 commit afe0f79
Showing 3 changed files with 251 additions and 240 deletions.
27 changes: 14 additions & 13 deletions crates/chain/tests/test_tx_graph.rs
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ use bitcoin::{
};
use core::iter;
use rand::RngCore;
use std::borrow::Cow;
use std::sync::Arc;
use std::vec;

@@ -1135,28 +1136,28 @@ fn call_map_anchors_with_non_deterministic_anchor() {

let template = [
TxTemplate {
tx_name: "tx1",
inputs: &[TxInTemplate::Bogus],
outputs: &[TxOutTemplate::new(10000, Some(1))],
anchors: &[block_id!(1, "A")],
tx_name: Cow::Borrowed("tx1"),
inputs: vec![TxInTemplate::Bogus],
outputs: vec![TxOutTemplate::new(10000, Some(1))],
anchors: vec![block_id!(1, "A")],
last_seen: None,
},
TxTemplate {
tx_name: "tx2",
inputs: &[TxInTemplate::PrevTx("tx1", 0)],
outputs: &[TxOutTemplate::new(20000, Some(2))],
anchors: &[block_id!(2, "B")],
tx_name: Cow::Borrowed("tx2"),
inputs: vec![TxInTemplate::PrevTx(Cow::Borrowed("tx1"), 0)],
outputs: vec![TxOutTemplate::new(20000, Some(2))],
anchors: vec![block_id!(2, "B")],
..Default::default()
},
TxTemplate {
tx_name: "tx3",
inputs: &[TxInTemplate::PrevTx("tx2", 0)],
outputs: &[TxOutTemplate::new(30000, Some(3))],
anchors: &[block_id!(3, "C"), block_id!(4, "D")],
tx_name: Cow::Borrowed("tx3"),
inputs: vec![TxInTemplate::PrevTx(Cow::Borrowed("tx2"), 0)],
outputs: vec![TxOutTemplate::new(30000, Some(3))],
anchors: vec![block_id!(3, "C"), block_id!(4, "D")],
..Default::default()
},
];
let (graph, _, _) = init_graph(&template);
let (graph, _, _) = init_graph(template);
let new_graph = graph.clone().map_anchors(|a| NonDeterministicAnchor {
anchor_block: a,
// A non-deterministic value
Loading

0 comments on commit afe0f79

Please sign in to comment.