Skip to content

Commit

Permalink
fix: forge fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed Sep 10, 2024
1 parent 0f07067 commit e432b5e
Showing 1 changed file with 20 additions and 37 deletions.
57 changes: 20 additions & 37 deletions contracts/test/helpers/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,18 @@ contract Utils is Test, JSONDecoder {
return cfg.l2OutputOracleProxy;
}

function upgradeAndInitialize(
address impl,
Config memory cfg,
address _spoofedAdmin
) public {
function upgradeAndInitialize(address impl, Config memory cfg, address _spoofedAdmin) public {
// require that the verifier gateway is deployed
require(
address(cfg.verifierGateway).code.length > 0,
"ZKUpgrader: verifier gateway not deployed"
);
require(address(cfg.verifierGateway).code.length > 0, "ZKUpgrader: verifier gateway not deployed");

ZKL2OutputOracle.ZKInitParams memory zkInitParams = ZKL2OutputOracle
.ZKInitParams({
chainId: cfg.chainId,
verifierGateway: cfg.verifierGateway,
vkey: cfg.vkey,
owner: cfg.owner,
startingOutputRoot: cfg.startingOutputRoot,
rollupConfigHash: cfg.rollupConfigHash
});
ZKL2OutputOracle.ZKInitParams memory zkInitParams = ZKL2OutputOracle.ZKInitParams({
chainId: cfg.chainId,
verifierGateway: cfg.verifierGateway,
vkey: cfg.vkey,
owner: cfg.owner,
startingOutputRoot: cfg.startingOutputRoot,
rollupConfigHash: cfg.rollupConfigHash
});

// If we are spoofing the admin (used in testing), start prank.
if (_spoofedAdmin != address(0)) vm.startPrank(_spoofedAdmin);
Expand All @@ -64,22 +56,19 @@ contract Utils is Test, JSONDecoder {
);
}

function readJson(
string memory filepath
) public view returns (Config memory) {
function readJson(string memory filepath) public view returns (Config memory) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/", filepath);
string memory json = vm.readFile(path);
bytes memory data = vm.parseJson(json);
return abi.decode(data, (Config));
}

function fetchOutputRoot(
Config memory config
) public returns (bytes32 startingOutputRoot, uint256 startingTimestamp) {
string memory hexStartingBlockNumber = createHexString(
config.startingBlockNumber
);
function fetchOutputRoot(Config memory config)
public
returns (bytes32 startingOutputRoot, uint256 startingTimestamp)
{
string memory hexStartingBlockNumber = createHexString(config.startingBlockNumber);

string memory l2NodeRpc = vm.envString("L2_NODE_RPC");

Expand All @@ -94,10 +83,7 @@ contract Utils is Test, JSONDecoder {

string memory jsonRes = string(vm.ffi(inputs));
bytes memory outputRootBytes = vm.parseJson(jsonRes, ".outputRoot");
bytes memory startingTimestampBytes = vm.parseJson(
jsonRes,
".blockRef.timestamp"
);
bytes memory startingTimestampBytes = vm.parseJson(jsonRes, ".blockRef.timestamp");

startingOutputRoot = abi.decode(outputRootBytes, (bytes32));
startingTimestamp = abi.decode(startingTimestampBytes, (uint256));
Expand Down Expand Up @@ -127,15 +113,12 @@ contract Utils is Test, JSONDecoder {
vm.ffi(inputs2);
}

function createHexString(
uint256 value
) public pure returns (string memory) {
function createHexString(uint256 value) public pure returns (string memory) {
string memory hexStartingBlockNum = Strings.toHexString(value);
bytes memory startingBlockNumAsBytes = bytes(hexStartingBlockNum);
require(
startingBlockNumAsBytes.length >= 4 &&
startingBlockNumAsBytes[0] == "0" &&
startingBlockNumAsBytes[1] == "x",
startingBlockNumAsBytes.length >= 4 && startingBlockNumAsBytes[0] == "0"
&& startingBlockNumAsBytes[1] == "x",
"Invalid input"
);

Expand Down

0 comments on commit e432b5e

Please sign in to comment.