Skip to content

Commit

Permalink
added contract constants
Browse files Browse the repository at this point in the history
  • Loading branch information
antiyro committed Jun 17, 2024
1 parent 6627f92 commit ce555b7
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 52 deletions.
26 changes: 13 additions & 13 deletions unit_tests/src/constants/mainnet/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,55 +48,55 @@ pub const CONTRACT_ERC20: &str =

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

///
/// Random Cairo 0 contract address.
///
///
/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x03cdabdf2ea700a667c63024523ccb04a22d18104da826ac10984a18eddadbbe)
///
///
pub const CONTRACT_CAIRO_0: &str =
"0x03cdabdf2ea700a667c63024523ccb04a22d18104da826ac10984a18eddadbbe";

///
/// Random Braavos account Cairo 0 contract address.
///
///
/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x0179d67854d1b9429d276ed7c59010be187af15d2e6ede31a513bdfbfa3e1af7)
///
///
pub const CONTRACT_BRAAVOS_ACCOUNT_CAIRO_0: &str =
"0x0179d67854d1b9429d276ed7c59010be187af15d2e6ede31a513bdfbfa3e1af7";

///
/// Random Braavos account Cairo 1 contract address.
///
///
/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x017de82f930be1caec165b9501197046ecc7d2d86d9721cd57f0cb16c2a99b2e)
///
///
pub const CONTRACT_BRAAVOS_ACCOUNT_CAIRO_1: &str =
"0x017de82f930be1caec165b9501197046ecc7d2d86d9721cd57f0cb16c2a99b2e";

///
/// Random Argent account Cairo 0 contract address.
///
///
/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x0314a5cbf7f368446d38ed4d0de19f5ca16546c1a519e8994c07590ecff803c0)
///
///
pub const CONTRACT_ARGENT_ACCOUNT_CAIRO_0: &str =
"0x0314a5cbf7f368446d38ed4d0de19f5ca16546c1a519e8994c07590ecff803c0";

///
/// Random Argent account Cairo 1 contract address.
///
///
/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x017317d13c8278d38720d2d70d7adcf6a3cf9ef3abb5422ad60ea4f98f8d6eba)
///
///
pub const CONTRACT_ARGENT_ACCOUNT_CAIRO_1: &str =
"0x017317d13c8278d38720d2d70d7adcf6a3cf9ef3abb5422ad60ea4f98f8d6eba";

///
/// Random ERC721 Cairo 0 contract address.
///
///
/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x0717e6b64e3c48c016ffec829963696480bf40ad8ca1d5303902c1b23347ff57)
///
///
pub const CONTRACT_ERC721_CAIRO_0: &str =
"0x0717e6b64e3c48c016ffec829963696480bf40ad8ca1d5303902c1b23347ff57";
4 changes: 2 additions & 2 deletions unit_tests/src/constants/mainnet/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod block;
pub mod transaction;
pub mod contract;
pub mod network;
pub mod contract;
pub mod transaction;
2 changes: 1 addition & 1 deletion unit_tests/src/constants/mainnet/network.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub const DEOXYS: &str = "deoxys";
pub const PATHFINDER: &str = "pathfinder";
pub const JUNO: &str = "juno";
pub const JUNO: &str = "juno";
35 changes: 15 additions & 20 deletions unit_tests/src/constants/mainnet/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,47 +1,42 @@
///
/// Random INVOKE_V0 transaction
///
///
/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x02c02d6f0d75bc71b1c629cde038199ccfb6e18343a76943275405817727f76c)
///
pub const TX_INVOKE_V0: &str =
"0x02c02d6f0d75bc71b1c629cde038199ccfb6e18343a76943275405817727f76c";
///
pub const TX_INVOKE_V0: &str = "0x02c02d6f0d75bc71b1c629cde038199ccfb6e18343a76943275405817727f76c";

