Skip to content

Commit

Permalink
cleaned getNonce call
Browse files Browse the repository at this point in the history
  • Loading branch information
antiyro committed May 25, 2024
1 parent 942cfbf commit b432cf9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 24 deletions.
14 changes: 7 additions & 7 deletions unit_tests/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,31 @@ pub const STARKGATE_ETHER: &str =
/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x07fa9a8eacb89fb6cd0c7fe557e71c42a4b181ba328a9a04958136e6469c4e00)
///
pub const CONTRACT_ERC721: &str =
"0x07fa9a8eacb89fb6cd0c7fe557e71c42a4b181ba328a9a04958136e6469c4e00";
"0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af";

///
/// Random ERC20 Starknet contract address.
///
/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x04a5fdce70877b77f03aea8a29259176f88d5bea9d0ad8c0118f5316425e6ba0)
///
pub const CONTRACT_ERC20: &str =
"0x04a5fdce70877b77f03aea8a29259176f88d5bea9d0ad8c0118f5316425e6ba0";
"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7";

///
/// Random ACCOUNT Starknet contract address.
///
/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x05e1eee30e79b4f592f444132526b2e2c7f505698e888c659e5f5def5a458c1a)
///
pub const CONTRACT_ACCOUNT: &str =
"0x05e1eee30e79b4f592f444132526b2e2c7f505698e888c659e5f5def5a458c1a";
pub const CONTRACT_ACCOUNT_CAIRO_ZERO: &str =
"0x0100104681e789e4211fba898262e1d6f6191bee797ce38a9e07fe8dec743574";

///
/// Random PROXY ACCOUNT Starknet contract address.
///
/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x05d7f4d55795b56ceb4dd93febe17954c7cfd5e15d7a79cb0cec067a713ac159)
///
pub const CONTRACT_ACCOUNT_PROXY: &str =
"0x05d7f4d55795b56ceb4dd93febe17954c7cfd5e15d7a79cb0cec067a713ac159";
pub const CONTRACT_ACCOUNT_PROXY_CAIRO_ZERO: &str =
"0x036Ef6410243034cE315eC19E7ABFEB41052f39095EE3D5AFcC20D672b1C725F";

///
/// Random legacy account using Cairo v0
Expand Down Expand Up @@ -142,7 +142,7 @@ pub const TRANSACTION_REVERTED: &str =
pub const ACCOUNT_CONTRACT: &str = "";
pub const TEST_CONTRACT_ADDRESS: &str = "";
pub const CAIRO_1_ACCOUNT_CONTRACT_CLASS_HASH: &str = "";
pub const TEST_CONTRACT_CLASS_HASH: &str = "";
pub const TEST_CONTRACT_CLASS_HASH: &str = "0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003";

