Skip to content

Commit

Permalink
update: PR reviews fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
heemankv committed Aug 17, 2024
1 parent 4de6e8b commit ebe967e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ MONGODB_CONNECTION_STRING="mongodb://localhost:27017"
# Ethereum Settlement
DEFAULT_SETTLEMENT_CLIENT_RPC="http://localhost:3000"
DEFAULT_L1_CORE_CONTRACT_ADDRESS="0xc662c410C0ECf747543f5bA90660f6ABeBD9C8c4"
TEST_IMPERSONATE_OPERATOR="1"
SHOULD_IMPERSONATE_ACCOUNT="true"
TEST_DUMMY_CONTRACT_ADDRESS="0xE5b6F5e695BA6E4aeD92B68c4CC8Df1160D69A81"
6 changes: 3 additions & 3 deletions crates/settlement-clients/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ pub mod config;
pub mod conversion;

// IMPORTANT to understand #[cfg(test)], #[cfg(not(test))] and SHOULD_IMPERSONATE_ACCOUNT
// Two tests : `update_state_blob_with_dummy_contract_works` & `update_state_blob_with_impersonation_works` use a env var `TEST_IMPERSONATE_OPERATOR` to inform the function `update_state_with_blobs` about the kind of testing,
// `TEST_IMPERSONATE_OPERATOR` can have any of "0" or "1" value :
// Two tests : `update_state_blob_with_dummy_contract_works` & `update_state_blob_with_impersonation_works` use a env var `SHOULD_IMPERSONATE_ACCOUNT` to inform the function `update_state_with_blobs` about the kind of testing,
// `SHOULD_IMPERSONATE_ACCOUNT` can have any of "0" or "1" value :
// - if "0" then : Testing via default Anvil address.
// - if "1" then : Testing via impersonating `Starknet Operator Address`.
// Note : changing between "0" and "1" is handled automatically by each test function, `no` manual change in `env.test` is needed.

#[cfg(test)]
lazy_static! {
static ref SHOULD_IMPERSONATE_ACCOUNT: bool = get_env_var_or_panic("TEST_IMPERSONATE_OPERATOR") == *"1";
static ref SHOULD_IMPERSONATE_ACCOUNT: bool = get_env_var_or_panic("SHOULD_IMPERSONATE_ACCOUNT") == *"true";
static ref TEST_DUMMY_CONTRACT_ADDRESS: String = get_env_var_or_panic("TEST_DUMMY_CONTRACT_ADDRESS");
static ref ADDRESS_TO_IMPERSONATE: Address =
Address::from_str("0x2C169DFe5fBbA12957Bdd0Ba47d9CEDbFE260CA7").expect("Unable to parse address");
Expand Down
4 changes: 2 additions & 2 deletions crates/settlement-clients/ethereum/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ lazy_static! {
.to_string();
static ref PORT: u16 = 3000_u16;
static ref ETH_RPC: String = get_env_var_or_panic("ETHEREUM_BLAST_RPC_URL");
static ref SHOULD_IMPERSONATE_ACCOUNT: bool = get_env_var_or_panic("TEST_IMPERSONATE_OPERATOR") == *"1";
static ref SHOULD_IMPERSONATE_ACCOUNT: bool = get_env_var_or_panic("SHOULD_IMPERSONATE_ACCOUNT") == *"true";
static ref TEST_DUMMY_CONTRACT_ADDRESS: String = get_env_var_or_panic("TEST_DUMMY_CONTRACT_ADDRESS");
static ref STARKNET_OPERATOR_ADDRESS: Address =
Address::from_str("0x2C169DFe5fBbA12957Bdd0Ba47d9CEDbFE260CA7").expect("Could not impersonate account.");
Expand Down Expand Up @@ -107,7 +107,7 @@ fn setup_ethereum_test(block_no: u64) -> TestSetup {
#[case::basic(20468828)]
/// tests if the method is able to do a transaction with same function selector on a dummy contract.
async fn update_state_blob_with_dummy_contract_works(#[case] fork_block_no: u64) {
env::set_var("TEST_IMPERSONATE_OPERATOR", "0");
env::set_var("SHOULD_IMPERSONATE_ACCOUNT", "false");
let TestSetup { anvil, ethereum_settlement_client, provider } = setup_ethereum_test(fork_block_no);

println!("{:?}", anvil);
Expand Down

0 comments on commit ebe967e

Please sign in to comment.