Skip to content

[Bug] Esplora reqwest blockchain tests are failing #431

Closed

Description

@rajarshimaitra

Bug

It seems that esplora-reqwest blockchain tests have been failing for some time now.

The CI missed it because all the esplora tests were being skipped.

The major sources of failure are async related. Especially calling async functions in bdk_blockchain_tests macro.

Error sample

error[E0599]: no method named `unwrap` found for opaque type `impl futures::Future` in the current scope
   --> src/testutils/blockchain_tests.rs:875:52
    |
875 |                   wallet.sync(noop_progress(), None).unwrap();
    |                                                      ^^^^^^ method not found in `impl futures::Future`
    | 
   ::: src/blockchain/esplora/mod.rs:125:1
    |
125 | / crate::bdk_blockchain_tests! {
126 | |     fn test_instance(test_client: &TestClient) -> EsploraBlockchain {
127 | |         EsploraBlockchain::new(&format!("http://{}",test_client.electrsd.esplora_url.as_ref().unwrap()), 20)
128 | |     }
129 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider `await`ing on the `Future` and calling the method on its `Output`
    |
875 |                 wallet.sync(noop_progress(), None).await.unwrap();
    |                                                    ^^^^^^

error: aborting due to 58 previous errors

Some errors have detailed explanations: E0195, E0308, E0599.
For more information about an error, try `rustc --explain E0195`.

Reproduce:

Edit test-esplora feature in cargo like test-esplora = ["use-esplora-reqwest", "electrsd/legacy", "electrsd/esplora_a33e97e1", "test-blockchains"].

then run cargo test --features test-esplora

Analysis

As far as I understand, its happening because in the test macro we are calling wallet APIs in non async mode, whereas, for esplora-reqwest these are async functions.

fn get_wallet_from_descriptors(descriptors: &(String, Option<String>), test_client: &TestClient) -> Wallet<$blockchain, MemoryDatabase> {
Wallet::new(&descriptors.0.to_string(), descriptors.1.as_ref(), Network::Regtest, MemoryDatabase::new(), get_blockchain(test_client)).unwrap()
}

Thoughts

I tried putting in the maybe_async and maybe_await macros where applicable. But #[test] are not allowed to be async (or at least the vanilla flavour of them).

we can have async tests but with using tokio directly. But then, they cannot be non-async anymore.

Or maybe we can create some proc macros like #[maybe_async_test]?

I noticed this issue few weeks back in bdk-cli bitcoindevkit/bdk-cli#36 (comment). Was confused why I couldn't reproduce it in BDK. The reason is the current test-esplora feature is broken, and is not compiling the blockchian tests. This is now fixed with #430

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions