Skip to content

Commit b38d154

Browse files
committed
test: get first_seen of a transaction
1 parent 748d248 commit b38d154

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

crates/chain/tests/test_tx_graph.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,3 +1401,31 @@ fn test_get_first_seen_of_a_tx() {
14011401
let first_seen = graph.get_tx_node(txid).unwrap().first_seen;
14021402
assert_eq!(first_seen, Some(seen_at));
14031403
}
1404+
1405+
#[test]
1406+
fn test_get_first_seen_of_a_tx() {
1407+
let mut graph = TxGraph::<BlockId>::default();
1408+
1409+
let tx = Transaction {
1410+
version: transaction::Version::ONE,
1411+
lock_time: absolute::LockTime::ZERO,
1412+
input: vec![TxIn {
1413+
previous_output: OutPoint::null(),
1414+
..Default::default()
1415+
}],
1416+
output: vec![TxOut {
1417+
value: Amount::from_sat(50_000),
1418+
script_pubkey: ScriptBuf::new(),
1419+
}],
1420+
};
1421+
let txid = tx.compute_txid();
1422+
let seen_at = 1_000_000_u64;
1423+
1424+
let changeset_tx = graph.insert_tx(Arc::new(tx));
1425+
graph.apply_changeset(changeset_tx);
1426+
let changeset_seen = graph.insert_seen_at(txid, seen_at);
1427+
graph.apply_changeset(changeset_seen);
1428+
1429+
let first_seen = graph.get_tx_node(txid).unwrap().first_seen;
1430+
assert_eq!(first_seen, Some(seen_at));
1431+
}

0 commit comments

Comments
 (0)