forked from bitcoindevkit/bdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge bitcoindevkit#1064: Better tests for transaction conflict handling
6d601a7 test(chain): Add test for conflicting transactions (Daniela Brozzoni) 48ca95b test(chain): Add test for walk_ancestors (Daniela Brozzoni) 59a2403 test(chain): Introduce TxTemplate (Daniela Brozzoni) 6e51147 test(chain): add block_id! utility macro (Daniela Brozzoni) 62de55f fix(chain): Consider conflicting ancestors in... ...try_get_chain_pos (Daniela Brozzoni) a3e8480 doc(chain): Clarify direct_conflicts_of_tx's docs (Daniela Brozzoni) 4742d88 feat(chain): Introduce TxAncestors, walk_ancestors (Daniela Brozzoni) 2f26eca fix(chain): TxDescendants performs a BFS (Daniela Brozzoni) 486e0e1 doc(chain): Fix typos (Daniela Brozzoni) Pull request description: <!-- You can erase any parts of this template not applicable to your Pull Request. --> ### Description Fixes bitcoindevkit#1063. This PR introduces a new `TxTemplate` struct to test different transaction conflict scenarios in `TxGraph`. The following transaction conflict scenarios are tested: - 2 unconfirmed txs with different last_seens conflict. The most recent tx should be the only tx that appears in the list methods. - 3 unconfirmed txs with different last_seens conflict. The most recent tx should be the only tx that appears in the list methods. - An unconfirmed tx U conflicts with a tx anchored in orphaned block O. O has higher last_seen. O should be the only tx that appears in the list methods. - An unconfirmed tx U conflicts with a tx anchored in orphaned block O. U has higher last_seen. U should be the only tx that appears in the list methods. - Multiple unconfirmed txs conflict with a confirmed tx. None of the unconfirmed txs should appear in the list methods. - B and B' conflict. C spends B. B' is anchored in best chain. B and C should not appear in the list methods. - B and B' conflict. C spends B. B is anchored in best chain. B' should not appear in the list methods. - B and B' conflict. C spends both B and B'. C is impossible. - B and B' conflict. C spends both B and B'. C is impossible. B' is confirmed. - B and B' conflict. C spends both B and B'. C is impossible. D spends C. These tests revealed that `TxGraph::walk_conflicts` was not checking ancestors of the root tx for conflicts. `TxGraph::walk_conflicts` has been refactored to check for conflicting ancestor transactions by using a new `TxAncestors` iterator in `TxGraph`. ### Changelog notice - Introduced `tx_template` module - Introduced `TxGraph::TxAncestors` iterator - Refactored `TxGraph::walk_conflicts` to use `TxGraph::TxAncestors` - Added `walk_ancestors` to `TxGraph` ### Checklists All Submissions: - [x] I've signed all my commits - [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) - [x] I ran cargo fmt and cargo clippy before committing #### New Features: * [x] I've added tests for the new feature * [x] I've added docs for the new feature ACKs for top commit: evanlinjin: ACK 6d601a7 Tree-SHA512: ea151392874c4312233e4e10299579f4eee4a7100ae344b4d7f19994284b49c1e43f37338bed931d16e77326021166ea0b94d6de3ccf50a8fabb25139a8e69b4
- Loading branch information
Showing
5 changed files
with
1,212 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.