-
Notifications
You must be signed in to change notification settings - Fork 352
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
Test conflicting tx situations. #964
Conversation
Looks like this one needs a |
No dependencies, I saw that CI wasn't passing so didn't review. |
544e843
to
32de63c
Compare
The following tests are included - Mempool conflicts are chosen by latest last seen. - Conflicts in mempool and orphaned block, filters out the orphaned block tx. - Conflicts with mempool and confirmed tx, filters out mempool. - Conflicts with two mempool tx at same `seen_at`. This currently lists both the txs. A potential fix in mentioned in the comments. Some helper functions in the common module.
32de63c
to
fe7bba1
Compare
My bad. Had the fmt fix, but forgot to push. This had a dependency on #963 as the Anchor type changed. Fixed now.. |
Will look at this first thing tomorrow. |
// We only have one utxo. The latest `tx_conflict_2`. | ||
assert_eq!( | ||
utxos.pop().unwrap().chain_position, | ||
ObservedAs::Unconfirmed(200) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why could we not assert
all of utxo
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can, but will make the tests code too verbose. The point here is to test various txout positions. If we wanna test the whole structure of FullTxOut
, could be done in a separate test.
@rajarshimaitra as we discussed. struct TxTemplate<'a, K> {
pub tx_name: &'a str,
pub spends: &'a [(&'a str, usize)], // (tx_name, vout)
pub outputs: &'a [TxOutTemplate<K>],
pub anchors: &'a [(u32, BlockId)],
pub last_seen: Option<u64>,
}
struct TxOutTemplate<K> {
pub value: u64,
pub owned_spk: Option<(K, u32)>, // some = derive a spk from K, none = random spk
}
fn init_graph<'a, K: 'a>(
descriptors: HashMap<K, Descriptor<DescriptorPublicKey>>,
tx_templates: impl IntoIterator<Item = TxTemplate<'a, K>>,
) -> (
IndexedTxGraph<ConfirmationHeightAnchor, KeychainTxOutIndex<K>>,
HashMap<&'a str, Txid>,
) {
todo!()
}
#[test]
fn example_test() {
struct TestCase<'a, K> {
tx_templates: &'a [TxTemplate<'a, K>],
chain_tip: BlockId,
expected_list_chain_txs: (),
}
} |
@LagginTimes Could you take over on this? |
Sure, I can start looking into this. |
@LagginTimes any updates on this? should I keep it in the alpha.1 milestone? |
Replaced by #1064 |
Description
partial fixes #958 . These tests attempt to cover all the conflicting scenarios.
The following tests are included:
seen_at
.Some helper functions in the common module.
Notes to the reviewers
As noted by @evanlinjin on the test description.
A possible solution for this situation is mentioned in the comment of the last test, which covers this case. I will attempt a PR to enforce the behavior if that is a reasonable approach.
Changelog notice
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committing