-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#![feature(assert_matches)] | ||
|
||
mod common; | ||
use common::*; | ||
|
||
use std::assert_matches::assert_matches; | ||
use rand::Rng; | ||
|
||
use starknet_core::types::{FieldElement, StarknetError, BlockId}; | ||
use starknet_providers::{ | ||
jsonrpc::{HttpTransport, JsonRpcClient}, | ||
Provider, ProviderError, | ||
}; | ||
|
||
#[rstest] | ||
#[tokio::test] | ||
async fn fail_non_existing_block(deoxys: JsonRpcClient<HttpTransport>) { | ||
|
||
assert_matches!( | ||
deoxys.trace_block_transactions(BlockId::Hash(FieldElement::ZERO)).await, | ||
Err(ProviderError::StarknetError(StarknetError::BlockNotFound)) | ||
); | ||
} | ||
|
||
#[rstest] | ||
#[tokio::test] | ||
async fn works_ok_for_block_10000(deoxys: JsonRpcClient<HttpTransport>, pathfinder: JsonRpcClient<HttpTransport>) { | ||
|
||
let block_number = BlockId::Number(10000); | ||
|
||
let deoxys_trace = deoxys.trace_block_transactions(block_number).await; | ||
let _pathfinder_trace = pathfinder.trace_block_transactions(block_number).await; | ||
|
||
assert_matches!(deoxys_trace, _pathfinder_trace); | ||
} | ||
|
||
#[rstest] | ||
#[tokio::test] | ||
async fn works_ok_for_block_300000(deoxys: JsonRpcClient<HttpTransport>, pathfinder: JsonRpcClient<HttpTransport>) { | ||
|
||
let block_number = BlockId::Number(300000); | ||
|
||
let deoxys_trace = deoxys.trace_block_transactions(block_number).await; | ||
let _pathfinder_trace = pathfinder.trace_block_transactions(block_number).await; | ||
|
||
assert_matches!(deoxys_trace, _pathfinder_trace); | ||
} | ||
|
||
#[rstest] | ||
#[tokio::test] | ||
async fn works_ok_for_random_block(deoxys: JsonRpcClient<HttpTransport>, pathfinder: JsonRpcClient<HttpTransport>) { | ||
let mut rng = rand::thread_rng(); | ||
let random_block_number = rng.gen_range(100000..602000); | ||
|
||
let block_number = BlockId::Number(random_block_number); | ||
|
||
let deoxys_trace = deoxys.trace_block_transactions(block_number).await; | ||
let _pathfinder_trace = pathfinder.trace_block_transactions(block_number).await; | ||
println!("{:?}", deoxys_trace); | ||
println!("block choose is: {:?}", block_number); | ||
|
||
assert_matches!(deoxys_trace, _pathfinder_trace); | ||
} |