Skip to content

Commit 49182f4

Browse files
committed
improve ICS20 tests
Signed-off-by: Jun Kimura <jun.kimura@datachain.jp>
1 parent b41cdf7 commit 49182f4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/foundry/src/ICS20.t.sol

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ contract TestICS20 is Test {
106106
// This should not revert if the input is not a valid hex string.
107107
ICS20LibTestHelper.hexStringToAddress(any);
108108
}
109+
110+
function testParseUint256String() public {
111+
bytes memory maxAmountStr = bytes("115792089237316195423570985008687907853269984665640564039457584007913129639935\"");
112+
(uint256 amount, uint256 pos) = ICS20LibTestHelper.parseUint256String(maxAmountStr, 0);
113+
assertEq(amount, 115792089237316195423570985008687907853269984665640564039457584007913129639935);
114+
assertEq(pos, maxAmountStr.length);
115+
116+
bytes memory minAmountStr = bytes("1\"");
117+
(amount, pos) = ICS20LibTestHelper.parseUint256String(minAmountStr, 0);
118+
assertEq(amount, 1);
119+
assertEq(pos, minAmountStr.length);
120+
}
109121
}
110122

111123
library ICS20LibTestHelper {
@@ -128,4 +140,8 @@ library ICS20LibTestHelper {
128140
function isEscapedJSONString(string calldata s) public pure returns (bool) {
129141
return ICS20Lib.isEscapedJSONString(s);
130142
}
143+
144+
function parseUint256String(bytes calldata bz, uint256 pos) public pure returns (uint256, uint256) {
145+
return ICS20Lib.parseUint256String(bz, pos);
146+
}
131147
}

0 commit comments

Comments
 (0)