Skip to content

Commit

Permalink
feat: bring branch coverage for string lib to 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
sujithsomraaj committed Oct 12, 2023
1 parent bf0d472 commit a2b47d8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 20 deletions.
36 changes: 18 additions & 18 deletions lcov.info
Original file line number Diff line number Diff line change
Expand Up @@ -476,33 +476,33 @@ DA:17,300
DA:18,300
DA:20,15
FN:23,StringAddressConversion.toAddress
FNDA:6,StringAddressConversion.toAddress
DA:24,6
DA:25,6
DA:26,6
DA:28,6
FNDA:8,StringAddressConversion.toAddress
DA:24,8
DA:25,8
DA:26,8
DA:28,8
BRDA:28,0,0,4
BRDA:28,0,1,2
DA:30,2
DA:31,79
DA:33,79
BRDA:33,1,0,-
BRDA:33,1,1,79
DA:34,79
BRDA:34,2,0,-
BRDA:28,0,1,4
DA:30,4
DA:31,159
DA:33,159
BRDA:33,1,0,40
BRDA:33,1,1,119
DA:34,119
BRDA:34,2,0,40
BRDA:34,2,1,79
DA:35,79
BRDA:35,3,0,78
BRDA:35,3,1,1
DA:36,1
DA:38,78
DA:40,1
DA:38,158
DA:40,3
FNF:2
FNH:2
LF:22
LH:22
BRF:8
BRH:6
BRH:8
end_of_record
TN:
SF:src/adapters/wormhole/WormholeReceiverAdapter.sol
Expand Down Expand Up @@ -1144,8 +1144,8 @@ FN:12,StringAddressConversionHelper.toString
FNDA:1,StringAddressConversionHelper.toString
DA:13,1
FN:16,StringAddressConversionHelper.toAddress
FNDA:6,StringAddressConversionHelper.toAddress
DA:17,6
FNDA:8,StringAddressConversionHelper.toAddress
DA:17,8
FNF:2
FNH:2
LF:2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,22 @@ contract StringAddressConversionTest is Test {
vm.expectRevert(selector);
conversionHelper.toAddress(invalidCharacterAddressString);
}

/// @dev tests conversion of string with lowercase hex characters to address
function testLowercaseHexCharacterToAddress() public {
string memory testString = "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd";
address result = conversionHelper.toAddress(testString);
address expected = address(0xABcdEFABcdEFabcdEfAbCdefabcdeFABcDEFabCD);

assertTrue(result == expected, "Converted address with lowercase hex characters does not match expected value");
}

/// @dev tests conversion of string with uppercase hex characters to address
function testUppercaseHexCharacterToAddress() public {
string memory testString = "0xABCDEFABCDEFABCDEFABCDEFABCDEFABCDEFABCD";
address result = conversionHelper.toAddress(testString);
address expected = address(0xABcdEFABcdEFabcdEfAbCdefabcdeFABcDEFabCD);

assertTrue(result == expected, "Converted address with uppercase hex characters does not match expected value");
}
}
4 changes: 2 additions & 2 deletions test/unit-tests/libraries/EIP5164/ExecutorAware.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ contract ExecutorAwareTest is Test {
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");
Expand All @@ -74,7 +74,7 @@ contract ExecutorAwareTest is Test {
executorAware.addTrustedExecutor(executor2);

uint256 count = executorAware.trustedExecutorsCount();

assertTrue(count == 2, "There should be two trusted executors");
}
}

0 comments on commit a2b47d8

Please sign in to comment.