Skip to content

Commit

Permalink
fix: convert owner to ContractAddress in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JordyRo1 committed Jul 4, 2024
1 parent 6317c2d commit 6700b7a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion contracts/src/tests/routing/test_domain_routing_ism.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ fn test_route_ism_fails_if_origin_not_found() {
];
let (_, ism, domain_routing_ism) = setup_domain_routing_ism();
let ownable = IOwnableDispatcher { contract_address: domain_routing_ism.contract_address };
start_prank(CheatTarget::One(ownable.contract_address), OWNER());
start_prank(CheatTarget::One(ownable.contract_address), OWNER().try_into().unwrap());
domain_routing_ism.initialize(_domains.span(), _modules.span());
ism.route(message);
}
Expand Down
11 changes: 6 additions & 5 deletions contracts/src/tests/test_mailbox.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use openzeppelin::token::erc20::interface::{ERC20ABI, ERC20ABIDispatcher, ERC20A
use snforge_std::cheatcodes::events::EventAssertions;
use snforge_std::{start_prank, CheatTarget, stop_prank};


#[test]
fn test_local_domain() {
let (mailbox, _, _, _) = setup_mailbox(MAILBOX(), Option::None, Option::None);
Expand Down Expand Up @@ -232,7 +233,7 @@ fn test_dispatch_with_protocol_fee_hook() {
);

// balance check
assert_eq!(erc20_dispatcher.balanceOf(OWNER()), INITIAL_SUPPLY - PROTOCOL_FEE);
assert_eq!(erc20_dispatcher.balanceOf(OWNER().try_into().unwrap()), INITIAL_SUPPLY - PROTOCOL_FEE);
assert(mailbox.get_latest_dispatched_id() == message_id, 'Failed to fetch latest id');
}

Expand Down Expand Up @@ -300,7 +301,7 @@ fn test_dispatch_with_two_fee_hook() {
);

// balance check
assert_eq!(erc20_dispatcher.balanceOf(OWNER()), INITIAL_SUPPLY - 4 * PROTOCOL_FEE);
assert_eq!(erc20_dispatcher.balanceOf(OWNER().try_into().unwrap()), INITIAL_SUPPLY - 4 * PROTOCOL_FEE);
assert(mailbox.get_latest_dispatched_id() == message_id, 'Failed to fetch latest id');
}

Expand All @@ -319,7 +320,7 @@ fn test_dispatch_with_protocol_fee_hook_fails_if_provided_fee_lower_than_require
start_prank(CheatTarget::One(ownable.contract_address), OWNER().try_into().unwrap());
// We transfer some token to the new owner
let erc20_dispatcher = ERC20ABIDispatcher { contract_address: ETH_ADDRESS() };
erc20_dispatcher.transfer(NEW_OWNER(), PROTOCOL_FEE - 10);
erc20_dispatcher.transfer(NEW_OWNER().try_into().unwrap(), PROTOCOL_FEE - 10);

// The new owner has has PROTOCOL_FEE -10 tokens so the required hook post dispatch fails
let ownable = IOwnableDispatcher { contract_address: ETH_ADDRESS() };
Expand Down Expand Up @@ -359,7 +360,7 @@ fn test_dispatch_with_protocol_fee_hook_fails_if_user_balance_lower_than_fee_amo
start_prank(CheatTarget::One(ownable.contract_address), OWNER().try_into().unwrap());
// We transfer some token to the new owner
let erc20_dispatcher = ERC20ABIDispatcher { contract_address: ETH_ADDRESS() };
erc20_dispatcher.transfer(NEW_OWNER(), PROTOCOL_FEE - 10);
erc20_dispatcher.transfer(NEW_OWNER().try_into().unwrap(), PROTOCOL_FEE - 10);

// The new owner has has PROTOCOL_FEE -10 tokens so the required hook post dispatch fails
let ownable = IOwnableDispatcher { contract_address: ETH_ADDRESS() };
Expand Down Expand Up @@ -401,7 +402,7 @@ fn test_dispatch_with_protocol_fee_hook_fails_if_insufficient_allowance() {
start_prank(CheatTarget::One(ownable.contract_address), OWNER().try_into().unwrap());
// We transfer some token to the new owner
let erc20_dispatcher = ERC20ABIDispatcher { contract_address: ETH_ADDRESS() };
erc20_dispatcher.transfer(NEW_OWNER(), PROTOCOL_FEE);
erc20_dispatcher.transfer(NEW_OWNER().try_into().unwrap(), PROTOCOL_FEE);

// The new owner has has PROTOCOL_FEE -10 tokens so the required hook post dispatch fails
let ownable = IOwnableDispatcher { contract_address: ETH_ADDRESS() };
Expand Down
1 change: 1 addition & 0 deletions contracts/src/tests/test_validator_announce.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ fn test_double_announce() {
];
let res = validator_announce
.announce(validator_address, _storage_location_2.clone(), signature);
assert_eq!(res, true);
let validators = validator_announce.get_announced_validators();
assert(validators == array![validator_address].span(), 'validator array mismatch');
let storage_location = validator_announce.get_announced_storage_locations(validators);
Expand Down

0 comments on commit 6700b7a

Please sign in to comment.