Skip to content

Commit

Permalink
Fix integration test except for eml files
Browse files Browse the repository at this point in the history
  • Loading branch information
wshino committed Sep 10, 2024
1 parent 8a4d55a commit 666c84d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"contract_name": "CommandUtils",
"contract_path": "src/libraries/CommandUtils.sol",
"missing_libraries": [
"src/libraries/DecimalUtils.sol:DecimalUtils"
]
},
{
"contract_name": "DecimalUtils",
"contract_path": "src/libraries/DecimalUtils.sol",
"missing_libraries": []
}
]
12 changes: 6 additions & 6 deletions packages/contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,14 @@ You can deploy them by the following command for example.

```
$ forge build --zksync --zk-detect-missing-libraries
Missing libraries detected: src/libraries/SubjectUtils.sol:SubjectUtils, src/libraries/DecimalUtils.sol:DecimalUtils
Missing libraries detected: src/libraries/CommandUtils.sol:CommandUtils, src/libraries/DecimalUtils.sol:DecimalUtils
```

Run the following command in order to deploy each missing library:

```
forge create src/libraries/DecimalUtils.sol:DecimalUtils --private-key {YOUR_PRIVATE_KEY} --rpc-url https://sepolia.era.zksync.dev --chain 300 --zksync
forge create src/libraries/SubjectUtils.sol:SubjectUtils --private-key {YOUR_PRIVATE_KEY} --rpc-url https://sepolia.era.zksync.dev --chain 300 --zksync --libraries src/libraries/DecimalUtils.sol:DecimalUtils:{DECIMAL_UTILS_DEPLOYED_ADDRESS}
forge create src/libraries/CommandUtils.sol:CommandUtils --private-key {YOUR_PRIVATE_KEY} --rpc-url https://sepolia.era.zksync.dev --chain 300 --zksync --libraries src/libraries/DecimalUtils.sol:DecimalUtils:{DECIMAL_UTILS_DEPLOYED_ADDRESS}
```

After that, you can see the following line in foundry.toml.
Expand All @@ -284,7 +284,7 @@ Also, this line is needed only for foundry-zksync, if you use foundry, please re
```
libraries = [
"{PROJECT_DIR}/packages/contracts/src/libraries/DecimalUtils.sol:DecimalUtils:{DEPLOYED_ADDRESS}",
"{PROJECT_DIR}/packages/contracts/src/libraries/SubjectUtils.sol:SubjectUtils:{DEPLOYED_ADDRESS}"]
"{PROJECT_DIR}/packages/contracts/src/libraries/CommandUtils.sol:CommandUtils:{DEPLOYED_ADDRESS}"]
```

Incidentally, the above line already exists in `foundy.toml` with it commented out, if you uncomment it by replacing `{PROJECT_DIR}` with the appropriate path, it will also work.
Expand Down Expand Up @@ -352,20 +352,20 @@ As you saw before, you need to deploy missing libraries.
You can deploy them by the following command for example.

```
Missing libraries detected: src/libraries/SubjectUtils.sol:SubjectUtils, src/libraries/DecimalUtils.sol:DecimalUtils
Missing libraries detected: src/libraries/CommandUtils.sol:CommandUtils, src/libraries/DecimalUtils.sol:DecimalUtils
Run the following command in order to deploy each missing library:
forge create src/libraries/DecimalUtils.sol:DecimalUtils --private-key {YOUR_PRIVATE_KEY} --rpc-url http://127.0.0.1:8011 --chain 260 --zksync
forge create src/libraries/SubjectUtils.sol:SubjectUtils --private-key {YOUR_PRIVATE_KEY} --rpc-url http://127.0.0.1:8011 --chain 260 --zksync --libraries src/libraries/DecimalUtils.sol:DecimalUtils:{DECIMAL_UTILS_DEPLOYED_ADDRESS}
forge create src/libraries/CommandUtils.sol:CommandUtils --private-key {YOUR_PRIVATE_KEY} --rpc-url http://127.0.0.1:8011 --chain 260 --zksync --libraries src/libraries/DecimalUtils.sol:DecimalUtils:{DECIMAL_UTILS_DEPLOYED_ADDRESS}
```

