foundry
foundry copied to clipboard
bug: `vm.parseJson` with static array parses incorrectly
Component
Forge
Have you ensured that all of these are up to date?
- [X] Foundry
- [X] Foundryup
What version of Foundry are you on?
forge 0.2.0 (08a629a 2023-06-03T00:14:26.563741000Z)
What command(s) is the bug in?
forge test
Operating System
macOS (Apple Silicon)
Describe the bug
Parsing a static sized array fails.
struct Simple {
uint256[1] timestamp;
}
function testParseJsonStaticArray() public {
string memory json = '{"timestamp": [1655140035]}';
bytes memory data = vm.parseJson(json);
Simple memory fixture = abi.decode(data, (Simple));
assertEq(fixture.timestamp[0], 1655140035);
}
fails, yet (with dynamically sized array)
struct Simple {
uint256[] timestamp;
}
function testParseJsonStaticArray() public {
string memory json = '{"timestamp": [1655140035]}';
bytes memory data = vm.parseJson(json);
Simple memory fixture = abi.decode(data, (Simple));
assertEq(fixture.timestamp[0], 1655140035);
}
passes
I've forked and made a PR that adds the failing test. https://github.com/foundry-rs/forge-std/pull/422.
I did the fork & branch against forge-std as I'm new to solidity/forge and couldn't get the foundry/forge solidity tests to run.