Skip to content

Commit

Permalink
failing tests fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
byteZorvin committed Aug 20, 2024
1 parent 584607c commit 1e51906
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
8 changes: 0 additions & 8 deletions src/bridge/tests/utils/setup.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ pub fn deploy_erc20(name: ByteArray, symbol: ByteArray) -> ContractAddress {
return usdc;
}

/// Returns the state of a contract for testing. This must be used
/// to test internal functions or directly access the storage.
/// You can't spy event with this. Use deploy instead.
pub fn mock_state_testing() -> TokenBridge::ContractState {
TokenBridge::contract_state_for_testing()
}


pub fn deploy_token_bridge_with_messaging() -> (
ITokenBridgeDispatcher, EventSpy, IMockMessagingDispatcher
) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub mod bridge {
mod messaging_test;
pub mod utils {
pub mod message_payloads;
pub mod setup;
pub mod setup;
}
}

Expand Down
24 changes: 23 additions & 1 deletion src/withdrawal_limit/tests/withdrawal_limit_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ fn get_remaining_withdrawal_quota_ok() {

let usdc_address = deploy_erc20("USDC", "USDC");
let usdc = IERC20Dispatcher { contract_address: usdc_address };

// Transfering usdc to test address for testing
snf::start_cheat_caller_address(usdc.contract_address, OWNER());
usdc.transfer(snf::test_address(), 10_000_000);
snf::stop_cheat_caller_address(usdc.contract_address);

// Mocking deposits with the contract
usdc.transfer(withdrawal_limit.contract_address, 1_000_000);

Expand Down Expand Up @@ -71,6 +77,12 @@ fn consume_withdrawal_quota_ok() {

let usdc_address = deploy_erc20("USDC", "USDC");
let usdc = IERC20Dispatcher { contract_address: usdc_address };

// Transfering usdc to test address for testing
snf::start_cheat_caller_address(usdc.contract_address, OWNER());
usdc.transfer(snf::test_address(), 10_000_000);
snf::stop_cheat_caller_address(usdc.contract_address);

// Mocking deposits with the contract
usdc.transfer(withdrawal_limit.contract_address, 1000_000);

Expand Down Expand Up @@ -111,6 +123,11 @@ fn consume_withdrawal_quota_limit_exceeded() {

let usdc_address = deploy_erc20("USDC", "USDC");
let usdc = IERC20Dispatcher { contract_address: usdc_address };
// Transfering usdc to test address for testing
snf::start_cheat_caller_address(usdc.contract_address, OWNER());
usdc.transfer(snf::test_address(), 10_000_000);
snf::stop_cheat_caller_address(usdc.contract_address);

// Mocking deposits with the contract
usdc.transfer(withdrawal_limit.contract_address, 1000_000);

Expand All @@ -133,9 +150,14 @@ fn get_remaining_withdrawal_quota_should_reset_after_1_day_ok() {

let usdc_address = deploy_erc20("USDC", "USDC");
let usdc = IERC20Dispatcher { contract_address: usdc_address };

// Transfering usdc to test address for testing
snf::start_cheat_caller_address(usdc.contract_address, OWNER());
usdc.transfer(snf::test_address(), 10_000_000);
snf::stop_cheat_caller_address(usdc.contract_address);

// Mocking deposits with the contract
usdc.transfer(withdrawal_limit.contract_address, 1000_000);

let withdrawal_limit_mock = IMockWithdrawalLimitDispatcher {
contract_address: withdrawal_limit.contract_address
};
Expand Down

0 comments on commit 1e51906

Please sign in to comment.