Skip to content

Commit

Permalink
test: updates tests
Browse files Browse the repository at this point in the history
  • Loading branch information
reednaa committed Jan 14, 2024
1 parent 4ef8154 commit c2bf4ef
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ contract GasSpendControlTest is TestCommon {
messageIdentifier,
_DESTINATION_ADDRESS_APPLICATION,
destinationFeeRecipitent,
uint48(0x36e8d), // Gas used
uint48(0x36eaa), // Gas used
uint64(1),
bytes1(0xff), // This states that the call went wrong.
message
Expand Down Expand Up @@ -93,9 +93,9 @@ contract GasSpendControlTest is TestCommon {
function test_fail_relayer_has_to_provide_enough_gas() public {
bytes32 destinationFeeRecipitent = bytes32(uint256(uint160(address(this))));

_INCENTIVE.maxGasDelivery = 200000; // This is not enough gas to execute the receiveCall. We should expect the sub-call to revert but the main call shouldn't.
_INCENTIVE.maxGasDelivery = 2000000; // This is not enough gas to execute the receiveCall. We should expect the sub-call to revert but the main call shouldn't.

(bytes32 messageIdentifier, bytes memory messageWithContext) = setupsubmitMessage(address(application), abi.encodePacked(bytes2(uint16(1000))));
(bytes32 messageIdentifier, bytes memory messageWithContext) = setupsubmitMessage(address(application), abi.encodePacked(bytes2(uint16(10000))));

(uint8 v, bytes32 r, bytes32 s) = signMessageForMock(messageWithContext);
bytes memory mockContext = abi.encode(v, r, s);
Expand All @@ -104,7 +104,7 @@ contract GasSpendControlTest is TestCommon {

// The strange gas limit of '<gas> + 5000 - 2' here is because <gas> is how much is actually spent (read from trace) and + 5000 - 2 is some kind of refund that
// the relayer needs to add as extra. (reentry refund)
escrow.processPacket{gas: 239958}(
escrow.processPacket{gas: 2039993 + 40000}(
mockContext,
messageWithContext,
destinationFeeRecipitent
Expand All @@ -113,7 +113,7 @@ contract GasSpendControlTest is TestCommon {
vm.revertTo(snapshot_num);

// While not perfect, it is a decent way to ensure that the gas delivery is kept true.
vm.expectRevert();
vm.expectRevert(abi.encodeWithSignature("NotEnoughGasExeuction()"));
vm.expectCall(
address(application),
abi.encodeCall(
Expand All @@ -122,11 +122,11 @@ contract GasSpendControlTest is TestCommon {
bytes32(0x8000000000000000000000000000000000000000000000000000000000123123),
messageIdentifier,
hex"140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f62849f9a0b5bf2913b396098f7c7019b51a820a",
hex"03e8"
hex"2710"
)
)
);
escrow.processPacket{gas: 239958 - 1}(
escrow.processPacket{gas: 2039993}(
mockContext,
messageWithContext,
destinationFeeRecipitent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ contract processPacketNoReceiveTest is TestCommon {
messageIdentifier,
_DESTINATION_ADDRESS_THIS,
feeRecipitent,
uint48(0x8860), // Gas used
uint48(0x887d), // Gas used
uint64(1),
abi.encodePacked(bytes1(0xff)),
message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ contract CallReentryTest is TestCommon, ICrossChainReceiver {
messageIdentifier,
_DESTINATION_ADDRESS_APPLICATION,
feeRecipitent,
uint48(0x10039), // Gas used
uint48(0x10038), // Gas used
uint64(1),
uint8(1)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ contract processPacketCallTest is TestCommon {
messageIdentifier,
_DESTINATION_ADDRESS_APPLICATION,
feeRecipitent,
uint48(0x82a3), // Gas used
uint48(0x829f), // Gas used
uint64(1),
mockAck
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ contract OnRecvCallTest is TestOnRecvCommon {
messageIdentifier,
_DESTINATION_ADDRESS_APPLICATION,
feeRecipitent,
uint48(0x6b0a), // Gas used
uint48(0x6b27), // Gas used
uint64(1),
hex"d9b60178cfb2eb98b9ff9136532b6bd80eeae6a2c90a2f96470294981fcfb62b"
)
Expand Down
6 changes: 3 additions & 3 deletions test/TestCommon.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ interface ICansubmitMessage is IMessageEscrowStructs{

contract TestCommon is Test, IMessageEscrowEvents, IMessageEscrowStructs {

uint256 constant GAS_SPENT_ON_SOURCE = 6330;
uint256 constant GAS_SPENT_ON_DESTINATION = 33443;
uint256 constant GAS_RECEIVE_CONSTANT = 6156932793;
uint256 constant GAS_SPENT_ON_SOURCE = 6333;
uint256 constant GAS_SPENT_ON_DESTINATION = 33439;
uint256 constant GAS_RECEIVE_CONSTANT = 6157402878;

bytes32 constant _DESTINATION_IDENTIFIER = bytes32(uint256(0x123123) + uint256(2**255));

Expand Down

0 comments on commit c2bf4ef

Please sign in to comment.