-
Notifications
You must be signed in to change notification settings - Fork 329
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
chore: extract TestEnv
into separate crate
#1171
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
dbbe366
to
0be5338
Compare
TestEnv
into separate crateTestEnv
into separate crate
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 need to change the internals to use electrsd
so the test env can serve esplora
and electrum
as well.
Can use #979 as a reference to see what electrum-server methods we need.
I will look into this(). |
I think having reorg functions for all backends will help. I had to use a hack from Steve to implement reorg for electrum. You should see the code in #979. Read more here: https://bitcoin.stackexchange.com/questions/114044/how-can-i-simulate-a-reorg-for-testing. |
@vladimirfomene that's a great point. https://github.com/bitcoindevkit/bdk/blob/release/0.29/src/testutils/blockchain_tests.rs Maybe the old |
50c5ccd
to
12403a1
Compare
19cafee
to
2cadfd2
Compare
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.
Thanks for taking this forward. The code looks pretty good.
The documentation was a little lacking. It's important to communicate why things are implemented the way they are.
A simple electrsd reorg test was written and runs without having to pass in |
2cadfd2
to
c45a8f5
Compare
fb8ab29
to
f2af089
Compare
A |
6bb1a40
to
cc50303
Compare
1010efd fix(electrum): fixed chain sync issue (Wei Chen) Pull request description: ### Description This may or may not fix #1125. Fixed what appeared to be a logic error in `construct_update_tip` in `electrum_ext.rs` that caused the local chain tip to always be a block behind the newest confirmed block. ### 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 #### Bugfixes: * [ ] This pull request breaks the existing API * [x] I've added tests to reproduce the issue which are now passing * [x] I'm linking the issue being fixed by this PR ACKs for top commit: danielabrozzoni: ACK 1010efd - although I've been able to reproduce the issue in #1125, I'm convinced that this PR fixes at least a bug, as demonstrated in #1171 (yet to be reviewed and merged). Tree-SHA512: 92790e9072d17be74d2cd24bec3503e1ad5d97f728ee81490eeb09ac3f8d4a3a7e8d9628e943bc801246d5bfd345152c11d5dbe25246f5a57b3118727d3ae315
53186e2
to
2903697
Compare
I know that we're testing it in other crates. |
Now that #1351 is open, I made LagginTimes#1 to test stop_gap in |
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.
ACK 2903697
2903697
to
29ac879
Compare
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.
Overall looks like a great improvement, related tests are much easier to read too. I just have one comment/question about a CI change.
a09b56b
to
e8dc8d3
Compare
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.
ACK e8dc8d3
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.
Overall looks pretty good!
I just left one minor comment about the documentation that I was uncertain about, and a general question for further discussion.
@@ -744,7 +624,7 @@ fn mempool_during_reorg() -> anyhow::Result<()> { | |||
// emission. | |||
// TODO: How can have have reorg logic in `TestEnv` NOT blacklast old blocks first? |
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.
@LagginTimes general question: after this PR is merged, do you think we'll be able to solve this TODO ?
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.
Unfortunately no. This can be done in a follow-up PR!
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.
Cool, thanks!
`TestEnv` is extracted into its own crate to serve as a framework for testing other block explorer APIs.
Added scan and reorg tests to check electrum functionality using `TestEnv`.
e8dc8d3
to
04d0ab5
Compare
crates/esplora/Cargo.toml
Outdated
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] | ||
electrsd = { version= "0.25.0", features = ["bitcoind_25_0", "esplora_a33e97e1", "legacy"] } |
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.
Do we need to make the tests run in WASM? Because electrsd
is a mandatory dependency of bdk_testenv
.
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.
Right now for CI we only do a cargo check
for WASM and don't rerun the tests for that target. Since I haven't heard of any WASM issues that slipped through by not running the tests I don't think we need to change TestEnv
to work with WASM.
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.
ACK 04d0ab5
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.
ACK 04d0ab5
Great job, this will be a big help with testing.
None of the `bdk_esplora` tests can run under WASM anyway since we depend on `electrsd`.
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.
ACK 7c9ba3c
Description
TestEnv
is extracted into its own crate withelectrsd
support added so thatTestEnv
can also serveesplora
andelectrum
.The tests in the
esplora
crate have also been updated to useTestEnv
.The
tx_can_become_unconfirmed_after_reorg()
test intest_electrum
suggests that the electrum issue where a reorged tx would be stuck at confirmed does not exist anymore.Notes to the reviewers
The code for
tx_can_become_unconfirmed_after_reorg()
was adapted from the same test inbitcoind_rpc/test_emitter
. This electrum version of the test requires extra review, as I am uncertain if I used the API efficiently.All Submissions:
cargo fmt
andcargo clippy
before committing