///
/// Random INVOKE_V1 transaction
///
/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x027ed707907aef09c39ece1b24540308eee8d74a14c77728604c3a2da546fd6d)
///
pub const TX_INVOKE_V1: &str =
"0x027ed707907aef09c39ece1b24540308eee8d74a14c77728604c3a2da546fd6d";
pub const TX_INVOKE_V1: &str = "0x027ed707907aef09c39ece1b24540308eee8d74a14c77728604c3a2da546fd6d";

///
/// Random DECLARE_V0 transaction
///
///
/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x5f430525084fe54a73e6f6de7d5d3ac20311ac4ba48002c665dade0c585af82)
///
pub const TX_DECLARE_V0: &str =
"0x5f430525084fe54a73e6f6de7d5d3ac20311ac4ba48002c665dade0c585af82";
///
pub const TX_DECLARE_V0: &str = "0x5f430525084fe54a73e6f6de7d5d3ac20311ac4ba48002c665dade0c585af82";

///
/// Random DECLARE_V1 transaction
///
///
/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x30fd34d7ffbe2aea6121f76c7c82a9edb7250a69a86eaf4ea55e9fb39237d71)
///
pub const TX_DECLARE_V1: &str =
"0x30fd34d7ffbe2aea6121f76c7c82a9edb7250a69a86eaf4ea55e9fb39237d71";

pub const TX_DECLARE_V1: &str = "0x30fd34d7ffbe2aea6121f76c7c82a9edb7250a69a86eaf4ea55e9fb39237d71";

///
/// Random DECLARE_V2 transaction
///
///
/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x62c6e41b306db3dd03fbbb14bd169e84819e5ac1058ffde93a924b3abe9b3c1)
///
pub const TX_DECLARE_V2: &str =
"0x62c6e41b306db3dd03fbbb14bd169e84819e5ac1058ffde93a924b3abe9b3c1";
///
pub const TX_DECLARE_V2: &str = "0x62c6e41b306db3dd03fbbb14bd169e84819e5ac1058ffde93a924b3abe9b3c1";

///
/// Random L1_HANDLER_V0 transaction
///
///
/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x006a555ac598673a215ef69815db1ebe89cb11eed9a489215c21c7d32d6e581a)
///
///
pub const TX_L1_HANDLER_V0: &str =
"0x006a555ac598673a215ef69815db1ebe89cb11eed9a489215c21c7d32d6e581a";
2 changes: 1 addition & 1 deletion unit_tests/src/constants/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pub mod mainnet;
pub mod sepolia;
pub mod sepolia;
1 change: 1 addition & 0 deletions unit_tests/src/constants/sepolia/block.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions unit_tests/src/constants/sepolia/contract.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 2 additions & 2 deletions unit_tests/src/constants/sepolia/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod block;
pub mod transaction;
pub mod contract;
pub mod network;
pub mod contract;
pub mod transaction;
1 change: 1 addition & 0 deletions unit_tests/src/constants/sepolia/network.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions unit_tests/src/constants/sepolia/transaction.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

5 changes: 3 additions & 2 deletions unit_tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![feature(assert_matches)]

use constants::mainnet;
use starknet_accounts::{Account, Call, ConnectedAccount, Execution, SingleOwnerAccount};
use starknet_core::chain_id;
use starknet_core::types::BroadcastedInvokeTransaction;
Expand All @@ -9,7 +10,6 @@ use starknet_core::{
};
use starknet_providers::{jsonrpc::HttpTransport, JsonRpcClient};
use starknet_signers::{LocalWallet, SigningKey};
use constants::mainnet;

