Skip to content
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

testing: Prepare light client testing with substrate binary and add subxt-test macro #1507

Merged
merged 44 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
34e9222
testing: Add long running light client flag and cfg aliases
lexnv Feb 29, 2024
518aa8e
testing: Expose clients depending on feature flags
lexnv Feb 29, 2024
ea6f3cc
subxt: Use unstable backend for light client
lexnv Feb 29, 2024
ca36ef6
testing: Disable flaky lightclient tests
lexnv Feb 29, 2024
8fe7e86
ci: Add long runnnig step
lexnv Feb 29, 2024
593fbeb
Revert "subxt: Use unstable backend for light client"
lexnv Feb 29, 2024
1fc1bb4
ci: Long running tests for 60 mins
lexnv Feb 29, 2024
ca60c31
ci: Use 16 cores for light-client testing
lexnv Feb 29, 2024
3c58c5e
ci: Isolate light-client testing to save CI minutes
lexnv Feb 29, 2024
0248343
testing: Retry on Tx::Dropped for lightclinet only
lexnv Mar 1, 2024
8400a0e
testing: Wait for more blocks for the lightclient init
lexnv Mar 1, 2024
d671664
subxt: Use unstable backend for light client
lexnv Feb 29, 2024
318ba5c
testing: Disable legacy RPC tests
lexnv Mar 1, 2024
1a6f1af
testing: Disable sudo and contracts tests
lexnv Mar 1, 2024
332fa72
testing: Retry constructing lightclient on read-proof errors
lexnv Mar 1, 2024
88ccc54
testing: Disable tx dynamic test
lexnv Mar 1, 2024
b6c98c7
proc-macro: Timeout for tests
lexnv Mar 1, 2024
20e75bc
testing: Add timeout 800 seconds
lexnv Mar 1, 2024
c5c7972
proc-macro/tests: Adjust subxt-test proc-macro
lexnv Mar 4, 2024
d3923c8
proc-macro: Rename crate to subxt-test-proc-macro
lexnv Mar 5, 2024
1a64750
Use default subxt-proc-macro timeout
lexnv Mar 5, 2024
4c3226e
light-client: Remove println
lexnv Mar 5, 2024
fbe2a74
subxt: Remove tokio as dependency, use it only for testing
lexnv Mar 5, 2024
30073d3
testing: Chagne default timeout to 6 seconds
lexnv Mar 5, 2024
aa55cea
proc-macro: Add env timeout variable
lexnv Mar 6, 2024
09277fe
ci: Add subxt env var for controling test timeouts
lexnv Mar 6, 2024
5039f1c
tests/tx-retries: Retry on `Non node available` error
lexnv Mar 6, 2024
410aaed
Merge remote-tracking branch 'origin/master' into lenxv/light-client-…
lexnv Mar 26, 2024
d81c70c
testing: Use unstable backend for testing lightclient
lexnv Mar 26, 2024
00c4b78
testing: Remove old lightclient object
lexnv Mar 26, 2024
03da904
testing: Adjust for the new interface
lexnv Mar 26, 2024
292f971
backend/rpc: Allow older version of the initialized event
lexnv Mar 27, 2024
2bc8947
rpc/tests: Check initialized decodes correctly
lexnv Mar 28, 2024
811f70c
ci: Reset workflow
lexnv Mar 28, 2024
2bb8acb
Apply cargo fmt
lexnv Mar 28, 2024
1fdd734
Remove unused dep
lexnv Mar 28, 2024
1bc6eb9
Merge remote-tracking branch 'origin/master' into lexnv/light-client-…
lexnv Mar 28, 2024
5692703
Remove gitmerge old file
lexnv Mar 28, 2024
fd47be1
Remove unused dep
lexnv Mar 28, 2024
be4b34c
rename proc-macro to subxt-test-macro
lexnv Apr 2, 2024
7270da8
tests: Remove txretries for lightclient
lexnv Apr 3, 2024
a62ceb7
tests: Wait for 5 blocks for the lightclient full testing suite
lexnv Apr 3, 2024
7664b56
tests: Group imports
lexnv Apr 8, 2024
510578f
macro: Rename const value
lexnv Apr 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
subxt: Remove tokio as dependency, use it only for testing
Signed-off-by: Alexandru Vasile <[email protected]>
  • Loading branch information
