Skip to content

Commit

Permalink
chore: change to assertEq
Browse files Browse the repository at this point in the history
  • Loading branch information
sujithsomraaj committed Oct 12, 2023
1 parent a14ff11 commit 1481243
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
3 changes: 2 additions & 1 deletion test/unit-tests/MultiBridgeMessageReceiver.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,8 @@ contract MultiBridgeMessageReceiverTest is Setup {

/// @dev should get message info for invalid message id
function test_get_message_info_invalid_message_id() public {
(bool isScheduled, uint256 msgCurrentVotes, string[] memory successfulBridge) = receiver.getMessageInfo(bytes32(0));
(bool isScheduled, uint256 msgCurrentVotes, string[] memory successfulBridge) =
receiver.getMessageInfo(bytes32(0));
assertFalse(isScheduled);
assertEq(msgCurrentVotes, 0);
assertEq(successfulBridge.length, 0);
Expand Down
24 changes: 12 additions & 12 deletions test/unit-tests/libraries/EIP5164/ExecutorAware.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,48 +33,48 @@ contract ExecutorAwareTest is Test {
//////////////////////////////////////////////////////////////*/

/// @dev tests adding a trusted executor
function testAddTrustedExecutor() public {
function test_add_trusted_executor() public {
address executor = address(0x1234567890123456789012345678901234567890);
bool added = executorAware.addTrustedExecutor(executor);

assertTrue(added, "Executor should be added successfully");
assertTrue(executorAware.isTrustedExecutor(executor), "Executor should be trusted after addition");
assertEq(added, true);
assertEq(executorAware.isTrustedExecutor(executor), true);
}

/// @dev tests removing a trusted executor
function testRemoveTrustedExecutor() public {
function test_remove_trusted_executor() public {
address executor = address(0x1234567890123456789012345678901234567890);
executorAware.addTrustedExecutor(executor);

bool removed = executorAware.removeTrustedExecutor(executor);

assertTrue(removed, "Executor should be removed successfully");
assertFalse(executorAware.isTrustedExecutor(executor), "Executor should no longer be trusted after removal");
assertEq(removed, true);
assertEq(executorAware.isTrustedExecutor(executor), false);
}

/// @dev tests retrieval of trusted executors
function testGetTrustedExecutors() public {
function test_get_trusted_executors() public {
address executor1 = address(420);
address executor2 = address(421);
executorAware.addTrustedExecutor(executor1);
executorAware.addTrustedExecutor(executor2);

address[] memory executors = executorAware.getTrustedExecutors();

assertTrue(executors.length == 2, "There should be two trusted executors");
assertTrue(executors[0] == executor1 || executors[1] == executor1, "Executor1 should be in the returned list");
assertTrue(executors[0] == executor2 || executors[1] == executor2, "Executor2 should be in the returned list");
assertEq(executors.length == 2, true);
assertEq(executors[0], executor1);
assertEq(executors[1], executor2);
}

/// @dev tests counting the number of trusted executors
function testTrustedExecutorsCount() public {
function test_trusted_executors_count() public {
address executor1 = address(420);
address executor2 = address(421);
executorAware.addTrustedExecutor(executor1);
executorAware.addTrustedExecutor(executor2);

uint256 count = executorAware.trustedExecutorsCount();

assertTrue(count == 2, "There should be two trusted executors");
assertEq(count, 2);
}
}
25 changes: 12 additions & 13 deletions test/unit-tests/libraries/Message.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract MessageLibraryTest is Test {
}

/// @dev tests computation of message id
function testComputeMsgId() public {
function test_compute_msg_id() public {
// convert the string literal to bytes constant
bytes memory callDataBytes = hex"abcdef";

Expand Down Expand Up @@ -77,11 +77,11 @@ contract MessageLibraryTest is Test {
)
);

assertTrue(computedId == expectedId, "Message ID does not match expected value");
assertEq(computedId, expectedId);
}

/// @dev tests extraction of execution parameters from a message
function testExtractExecutionParams() public {
function test_extract_execution_params() public {
MessageLibrary.Message memory message = MessageLibrary.Message({
srcChainId: 1,
dstChainId: 2,
Expand All @@ -94,16 +94,15 @@ contract MessageLibraryTest is Test {

MessageLibrary.MessageExecutionParams memory params = messageHelper.extractExecutionParams(message);

assertTrue(
params.target == address(0x1234567890123456789012345678901234567890)
&& keccak256(params.callData) == keccak256(hex"abcdef") && params.value == 456 && params.nonce == 123
&& params.expiration == 10000,
"Extracted execution parameters are incorrect"
);
assertEq(params.target, address(0x1234567890123456789012345678901234567890));
assertEq(keccak256(params.callData), keccak256(hex"abcdef"));
assertEq(params.value, 456);
assertEq(params.nonce, 123);
assertEq(params.expiration, 10000);
}

/// @dev tests computation of execution parameters hash directly from parameters
function testComputeExecutionParamsHash() public {
function test_compute_execution_params_hash() public {
MessageLibrary.MessageExecutionParams memory params = MessageLibrary.MessageExecutionParams({
target: address(0x1234567890123456789012345678901234567890),
callData: hex"abcdef",
Expand All @@ -123,11 +122,11 @@ contract MessageLibraryTest is Test {
)
);

assertTrue(computedHash == expectedHash, "Execution parameters hash does not match expected value");
assertEq(computedHash, expectedHash);
}

/// @dev tests computation of execution parameters hash from a message
function testComputeExecutionParamsHashFromMessage() public {
function test_compute_execution_params_hash_from_message() public {
MessageLibrary.Message memory message = MessageLibrary.Message({
srcChainId: 1,
dstChainId: 2,
Expand All @@ -149,6 +148,6 @@ contract MessageLibraryTest is Test {
)
);

assertTrue(computedHash == expectedHash, "Execution parameters hash from message does not match expected value");
assertEq(computedHash, expectedHash);
}
}
6 changes: 3 additions & 3 deletions test/unit-tests/libraries/TypeCasts.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ contract TypeCastsTest is Test {
//////////////////////////////////////////////////////////////*/

/// @dev tests conversion of address to bytes32
function testAddressToBytes32() public {
function test_address_to_bytes32() public {
address testAddr = address(0x1234567890123456789012345678901234567890);
bytes32 expected = bytes32(uint256(uint160(testAddr))); // Correct casting here
bytes32 result = typeCastsHelper.addressToBytes32(testAddr);

assertTrue(result == expected, "Converted bytes32 value does not match expected value");
assertEq(result, expected);
}

/// @dev tests conversion of bytes32 to address
Expand All @@ -48,6 +48,6 @@ contract TypeCastsTest is Test {
address expected = address(uint160(uint256(testBytes))); // Correct casting here
address result = typeCastsHelper.bytes32ToAddress(testBytes);

assertTrue(result == expected, "Converted address value does not match expected value");
assertEq(result, expected);
}
}

0 comments on commit 1481243

Please sign in to comment.