pub mod constants;
pub mod fixtures;
Expand All @@ -28,7 +28,8 @@ impl TransactionFactory for OkTransactionFactory {
max_fee: FieldElement::ZERO,
signature: vec![],
nonce: nonce.unwrap_or(FieldElement::ZERO),
sender_address: FieldElement::from_hex_be(mainnet::contract::CONTRACT_ACCOUNT).unwrap(),
sender_address: FieldElement::from_hex_be(mainnet::contract::CONTRACT_ACCOUNT)
.unwrap(),
calldata: vec![
FieldElement::from_hex_be(mainnet::contract::CONTRACT_ERC20).unwrap(),
get_selector_from_name("transfer").unwrap(),
Expand Down
11 changes: 4 additions & 7 deletions unit_tests/tests/test_get_block_with_txs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ mod common;
use colored::*;
use common::*;
use serde_json::Value;
use std::sync::Arc;
use std::collections::HashMap;
use starknet_core::types::{BlockId, BlockTag, FieldElement, StarknetError};
use starknet_providers::{
jsonrpc::{HttpTransport, JsonRpcClient},
Provider,
};
use std::collections::HashMap;
use std::sync::Arc;
use unit_tests::constants::DEOXYS;

// Define a recursive function to compare JSON values and print differences
Expand Down Expand Up @@ -156,7 +156,6 @@ async fn work_with_latest_block(clients: HashMap<String, JsonRpcClient<HttpTrans
}
}


async fn work_with_block(
deoxys: JsonRpcClient<HttpTransport>,
pathfinder: JsonRpcClient<HttpTransport>,
Expand Down Expand Up @@ -270,9 +269,7 @@ async fn work_with_block_100_000(
#[rstest]
#[tokio::test]
async fn work_with_block_one_hundred_thousand_hash(
clients

: HashMap<String, JsonRpcClient<HttpTransport>>,
clients: HashMap<String, JsonRpcClient<HttpTransport>>,
) {
let deoxys = &clients[mainnet::network::DEOXYS];
let pathfinder = &clients[mainnet::network::PATHFINDER];
Expand Down Expand Up @@ -418,4 +415,4 @@ async fn work_loop(deoxys: JsonRpcClient<HttpTransport>, pathfinder: JsonRpcClie
}
}
assert_eq!(diff, false);
}
}
16 changes: 12 additions & 4 deletions unit_tests/tests/test_get_transaction_by_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,16 @@ async fn work_declare_transaction(clients: HashMap<String, JsonRpcClient<HttpTra
let pathfinder = &clients[mainnet::network::PATHFINDER];

let response_deoxys = deoxys
.get_transaction_by_hash(FieldElement::from_hex_be(mainnet::transaction::DECLARE_TX_V0).unwrap())
.get_transaction_by_hash(
FieldElement::from_hex_be(mainnet::transaction::DECLARE_TX_V0).unwrap(),
)
.await
.expect("Error waiting for response from Deoxys node");

let response_pathfinder = pathfinder
.get_transaction_by_hash(FieldElement::from_hex_be(mainnet::transaction::DECLARE_TX_V0).unwrap())
.get_transaction_by_hash(
FieldElement::from_hex_be(mainnet::transaction::DECLARE_TX_V0).unwrap(),
)
.await
.expect("Error waiting for response from Pathfinder node");

Expand All @@ -129,12 +133,16 @@ async fn work_transaction_deploy_account(clients: HashMap<String, JsonRpcClient<
let pathfinder = &clients[mainnet::network::PATHFINDER];

let response_deoxys = deoxys
.get_transaction_by_hash(FieldElement::from_hex_be(mainnet::transaction::DEPLOY_ACCOUNT_V0).unwrap())
.get_transaction_by_hash(
FieldElement::from_hex_be(mainnet::transaction::DEPLOY_ACCOUNT_V0).unwrap(),
)
.await
.expect("Error waiting for response from Deoxys node");

let response_pathfinder = pathfinder
.get_transaction_by_hash(FieldElement::from_hex_be(mainnet::transaction::DEPLOY_ACCOUNT_V0).unwrap())
.get_transaction_by_hash(
FieldElement::from_hex_be(mainnet::transaction::DEPLOY_ACCOUNT_V0).unwrap(),
)
.await
.expect("Error waiting for response from Pathfinder node");

Expand Down

0 comments on commit ce555b7

Please sign in to comment.