From 666c84d7832b029775c8d1b259da35fd8d7c32b3 Mon Sep 17 00:00:00 2001 From: wshino Date: Wed, 11 Sep 2024 01:29:53 +0900 Subject: [PATCH] Fix integration test except for eml files --- .../missing_library_dependencies.json | 14 ++++++++++++++ packages/contracts/README.md | 12 ++++++------ packages/contracts/foundry.toml | 14 ++++++++++++-- packages/contracts/test/IntegrationZKSync.t.sol | 6 +++--- 4 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 packages/contracts/.zksolc-libraries-cache/missing_library_dependencies.json diff --git a/packages/contracts/.zksolc-libraries-cache/missing_library_dependencies.json b/packages/contracts/.zksolc-libraries-cache/missing_library_dependencies.json new file mode 100644 index 0000000..0e7f1f1 --- /dev/null +++ b/packages/contracts/.zksolc-libraries-cache/missing_library_dependencies.json @@ -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": [] + } +] \ No newline at end of file diff --git a/packages/contracts/README.md b/packages/contracts/README.md index 742ceaf..69382d4 100644 --- a/packages/contracts/README.md +++ b/packages/contracts/README.md @@ -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. @@ -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. @@ -352,12 +352,12 @@ 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. @@ -365,7 +365,7 @@ 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) diff --git a/packages/contracts/foundry.toml b/packages/contracts/foundry.toml index bf78c03..4edb0e0 100644 --- a/packages/contracts/foundry.toml +++ b/packages/contracts/foundry.toml @@ -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}" diff --git a/packages/contracts/test/IntegrationZKSync.t.sol b/packages/contracts/test/IntegrationZKSync.t.sol index 4fe62b0..f6d6ed6 100644 --- a/packages/contracts/test/IntegrationZKSync.t.sol +++ b/packages/contracts/test/IntegrationZKSync.t.sol @@ -147,7 +147,7 @@ contract IntegrationZKSyncTest is Test { console.log("SimpleWallet is at ", address(simpleWallet)); assertEq( address(simpleWallet), - 0x7c5E4b26643682AF77A196781A851c9Fe769472d + 0xc9a403a0f75924677Dc0b011Da7eD8dD902063A6 ); address simpleWalletOwner = simpleWallet.owner(); @@ -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; @@ -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]));