Skip to content

Commit

Permalink
improve: not needed to deploy usdc in while mock testing
Browse files Browse the repository at this point in the history
  • Loading branch information
byteZorvin committed Aug 5, 2024
1 parent 0c613d0 commit 02205bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions tests/constants.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 10 additions & 10 deletions tests/token_bridge_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 02205bd

Please sign in to comment.