generated from PaulRBerg/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: lint json * fix test run
- Loading branch information
Showing
7 changed files
with
54 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.25; | ||
|
||
import "forge-std/src/Test.sol"; | ||
|
||
contract LintJSON is Test { | ||
function _lintJSON(string memory json) internal { | ||
if (vm.envOr("COVERAGE", false)) { | ||
// Don't check if we're running coverage | ||
return; | ||
} | ||
|
||
vm.writeFile("./out/lint-json.json", json); | ||
string[] memory inputs = new string[](3); | ||
inputs[0] = "npx"; | ||
inputs[1] = "ts-node"; | ||
inputs[2] = "./utils/lint-json.ts"; | ||
bytes memory ffiResp = vm.ffi(inputs); | ||
|
||
uint256 resAsInt; | ||
assembly { | ||
resAsInt := mload(add(ffiResp, 0x20)) | ||
} | ||
if (resAsInt != 1) { | ||
revert("JSON lint failed"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import fs from "fs"; | ||
|
||
const jsonString = fs.readFileSync("./out/lint-json.json", "utf8"); | ||
try { | ||
JSON.parse(jsonString.substring(27)); | ||
} catch { | ||
// Invalid json | ||
process.stdout.write("0x0000000000000000000000000000000000000000000000000000000000000002"); | ||
process.exit(); | ||
} | ||
|
||
process.stdout.write("0x0000000000000000000000000000000000000000000000000000000000000001"); | ||
process.exit(); |