Set the libraries in foundry.toml using the above deployed address.

And then, run the integration testing.

```
forge test --match-contract "IntegrationZkSyncTest" --system-mode=true --zksync --gas-limit 1000000000 --chain 300 -vvv --ffi
forge test --match-contract "IntegrationZKSyncTest" --system-mode=true --zksync --gas-limit 1000000000 --chain 300 -vvv --ffi
```

# For zkSync deployment (For test net)
Expand Down
14 changes: 12 additions & 2 deletions packages/contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,18 @@ solc = "0.8.26"
build_info = true
extra_output = ["storageLayout"]

# For missing libraries, please comment out this if you use foundry-zksync
#libraries = ["{PROJECT_DIR}/packages/contracts/src/libraries/DecimalUtils.sol:DecimalUtils:0x91cc0f0a227b8dd56794f9391e8af48b40420a0b", "{PROJECT_DIR}/packages/contracts/src/libraries/CommandUtils.sol:CommandUtils:0x981e3df952358a57753c7b85de7949da4abcf54a"]
# For missing libraries, please comment out this if you use foundry-zksync for unit test
#libraries = [
# "{PROJECT_DIR}/packages/contracts/src/libraries/DecimalUtils.sol:DecimalUtils:0x91cc0f0a227b8dd56794f9391e8af48b40420a0b",
# "{PROJECT_DIR}/packages/contracts/src/libraries/CommandUtils.sol:CommandUtils:0x981e3df952358a57753c7b85de7949da4abcf54a"
#]

# For missing libraries, please comment out this if you use foundry-zksync for integration test
#libraries = [
# "{PROJECT_DIR}/packages/contracts/src/libraries/DecimalUtils.sol:DecimalUtils:0x34eb91D6a0c6Cea4B3b2e4eE8176d6Fc120CB133",
# "{PROJECT_DIR}/packages/contracts/src/libraries/CommandUtils.sol:CommandUtils:0x3CE48a2c96889FeB67f2e3fb0285AEc9e3FCb68b"
#]


[rpc_endpoints]
localhost = "${LOCALHOST_RPC_URL}"
Expand Down
6 changes: 3 additions & 3 deletions packages/contracts/test/IntegrationZKSync.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ contract IntegrationZKSyncTest is Test {
console.log("SimpleWallet is at ", address(simpleWallet));
assertEq(
address(simpleWallet),
0x7c5E4b26643682AF77A196781A851c9Fe769472d
0xc9a403a0f75924677Dc0b011Da7eD8dD902063A6
);
address simpleWalletOwner = simpleWallet.owner();

Expand Down Expand Up @@ -182,7 +182,7 @@ contract IntegrationZKSyncTest is Test {
emailProof.publicKeyHash = bytes32(vm.parseUint(pubSignals[9]));
emailProof.timestamp = vm.parseUint(pubSignals[11]);
emailProof
.maskedCommand = "Accept guardian request for 0x7c5E4b26643682AF77A196781A851c9Fe769472d";
.maskedCommand = "Accept guardian request for 0xc9a403a0f75924677Dc0b011Da7eD8dD902063A6";
emailProof.emailNullifier = bytes32(vm.parseUint(pubSignals[10]));
emailProof.accountSalt = bytes32(vm.parseUint(pubSignals[32]));
accountSalt = emailProof.accountSalt;
Expand Down Expand Up @@ -263,7 +263,7 @@ contract IntegrationZKSyncTest is Test {

// 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 is account 9
emailProof
.maskedCommand = "Set the new signer of 0x7c5E4b26643682AF77A196781A851c9Fe769472d to 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720";
.maskedCommand = "Set the new signer of 0xc9a403a0f75924677Dc0b011Da7eD8dD902063A6 to 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720";

emailProof.emailNullifier = bytes32(vm.parseUint(pubSignals[10]));
emailProof.accountSalt = bytes32(vm.parseUint(pubSignals[32]));
Expand Down

0 comments on commit 666c84d

Please sign in to comment.