Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ermyas committed Sep 24, 2023
1 parent 5daab35 commit d5fdee8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
14 changes: 8 additions & 6 deletions test/unit-tests/MessageReceiverGAC.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,25 @@ contract MessageReceiverGACTest is Setup {
event MultiBridgeMessageReceiverUpdated(address indexed oldReceiver, address indexed newReceiver);

MessageReceiverGAC receiverGAC;

address gacOwner;
/// @dev initializes the setup

function setUp() public override {
super.setUp();
vm.selectFork(fork[DST_CHAIN_ID]);
receiverGAC = MessageReceiverGAC(contractAddress[DST_CHAIN_ID]["GAC"]);
gacOwner = contractAddress[DST_CHAIN_ID]["TIMELOCK"];
}

/// @dev constructor
function test_constructor() public {
// checks existing setup
assertEq(address(Ownable(address(receiverGAC)).owner()), owner);
assertEq(address(Ownable(address(receiverGAC)).owner()), gacOwner);
}

/// @dev sets multi message receiver
function test_set_multi_message_receiver() public {
vm.startPrank(owner);
vm.startPrank(gacOwner);

vm.expectEmit(true, true, true, true, address(receiverGAC));
emit MultiBridgeMessageReceiverUpdated(address(receiverGAC.getMultiBridgeMessageReceiver()), address(42));
Expand All @@ -54,20 +56,20 @@ contract MessageReceiverGACTest is Setup {

/// @dev cannot set multi message receiver to zero address
function test_set_multi_message_receiver_zero_address() public {
vm.startPrank(owner);
vm.startPrank(gacOwner);

vm.expectRevert(Error.ZERO_ADDRESS_INPUT.selector);
receiverGAC.setMultiBridgeMessageReceiver(address(0));
}

/// @dev checks if address is the global owner
function test_is_global_owner() public {
assertTrue(receiverGAC.isGlobalOwner(owner));
assertTrue(receiverGAC.isGlobalOwner(gacOwner));
assertFalse(receiverGAC.isGlobalOwner(caller));
}

/// @dev gets the global owner
function test_get_global_owner() public {
assertEq(receiverGAC.getGlobalOwner(), owner);
assertEq(receiverGAC.getGlobalOwner(), gacOwner);
}
}
10 changes: 6 additions & 4 deletions test/unit-tests/MultiBridgeMessageSender.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,11 @@ contract MultiBridgeMessageSenderTest is Setup {
function test_add_sender_adapters_higher_addresses() public {
vm.startPrank(owner);

(address[] memory existingAdpSorted) = _sortTwoAdapters(wormholeAdapterAddr, axelarAdapterAddr);

address[] memory adapters = new address[](2);
address higherAddr0 = address(uint160(wormholeAdapterAddr) + 1);
address higherAddr1 = address(uint160(wormholeAdapterAddr) + 2);
address higherAddr0 = address(uint160(existingAdpSorted[1]) + 1);
address higherAddr1 = address(uint160(existingAdpSorted[1]) + 2);
adapters[0] = higherAddr0;
adapters[1] = higherAddr1;

Expand All @@ -475,8 +477,8 @@ contract MultiBridgeMessageSenderTest is Setup {

sender.addSenderAdapters(adapters);

assertEq(sender.senderAdapters(0), axelarAdapterAddr);
assertEq(sender.senderAdapters(1), wormholeAdapterAddr);
assertEq(sender.senderAdapters(0), existingAdpSorted[0]);
assertEq(sender.senderAdapters(1), existingAdpSorted[1]);
assertEq(sender.senderAdapters(2), higherAddr0);
assertEq(sender.senderAdapters(3), higherAddr1);
}
Expand Down

0 comments on commit d5fdee8

Please sign in to comment.