Skip to content

Commit

Permalink
cleaned tx count
Browse files Browse the repository at this point in the history
  • Loading branch information
antiyro committed May 23, 2024
1 parent 7239f32 commit f7227fe
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions unit_tests/tests/test_get_block_transaction_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ async fn fail_non_existing_block(clients: HashMap<String, JsonRpcClient<HttpTran
async fn work_with_latest_block(clients: HashMap<String, JsonRpcClient<HttpTransport>>) {
let deoxys = &clients[DEOXYS];
let pathfinder = &clients[PATHFINDER];
let juno = &clients[JUNO];

let block_tag = BlockId::Tag(BlockTag::Latest);

Expand All @@ -59,12 +60,20 @@ async fn work_with_latest_block(clients: HashMap<String, JsonRpcClient<HttpTrans
.await
.expect("Error waiting for response from Pathfinder node");

let response_juno = juno
.get_block_transaction_count(block_tag)
.await
.expect("Error waiting for response from Juno node");

assert_eq!(response_juno, response_deoxys);
assert_eq!(response_deoxys, response_pathfinder);
assert_eq!(response_pathfinder, response_juno);
}

async fn work_with_block(
deoxys: JsonRpcClient<HttpTransport>,
pathfinder: JsonRpcClient<HttpTransport>,
juno: JsonRpcClient<HttpTransport>,
block_number: u64,
) {
let block_number = BlockId::Number(block_number);
Expand All @@ -79,23 +88,32 @@ async fn work_with_block(
.await
.expect("Error waiting for response from Pathfinder node");

let response_juno = juno
.get_block_transaction_count(block_number)
.await
.expect("Error waiting for response from Juno node");

assert_eq!(response_juno, response_deoxys);
assert_eq!(response_deoxys, response_pathfinder);
assert_eq!(response_pathfinder, response_juno);
}

#[rstest]
#[tokio::test]
async fn work_with_block_1(
deoxys: JsonRpcClient<HttpTransport>,
pathfinder: JsonRpcClient<HttpTransport>,
juno: JsonRpcClient<HttpTransport>
) {
work_with_block(deoxys, pathfinder, 1).await;
work_with_block(deoxys, pathfinder, juno, 1).await;
}

#[rstest]
#[tokio::test]
async fn work_with_block_1_hash(clients: HashMap<String, JsonRpcClient<HttpTransport>>) {
let deoxys = &clients[DEOXYS];
let pathfinder = &clients[PATHFINDER];
let juno = &clients[JUNO];

let block_hash = BlockId::Hash(
FieldElement::from_hex_be(
Expand All @@ -114,32 +132,42 @@ async fn work_with_block_1_hash(clients: HashMap<String, JsonRpcClient<HttpTrans
.await
.expect("Error waiting for response from Pathfinder node");

let response_juno = juno
.get_block_transaction_count(block_hash)
.await
.expect("Error waiting for response from Juno node");

assert_eq!(response_juno, response_deoxys);
assert_eq!(response_deoxys, response_pathfinder);
assert_eq!(response_pathfinder, response_juno);
}

#[rstest]
#[tokio::test]
async fn work_with_block_5066(
deoxys: JsonRpcClient<HttpTransport>,
pathfinder: JsonRpcClient<HttpTransport>,
juno: JsonRpcClient<HttpTransport>
) {
work_with_block(deoxys, pathfinder, 1).await;
work_with_block(deoxys, pathfinder, juno, 1).await;
}

#[rstest]
#[tokio::test]
async fn work_with_block_100_000(
deoxys: JsonRpcClient<HttpTransport>,
pathfinder: JsonRpcClient<HttpTransport>,
juno: JsonRpcClient<HttpTransport>
) {
work_with_block(deoxys, pathfinder, 100_000).await;
work_with_block(deoxys, pathfinder, juno, 100_000).await;
}

#[rstest]
#[tokio::test]
async fn work_with_block_100_000_hash(clients: HashMap<String, JsonRpcClient<HttpTransport>>) {
let deoxys = &clients[DEOXYS];
let pathfinder = &clients[PATHFINDER];
let juno = &clients[JUNO];

let block_hash = BlockId::Hash(
FieldElement::from_hex_be(
Expand All @@ -158,7 +186,14 @@ async fn work_with_block_100_000_hash(clients: HashMap<String, JsonRpcClient<Htt
.await
.expect("Error waiting for response from Pathfinder node");

let response_juno = juno
.get_block_transaction_count(block_hash)
.await
.expect("Error waiting for response from Juno node");

assert_eq!(response_juno, response_deoxys);
assert_eq!(response_deoxys, response_pathfinder);
assert_eq!(response_pathfinder, response_juno);
}

#[rstest]
Expand Down

0 comments on commit f7227fe

Please sign in to comment.