Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
haider-rs committed Feb 11, 2025
1 parent 4479eeb commit d6004e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions tc-subxt/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ where
},
Some(Err(e)) => {
tracing::error!("Error processing finalized blocks: {:?}", e);
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
continue;
},
None => {
Expand Down Expand Up @@ -409,6 +410,7 @@ where
},
Some(Err(e)) => {
tracing::error!("Error processing block: {:?}", e);
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
continue;
},
None => {
Expand Down
12 changes: 7 additions & 5 deletions tc-subxt/tests/test_cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ async fn test_transaction_mortality_outage_flow() {
}

#[tokio::test]
#[ignore]
// not working tbf
async fn test_transaction_mortality_outage_flow_100() {
let total_tasks: usize = 100;
async fn test_transaction_mortality_outage_flow_50() {
let total_tasks: usize = 50;
let env = new_env().await;
let mut receivers = VecDeque::new();
// init 100 transactions
Expand All @@ -85,9 +86,9 @@ async fn test_transaction_mortality_outage_flow_100() {
let hashes = wait_for_submission(&env.client, total_tasks).await;
assert!(hashes.len() == total_tasks);
env.client.inc_empty_blocks(MORTALITY / 2).await;
tokio::time::sleep(Duration::from_millis(100)).await;
tokio::time::sleep(Duration::from_secs(1)).await;
env.client.inc_empty_blocks(MORTALITY / 2).await;
tokio::time::sleep(Duration::from_millis(100)).await;
tokio::time::sleep(Duration::from_secs(1)).await;
env.client.inc_empty_blocks(1).await;
let hashes = wait_for_submission(&env.client, total_tasks + total_tasks).await;
assert_eq!(hashes[0], hashes[total_tasks + 1]);
Expand All @@ -102,7 +103,7 @@ async fn test_transaction_mortality_outage_flow_100() {
#[tokio::test]
async fn test_tc_subxt_db_ops() {
let env = new_env().await;
let (tx, _) = oneshot::channel();
let (tx, rx) = oneshot::channel();
env.tx_sender.unbounded_send((Tx::Ready { shard_id: 0 }, tx)).unwrap();
let hashes = wait_for_submission(&env.client, 1).await;
assert!(hashes.len() == 1);
Expand All @@ -111,6 +112,7 @@ async fn test_tc_subxt_db_ops() {
assert!(txs.len() == 1);
assert_eq!(txs[0].hash, hashes[0]);
env.client.inc_block_with_tx(hashes[0], true).await;
let _ = rx.await.unwrap();
let txs = env.db.load_pending_txs(0).unwrap();
assert!(txs.len() == 0);

Check failure on line 117 in tc-subxt/tests/test_cases.rs

View workflow job for this annotation

GitHub Actions / test-clippy

error: length comparison to zero --> tc-subxt/tests/test_cases.rs:117:10 | 117 | assert!(txs.len() == 0); | ^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `txs.is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero = note: `-D clippy::len-zero` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::len_zero)]`
}
Expand Down

0 comments on commit d6004e3

Please sign in to comment.