From 02205bd63ac3bace7f021b28374b3267237ebc26 Mon Sep 17 00:00:00 2001 From: byteZorvin Date: Mon, 5 Aug 2024 11:40:33 +0530 Subject: [PATCH] improve: not needed to deploy usdc in while mock testing --- tests/constants.cairo | 3 +++ tests/token_bridge_test.cairo | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/constants.cairo b/tests/constants.cairo index cb8f018..8f56b1c 100644 --- a/tests/constants.cairo +++ b/tests/constants.cairo @@ -8,6 +8,9 @@ pub fn L3_BRIDGE_ADDRESS() -> ContractAddress { contract_address_const::<'l3_bridge_address'>() } +pub fn USDC_MOCK_ADDRESS() -> ContractAddress { + contract_address_const::<'Usdc address'>() +} // 5 days as the delay time (5 * 86400 = 432000) pub const DELAY_TIME: felt252 = 432000; diff --git a/tests/token_bridge_test.cairo b/tests/token_bridge_test.cairo index 3380c8f..7726ca0 100644 --- a/tests/token_bridge_test.cairo +++ b/tests/token_bridge_test.cairo @@ -21,7 +21,7 @@ use openzeppelin::access::ownable::{ interface::{IOwnableTwoStepDispatcher, IOwnableTwoStepDispatcherTrait} }; use starknet::contract_address::{contract_address_const}; -use super::constants::{OWNER, L3_BRIDGE_ADDRESS, DELAY_TIME}; +use super::constants::{OWNER, L3_BRIDGE_ADDRESS, USDC_MOCK_ADDRESS, DELAY_TIME}; fn deploy_erc20(name: ByteArray, symbol: ByteArray) -> ContractAddress { @@ -208,7 +208,7 @@ fn set_max_total_balance_ok() { #[test] fn block_token_ok() { let mut mock = mock_state_testing(); - let usdc_address = deploy_erc20("usdc", "usdc"); + let usdc_address = USDC_MOCK_ADDRESS(); mock.ownable.Ownable_owner.write(OWNER()); snf::cheat_caller_address_global(OWNER()); @@ -222,7 +222,7 @@ fn block_token_ok() { #[should_panic(expected: ('Caller is not the owner',))] fn block_token_not_owner() { let mut mock = mock_state_testing(); - let usdc_address = deploy_erc20("usdc", "usdc"); + let usdc_address = USDC_MOCK_ADDRESS(); mock.ownable.Ownable_owner.write(OWNER()); snf::cheat_caller_address_global(snf::test_address()); @@ -234,7 +234,7 @@ fn block_token_not_owner() { #[should_panic(expected: ('Only unknown can be blocked',))] fn block_token_not_unknown() { let mut mock = mock_state_testing(); - let usdc_address = deploy_erc20("usdc", "usdc"); + let usdc_address = USDC_MOCK_ADDRESS(); // Setting the token active let old_settings = mock.token_settings.read(usdc_address); @@ -341,7 +341,7 @@ fn disable_withdrwal_not_owner() { #[test] fn unblock_token_ok() { let mut mock = mock_state_testing(); - let usdc_address = deploy_erc20("usdc", "usdc"); + let usdc_address = USDC_MOCK_ADDRESS(); // Setting the token active let old_settings = mock.token_settings.read(usdc_address); @@ -360,7 +360,7 @@ fn unblock_token_ok() { #[should_panic(expected: ('Caller is not the owner',))] fn unblock_token_not_owner() { let mut mock = mock_state_testing(); - let usdc_address = deploy_erc20("usdc", "usdc"); + let usdc_address = USDC_MOCK_ADDRESS(); // Setting the token active let old_settings = mock.token_settings.read(usdc_address); @@ -379,7 +379,7 @@ fn unblock_token_not_owner() { #[should_panic(expected: ('Token not blocked',))] fn unblock_token_not_blocked() { let mut mock = mock_state_testing(); - let usdc_address = deploy_erc20("usdc", "usdc"); + let usdc_address = USDC_MOCK_ADDRESS(); // Setting the token active let old_settings = mock.token_settings.read(usdc_address); @@ -396,7 +396,7 @@ fn unblock_token_not_blocked() { #[test] fn reactivate_token_ok() { let mut mock = mock_state_testing(); - let usdc_address = deploy_erc20("usdc", "usdc"); + let usdc_address = USDC_MOCK_ADDRESS(); // Setting the token active let old_settings = mock.token_settings.read(usdc_address); @@ -418,7 +418,7 @@ fn reactivate_token_ok() { #[should_panic(expected: ('Caller is not the owner',))] fn reactivate_token_not_owner() { let mut mock = mock_state_testing(); - let usdc_address = deploy_erc20("usdc", "usdc"); + let usdc_address = USDC_MOCK_ADDRESS(); // Setting the token active let old_settings = mock.token_settings.read(usdc_address); @@ -437,7 +437,7 @@ fn reactivate_token_not_owner() { #[should_panic(expected: ('Token not deactivated',))] fn reactivate_token_not_deactivated() { let mut mock = mock_state_testing(); - let usdc_address = deploy_erc20("usdc", "usdc"); + let usdc_address = USDC_MOCK_ADDRESS(); // Setting the token active let old_settings = mock.token_settings.read(usdc_address);