-
Notifications
You must be signed in to change notification settings - Fork 38.7k
test: add assumeutxo wallet test #28838
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
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
test/functional/wallet_assumeutxo.py
Outdated
| for n in self.nodes: | ||
| assert_equal(n.getblockchaininfo()["headers"], SNAPSHOT_BASE_HEIGHT) | ||
|
|
||
| w.backupwallet("/tmp/abc.dat") |
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.
My diff was a hack, obviously. I don't think it makes sense to escape the datadir "sandbox" and potentially overwrite user data when running a test.
test/functional/wallet_assumeutxo.py
Outdated
|
|
||
| ## Possible test improvements | ||
|
|
||
| - TODO: the "assumed" field for a confirmed wallet transaction should be |
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.
Seems odd to add a TODO to add a test based on a feature that doesn't even exist.
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.
Dropped
test/functional/wallet_assumeutxo.py
Outdated
|
|
||
| self.sync_blocks() | ||
|
|
||
| n0.createwallet('test',blank=True, disable_private_keys=True, descriptors=True) |
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.
nit: blank may not be needed? Also, could run a python formatter on this file to fix the whitespace?
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.
Might indeed just give the wallet some keys, so later tests can have transactions and rescans.
Which formatter? Ah PEP-8 https://github.com/bitcoin/bitcoin/tree/master/test/functional#style-guidelines
0b81433 to
f4f3a0c
Compare
|
Pushed some cleanups. |
test/functional/wallet_assumeutxo.py
Outdated
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.
Could add a comment why this is needed?
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.
It's not. Replaced with a TODO comment to add wallet test for a pruned node.
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.
It doesn't seem like this was pushed?
test/functional/wallet_assumeutxo.py
Outdated
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.
Also dropping this import since the wallet is no longer watch-only. I added a TODO instead to test scenarios like when you import a descriptor with existing transactions while background sync is in progress.
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.
It doesn't seem like this was pushed?
Co-Authored-By: MarcoFalke <*~=`'#}+{/-|&$^[email protected]>
pablomartin4btc
left a comment
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.
|
lgtm ACK f4f3a0c910a148a158e1879f8c9e6767575539db |
f4f3a0c to
997b9a7
Compare
|
@achow101 good catch, I indeed forgot to push. @pablomartin4btc I think he likes it this way |
BrandonOdiwuor
left a comment
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.
Concept ACK
|
Concept ACK Will review in a bit. As a follow-up idea, maybe we could put the AssumeUTXO chain and snapshot creation in a shared module, in order to deduplicate code between feature_assumeutxo.py and wallet_assumeutxo.py? If we ever wanted to change the snapshot chainstate for e.g. more advanced tests, it'd be quite annoying having to touch several files. |
…fter loading 9315754 test: assumeutxo: spend coin from snapshot chainstate after loading (Sebastian Falbesoner) Pull request description: This PR extends the AssumeUTXO functional test by submitting a spending transaction for an UTXO that is only available in a the snapshot chainstate (after loading via `loadtxoutset`), i.e. it hasn't been seen in a block before. With that we can verify that snapshot coins are visible to the mempool. Note that we unfortunately can't use MiniWallet here, as the only available UTXO to spend from the snapshot chainstate is at height 200, where a P2PKH created from the test framework's deterministic private key is used (see `TestNode.generate(...)` and the `PRIV_KEYS` array). Coinbase outputs with smaller heights (<= 199) would be part of the pre-generated chain and hence not qualify for the "UTXO is only in snapshot chainstate and has never been seen in a block" scenario, coinbase outputs with larger heights (>= 201) can't be spent due to immaturity, as the snapshot chainstate block height is 299. One could of course mine a different chain with outputs that MiniWallet supports (e.g. taproot anyone-can-spend), but this would change the hardcoded AssumeUTXO hash, colliding with other PRs like #28838, so I wanted to avoid that. ACKs for top commit: maflcko: lgtm ACK 9315754 jamesob: ACK 9315754 Tree-SHA512: 0665868e1e91fe74f408d0a239cc264bbbc11a6b55bcc0e86cc8b4b2ec1f44977884b817dbe9065a7c768332cab464636656858bc8b9c8e7d7810498e0a17d78
theStack
left a comment
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.
Code-review ACK 997b9a7
Also ran the test locally.
| assert_equal(n.getblockchaininfo()[ | ||
| "headers"], SNAPSHOT_BASE_HEIGHT) |
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.
nit: looks like an unintended newline here?
| assert_equal(n.getblockchaininfo()[ | |
| "headers"], SNAPSHOT_BASE_HEIGHT) | |
| assert_equal(n.getblockchaininfo()["headers"], SNAPSHOT_BASE_HEIGHT) |
|
lgtm ACK 997b9a7 |
|
ACK 997b9a7 |
|
Posthumous ACK 997b9a7 Was just in the middle of reviewing this and figuring out how to add some balance checks. May file a followup. |
|
| assert_equal(n.getblockchaininfo()[ | ||
| "headers"], SNAPSHOT_BASE_HEIGHT) | ||
|
|
||
| w.backupwallet("backup_w.dat") |
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.
@jamesob I think you can just close the wallet after this call?
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.
From reading the test again (it's a been a while) I don't think we care about this loaded wallet w anymore.
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.
I don't think the problem is that the original wallet is open. The error is the path for the restored wallet on node1, not the original on node0.
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.
I see (just saw the log in #29234).
Sounds like the node that made the backup holds on to it after writing? Maybe restart the node (n0)? Or copy the backup file?
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.
Sounds like the node that made the backup holds on to it after writing? Maybe restart the node? Or copy the backup file?
We don't remove the backup. The failure is in cleaning up the restored wallet after it fails to restore. The backup file is copied to a new path, and that is what remove_all is trying to remove.
I think it's more likely that the database isn't fully closed yet even though the CWallet should be destructed.
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.
Ok, so it has nothing to do with what n0 did. I'm surprised none of the other wallet backup & restore tests have this issue. But I guess it's a different failure condition.
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.
It looks like we don't have any other tests that have a failure in CWallet::Create, which I don't think is that surprising since generally the wallet needs to be corrupted for that to happen.
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.
I think it's more likely that the database isn't fully closed yet even though the
CWalletshould be destructed.
Maybe it's because of -unsafesqlitesync, going to try turning that off for the test.
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.
I wonder why it's called unsafe :-)
Extracted from #28616, this adds a (very) basic wallet test for assume utxo. It checks some circumstances where a backup can and can't be loaded.