Skip to content

Commit

Permalink
feat: 🎨 fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbelleng committed Apr 23, 2024
1 parent 9682787 commit 0224223
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 22 deletions.
20 changes: 16 additions & 4 deletions unit_tests/tests/test_get_storage_at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,28 @@ async fn work_get_storage(clients: HashMap<String, JsonRpcClient<HttpTransport>>
// TODO: get contract key from field name
let response_deoxys = deoxys
.get_storage_at(
FieldElement::from_hex_be("0x06c780b25d325d49e08175b47d3bc93c53323917d7df3a8084d387d63e84a49b").unwrap(),
FieldElement::from_hex_be("0x0000000000000000000000000000000000000000000000000000000000000005").unwrap(),
FieldElement::from_hex_be(
"0x06c780b25d325d49e08175b47d3bc93c53323917d7df3a8084d387d63e84a49b",
)
.unwrap(),
FieldElement::from_hex_be(
"0x0000000000000000000000000000000000000000000000000000000000000005",
)
.unwrap(),
BlockId::Number(2000),
)
.await
.expect("Error waiting for response from Deoxys client");
let response_pathfinder = pathfinder
.get_storage_at(
FieldElement::from_hex_be("0x06c780b25d325d49e08175b47d3bc93c53323917d7df3a8084d387d63e84a49b").unwrap(),
FieldElement::from_hex_be("0x0000000000000000000000000000000000000000000000000000000000000005").unwrap(),
FieldElement::from_hex_be(
"0x06c780b25d325d49e08175b47d3bc93c53323917d7df3a8084d387d63e84a49b",
)
.unwrap(),
FieldElement::from_hex_be(
"0x0000000000000000000000000000000000000000000000000000000000000005",
)
.unwrap(),
BlockId::Number(2000),
)
.await
Expand Down
14 changes: 12 additions & 2 deletions unit_tests/tests/test_get_transaction_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,22 @@ async fn work_transaction_accepted_on_l1(clients: HashMap<String, JsonRpcClient<
let pathfinder = &clients[PATHFINDER];

let response_deoxys = deoxys
.get_transaction_status(FieldElement::from_hex_be("0x02cdada29d741a0e0308ce56ac23376d7ca735474d53b2d5da0400b8eab0c7aa").unwrap())
.get_transaction_status(
FieldElement::from_hex_be(
"0x02cdada29d741a0e0308ce56ac23376d7ca735474d53b2d5da0400b8eab0c7aa",
)
.unwrap(),
)
.await
.expect(ERR_DEOXYS);

let response_pathfinder = pathfinder
.get_transaction_status(FieldElement::from_hex_be("0x02cdada29d741a0e0308ce56ac23376d7ca735474d53b2d5da0400b8eab0c7aa").unwrap())
.get_transaction_status(
FieldElement::from_hex_be(
"0x02cdada29d741a0e0308ce56ac23376d7ca735474d53b2d5da0400b8eab0c7aa",
)
.unwrap(),
)
.await
.expect(ERR_PATHFINDER);

Expand Down
37 changes: 21 additions & 16 deletions unit_tests/tests/test_trace_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ use starknet_providers::{
Provider,
};


#[rstest]
#[tokio::test]
async fn fail_non_existing_hash(deoxys: JsonRpcClient<HttpTransport>) {
let transaction_hash = FieldElement::from_hex_be(
"0x02x02d6f0d7sbc71bsc629cde0w8199ccfb6er8343a76943475405817737f76c",
)
.unwrap(); // non-existent transaction hash

let transaction_hash = FieldElement::from_hex_be("0x02x02d6f0d7sbc71bsc629cde0w8199ccfb6er8343a76943475405817737f76c").unwrap(); // non-existent transaction hash

let response_deoxys = deoxys
.trace_transaction(transaction_hash)
.await;
let response_deoxys = deoxys.trace_transaction(transaction_hash).await;

assert!(
response_deoxys.is_err(),
"Expected an error, but got a result"
);

if let Err(error) = response_deoxys {
let is_correct_error = checking_error_format(&error, StarknetError::TransactionHashNotFound);
let is_correct_error =
checking_error_format(&error, StarknetError::TransactionHashNotFound);

assert!(
is_correct_error,
Expand All @@ -42,12 +42,12 @@ async fn fail_non_existing_hash(deoxys: JsonRpcClient<HttpTransport>) {
#[rstest]
#[tokio::test]
async fn fail_no_trace_available(deoxys: JsonRpcClient<HttpTransport>) {
let transaction_hash = FieldElement::from_hex_be(
"0x2062dc37facfcc3bed03163dbbde0e3874bf8b231628c6aa21ac2d094b94372",
)
.unwrap(); // first tx reverted at block 164901

let transaction_hash = FieldElement::from_hex_be("0x2062dc37facfcc3bed03163dbbde0e3874bf8b231628c6aa21ac2d094b94372").unwrap(); // first tx reverted at block 164901

let response_deoxys = deoxys
.trace_transaction(transaction_hash)
.await;
let response_deoxys = deoxys.trace_transaction(transaction_hash).await;

assert!(
response_deoxys.is_err(),
Expand All @@ -66,9 +66,14 @@ async fn fail_no_trace_available(deoxys: JsonRpcClient<HttpTransport>) {

#[rstest]
#[tokio::test]
async fn work_trace_transaction(deoxys: JsonRpcClient<HttpTransport>, pathfinder: JsonRpcClient<HttpTransport>) {

let transaction_hash = FieldElement::from_hex_be("0x04456c75586c033f4c8f6731a87d10ff5779e40c351e9c8378590ae2a3f823da").unwrap(); // first tx accepted at block 10000
async fn work_trace_transaction(
deoxys: JsonRpcClient<HttpTransport>,
pathfinder: JsonRpcClient<HttpTransport>,
) {
let transaction_hash = FieldElement::from_hex_be(
"0x04456c75586c033f4c8f6731a87d10ff5779e40c351e9c8378590ae2a3f823da",
)
.unwrap(); // first tx accepted at block 10000

let response_deoxys = deoxys
.trace_transaction(transaction_hash)
Expand All @@ -81,4 +86,4 @@ async fn work_trace_transaction(deoxys: JsonRpcClient<HttpTransport>, pathfinder
.expect(ERR_PATHFINDER);

assert_eq!(response_deoxys, response_pathfinder);
}
}

0 comments on commit 0224223

Please sign in to comment.