Skip to content

Commit

Permalink
tests(zk): convert missing libs tests to scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Karrq committed May 16, 2024
1 parent 85793da commit dc4b81f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions zk-tests/src/MissingLibraries.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.13;

import {Maths} from "./Maths.sol";
import 'forge-std/Test.sol';
import 'forge-std/Script.sol';

contract Mathematician {
uint256 public number;
Expand All @@ -16,10 +16,10 @@ contract Mathematician {
}
}

contract MathematicianTest is Test {
function testLibraries() external {
contract MathematicianScript is Script {
function run() external {
Mathematician maths = new Mathematician(2);

assertEq(maths.square(), 4);
assert(maths.square() == 4);
}
}
8 changes: 4 additions & 4 deletions zk-tests/src/NestedMissingLibraries.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.13;

import {NestedMaths} from "./NestedMaths.sol";
import 'forge-std/Test.sol';
import 'forge-std/Script.sol';

contract NestedMathematician {
uint256 public number;
Expand All @@ -16,10 +16,10 @@ contract NestedMathematician {
}
}

contract NestedMathematicianTest is Test {
function testNestedLibraries() external {
contract NestedMathematicianScript is Script {
function run() external {
NestedMathematician maths = new NestedMathematician(2);

assertEq(maths.square(), 4);
assert(maths.square() == 4);
}
}
2 changes: 2 additions & 0 deletions zk-tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ output=$(RUST_LOG=warn "${FORGE}" build --zksync 2>&1 || true)

if echo "$output" | grep -q "Missing libraries detected"; then
RUST_LOG=warn "${FORGE}" create --deploy-missing-libraries --rpc-url $RPC_URL --private-key $PRIVATE_KEY --zksync
RUST_LOG=warn "${FORGE}" script ./src/MissingLibraries.sol:MathematicianScript --rpc-url $RPC_URL --private-key $PRIVATE_KEY --zksync --chain 260 --use "./${SOLC}" -vvv || fail "forge script with libs failed"
RUST_LOG=warn "${FORGE}" script ./src/NestedMissingLibraries.sol:NestedMathematicianScript --rpc-url $RPC_URL --private-key $PRIVATE_KEY --zksync --chain 260 --use "./${SOLC}" -vvv || fail "forge script with nested libs failed"
else
echo "No missing libraries detected."
fi
Expand Down

0 comments on commit dc4b81f

Please sign in to comment.