Skip to content

Commit

Permalink
fix: nits in tests (#1750)
Browse files Browse the repository at this point in the history
* fix: nits in tests

* fix filter nit
  • Loading branch information
niklasad1 authored Sep 2, 2024
1 parent 3866737 commit e4f6f08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 0 additions & 4 deletions subxt/src/backend/rpc/reconnecting_rpc_client/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ use jsonrpsee::server::{

#[tokio::test]
async fn call_works() {
tracing_subscriber::fmt::init();
let (_handle, addr) = run_server().await.unwrap();
let client = RpcClient::builder().build(addr).await.unwrap();
assert!(client.request("say_hello".to_string(), None).await.is_ok(),)
}

#[tokio::test]
async fn sub_works() {
tracing_subscriber::fmt::init();
let (_handle, addr) = run_server().await.unwrap();

let client = RpcClient::builder()
Expand All @@ -44,7 +42,6 @@ async fn sub_works() {

#[tokio::test]
async fn sub_with_reconnect() {
tracing_subscriber::fmt::init();
let (handle, addr) = run_server().await.unwrap();
let client = RpcClient::builder().build(addr.clone()).await.unwrap();

Expand Down Expand Up @@ -89,7 +86,6 @@ async fn sub_with_reconnect() {

#[tokio::test]
async fn call_with_reconnect() {
tracing_subscriber::fmt::init();
let (handle, addr) = run_server_with_settings(None, true).await.unwrap();

let client = Arc::new(RpcClient::builder().build(addr.clone()).await.unwrap());
Expand Down
11 changes: 10 additions & 1 deletion testing/integration-tests/src/full_client/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ async fn partial_fee_estimate_correct() {
#[subxt_test]
async fn legacy_and_unstable_block_subscription_reconnect() {
let ctx = test_context_reconnecting_rpc_client().await;

let api = ctx.unstable_client().await;

let unstable_client_blocks = move |num: usize| {
Expand All @@ -425,6 +424,16 @@ async fn legacy_and_unstable_block_subscription_reconnect() {
.subscribe_finalized()
.await
.unwrap()
// Ignore `disconnected events`.
// This will be emitted by the legacy backend for every reconnection.
.filter(|item| {
let disconnected = match item {
Ok(_) => false,
Err(e) => e.is_disconnected_will_reconnect(),
};

futures::future::ready(!disconnected)
})
.take(num)
.map(|x| x.unwrap().hash().to_string())
.collect::<Vec<String>>()
Expand Down

0 comments on commit e4f6f08

Please sign in to comment.