Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The insert_txouts test in test_tx_graph.rs needs redoing. #1331

Open
3 tasks
evanlinjin opened this issue Feb 8, 2024 · 6 comments · May be fixed by #1338
Open
3 tasks

The insert_txouts test in test_tx_graph.rs needs redoing. #1331

evanlinjin opened this issue Feb 8, 2024 · 6 comments · May be fixed by #1338

Comments

@evanlinjin
Copy link
Member

Describe the bug

#[test]
fn insert_txouts() {

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 to TxGraph (full tx should still exist in graph). Returned changeset is empty.
  • Insert partial txout with txid B. Then insert full tx with txid B. 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.
@evanlinjin evanlinjin added the bug Something isn't working label Feb 8, 2024
@yanganto
Copy link
Contributor

yanganto commented Feb 8, 2024

Let me try this.

@evanlinjin evanlinjin changed the title The insert_txouts test in test_tx_graph.rs does not make any sense. The insert_txouts test in test_tx_graph.rs needs redoing. Feb 8, 2024
@LLFourn
Copy link
Contributor

LLFourn commented Feb 8, 2024

How does this line even compile:

graph.insert_anchor(outpoint.txid, unconf_anchor),

If unconf_anchor isn't even an Anchor how can you pass it to insert_anchor!?!?!?

@yanganto
Copy link
Contributor

yanganto commented Feb 10, 2024

If unconf_anchor isn't even an Anchor how can you pass it to insert_anchor!?!?!?

We will remove Anchor implementation for ChainPosition<A> to avoid the caller using UnconfirmChainPosition(u64) as an anchor to avoid malusage.

@yanganto yanganto linked a pull request Feb 10, 2024 that will close this issue
8 tasks
@evanlinjin
Copy link
Member Author

evanlinjin commented Feb 11, 2024

How does this line even compile:

graph.insert_anchor(outpoint.txid, unconf_anchor),

If unconf_anchor isn't even an Anchor how can you pass it to insert_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.

@evanlinjin
Copy link
Member Author

If unconf_anchor isn't even an Anchor how can you pass it to insert_anchor!?!?!?

We will remove Anchor implementation for ChainPosition<A> to avoid the caller using UnconfirmChainPosition(u64) as an anchor to avoid malusage.

There is no Anchor implementation for ChainPosition. #1338 (comment)

@yanganto
Copy link
Contributor

yeh, I misread it.

@notmandatory notmandatory added module-blockchain tests and removed bug Something isn't working labels Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

4 participants