lexnv committed Mar 5, 2024
commit fbe2a7498be9834dfec131b63b81359713fe37ca
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions subxt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ unstable-metadata = []

# Activate this to expose the Light Client functionality.
# Note that this feature is experimental and things may break or not work as expected.
unstable-light-client = ["subxt-lightclient", "tokio-stream", "tokio"]
unstable-light-client = ["subxt-lightclient", "tokio-stream"]

[dependencies]
async-trait = { workspace = true }
Expand Down Expand Up @@ -117,7 +117,6 @@ getrandom = { workspace = true, optional = true }

# Included if "native" feature is enabled
tokio-util = { workspace = true, features = ["compat"], optional = true }
tokio = { workspace = true, features = ["macros", "time", "rt-multi-thread"], optional = true }

[dev-dependencies]
bitvec = { workspace = true }
Expand All @@ -129,6 +128,7 @@ sp-keyring = { workspace = true }
sp-runtime = { workspace = true }
assert_matches = { workspace = true }
subxt-signer = { path = "../signer" }
wasm-bindgen-futures = { workspace = true }
# Tracing subscriber is useful for light-client examples to ensure that
# the `bootNodes` and chain spec are configured correctly. If all is fine, then
# the light-client wlll emit INFO logs with
Expand Down
56 changes: 36 additions & 20 deletions subxt/src/client/light_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,43 @@ impl RawLightClient {
let raw_rpc = self.raw_rpc.for_chain(chain_id);
let rpc_client = RpcClient::new(raw_rpc.clone());

use crate::backend::unstable::UnstableBackend;
use std::sync::Arc;
let (backend, mut driver) = UnstableBackend::builder().build(rpc_client);
let future = async move {
use futures::StreamExt;
while let Some(val) = driver.next().await {
if let Err(e) = val {
// This is a test; bail if something does wrong and try to
// ensure that the message makes it to some logs.
panic!("Error driving unstable backend in tests: {e}");
// Production code should use the legacy backend.
#[cfg(not(test))]
async fn build_online_client<TChainConfig: Config>(
rpc_client: RpcClient,
) -> Result<OnlineClient<TChainConfig>, crate::Error> {
OnlineClient::<TChainConfig>::from_rpc_client(rpc_client).await
}

// For testing we are only interested in using the unstable-backend with
// the lightclient.
#[cfg(test)]
async fn build_online_client<TChainConfig: Config>(
rpc_client: RpcClient,
) -> Result<OnlineClient<TChainConfig>, crate::Error> {
use crate::backend::unstable::UnstableBackend;
use std::sync::Arc;
let (backend, mut driver) = UnstableBackend::builder().build(rpc_client);
let future = async move {
use futures::StreamExt;
while let Some(val) = driver.next().await {
if let Err(e) = val {
// This is a test; bail if something does wrong and try to
// ensure that the message makes it to some logs.
panic!("Error driving unstable backend in tests: {e}");
}
}
}
};
// The unstable backend needs driving:
#[cfg(feature = "native")]
tokio::spawn(future);
#[cfg(feature = "web")]
wasm_bindgen_futures::spawn_local(future);
let client = OnlineClient::from_backend(Arc::new(backend))
.await
.map_err(|e| format!("Cannot construct OnlineClient from backend: {e}"))?;
};
// The unstable backend needs driving:
#[cfg(feature = "native")]
tokio::spawn(future);
#[cfg(feature = "web")]
wasm_bindgen_futures::spawn_local(future);

OnlineClient::from_backend(Arc::new(backend)).await
}

let client = build_online_client(rpc_client).await?;

Ok(LightClient { client, chain_id })
}
Expand Down