The `insert_txouts` test in `test_tx_graph.rs` needs redoing.
Describe the bug
https://github.com/bitcoindevkit/bdk/blob/7aca88474ac241bc0938ff989026463bdaf8f3ab/crates/chain/tests/test_tx_graph.rs#L16-L17
This test misunderstands Anchors. There is no such thing as an "unconfirmed anchor", and ChainPosition does not implement Anchor. We should rewrite this test to be comprehensive.
Proposed test scenarios
- [ ] Insert tx with txid
A, then insert partial txout(s) of the same txid. Expect: No changes toTxGraph(full tx should still exist in graph). Returned changeset is empty. - [ ] Insert partial txout with txid
B. Then insert full tx with txidB. Expect: the full tx should replace the partial tx. Check graph and returned changeset to confirm this. - [ ] Do the above two tests with different counts of partial txids.
Let me try this.
How does this line even compile:
https://github.com/bitcoindevkit/bdk/blob/7aca88474ac241bc0938ff989026463bdaf8f3ab/crates/chain/tests/test_tx_graph.rs#L97
If unconf_anchor isn't even an Anchor how can you pass it to insert_anchor!?!?!?
If
unconf_anchorisn't even anAnchorhow can you pass it toinsert_anchor!?!?!?
We will remove Anchor implementation for ChainPosition<A> to avoid the caller using UnconfirmChainPosition(u64) as an anchor to avoid malusage.
How does this line even compile:
https://github.com/bitcoindevkit/bdk/blob/7aca88474ac241bc0938ff989026463bdaf8f3ab/crates/chain/tests/test_tx_graph.rs#L97
If
unconf_anchorisn't even anAnchorhow can you pass it toinsert_anchor!?!?!?
We aren't enforcing the A: Anchor bound on that method. Now the question is, should we? What should be the policy of how we do generic bounds? I tend to avoid them wherever possible because bounds stack and it becomes annoying to deal with at higher levels.
If
unconf_anchorisn't even anAnchorhow can you pass it toinsert_anchor!?!?!?We will remove
Anchorimplementation forChainPosition<A>to avoid the caller usingUnconfirmChainPosition(u64)as an anchor to avoid malusage.
There is no Anchor implementation for ChainPosition. https://github.com/bitcoindevkit/bdk/pull/1338#discussion_r1485538692
yeh, I misread it.