///
/// Value to be used as a payload for a message in the `estimate_message_fee` test.
Expand Down
2 changes: 1 addition & 1 deletion unit_tests/tests/test_get_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async fn fail_non_existing_block(clients: HashMap<String, JsonRpcClient<HttpTran
FieldElement::from_hex_be(TEST_CONTRACT_CLASS_HASH).expect("Invalid Contract Address");

let response_deoxys = deoxys
.get_class(BlockId::Number(100), test_contract_class_hash)
.get_class(BlockId::Number(1), test_contract_class_hash)
.await;

assert!(
Expand Down
6 changes: 3 additions & 3 deletions unit_tests/tests/test_get_class_at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn fail_non_existing_block(clients: HashMap<String, JsonRpcClient<HttpTran
let response_deoxys = deoxys
.get_class_at(
BlockId::Hash(FieldElement::ZERO),
FieldElement::from_hex_be(CONTRACT_ACCOUNT).unwrap(),
FieldElement::from_hex_be(CONTRACT_ACCOUNT_CAIRO_ZERO).unwrap(),
)
.await;

Expand Down Expand Up @@ -148,15 +148,15 @@ async fn work_contract_v1(
let response_deoxys = deoxys
.get_class_at(
block_number,
FieldElement::from_hex_be(CONTRACT_ACCOUNT).unwrap(),
FieldElement::from_hex_be(CONTRACT_ACCOUNT_CAIRO_ZERO).unwrap(),
)
.await
.expect("Error waiting for response from Deoxys client");

let response_pathfinder = pathfinder
.get_class_at(
block_number,
FieldElement::from_hex_be(CONTRACT_ACCOUNT).unwrap(),
FieldElement::from_hex_be(CONTRACT_ACCOUNT_CAIRO_ZERO).unwrap(),
)
.await
.expect("Error waiting for response from Pathfinder client");
Expand Down
18 changes: 6 additions & 12 deletions unit_tests/tests/test_get_nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ async fn fail_non_existing_contract(clients: HashMap<String, JsonRpcClient<HttpT
async fn work_erc721_contract(clients: HashMap<String, JsonRpcClient<HttpTransport>>) {
let deoxys = &clients[DEOXYS];

//This contract was created at Block 500198, so need to be synced to this minimum block

let block_number = get_block_setting();

let response_deoxys = deoxys
Expand Down Expand Up @@ -156,22 +154,20 @@ async fn work_account_contract(clients: HashMap<String, JsonRpcClient<HttpTransp
let deoxys = &clients[DEOXYS];
let pathfinder = &clients[PATHFINDER];

//This contract was created at Block 500209, so need to be synced to this minimum block

let block_number = get_block_setting();
let block_number = BlockId::Number(55000);

let response_deoxys = deoxys
.get_nonce(
block_number,
FieldElement::from_hex_be(CONTRACT_ACCOUNT).unwrap(),
FieldElement::from_hex_be(CONTRACT_ACCOUNT_CAIRO_ZERO).unwrap(),
)
.await
.expect("Error waiting for response from Deoxys node");

let response_pathfinder = pathfinder
.get_nonce(
block_number,
FieldElement::from_hex_be(CONTRACT_ACCOUNT).unwrap(),
FieldElement::from_hex_be(CONTRACT_ACCOUNT_CAIRO_ZERO).unwrap(),
)
.await
.expect("Error waiting for response from Pathfinder node");
Expand All @@ -192,22 +188,20 @@ async fn work_account_proxy_contract(clients: HashMap<String, JsonRpcClient<Http
let deoxys = &clients[DEOXYS];
let pathfinder = &clients[PATHFINDER];

//This contract was created at Block 500192, so need to be synced to this minimum block

let block_number = get_block_setting();
let block_number = BlockId::Number(51244);

let response_deoxys = deoxys
.get_nonce(
block_number,
FieldElement::from_hex_be(CONTRACT_ACCOUNT_PROXY).unwrap(),
FieldElement::from_hex_be(CONTRACT_ACCOUNT_PROXY_CAIRO_ZERO).unwrap(),
)
.await
.expect("Error waiting for response from Deoxys node");

let response_pathfinder = pathfinder
.get_nonce(
block_number,
FieldElement::from_hex_be(CONTRACT_ACCOUNT_PROXY).unwrap(),
FieldElement::from_hex_be(CONTRACT_ACCOUNT_PROXY_CAIRO_ZERO).unwrap(),
)
.await
.expect("Error waiting for response from Pathfinder node");
Expand Down
2 changes: 1 addition & 1 deletion unit_tests/tests/test_get_transaction_by_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async fn work_transaction_l1_handler(clients: HashMap<String, JsonRpcClient<Http
///
#[rstest]
#[tokio::test]
async fn work_transaction_declare(clients: HashMap<String, JsonRpcClient<HttpTransport>>) {
async fn work_declare_transaction(clients: HashMap<String, JsonRpcClient<HttpTransport>>) {
let deoxys = &clients[DEOXYS];
let pathfinder = &clients[PATHFINDER];

Expand Down

0 comments on commit b432cf9

Please sign in to comment.