Skip to content

Commit

Permalink
test: make mocked tests work
Browse files Browse the repository at this point in the history
  • Loading branch information
jatZama authored and antoniupop committed Dec 3, 2024
1 parent 03b2c07 commit f3adb16
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion contracts/examples/BlindAuction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.24;
import "../lib/TFHE.sol";
import "./EncryptedERC20.sol";
import "@openzeppelin/contracts/access/Ownable2Step.sol";
import "../gateway/GatewayCaller.sol";
import "../gatewayLib/GatewayCaller.sol";

/// @notice Main contract for the blind auction
contract BlindAuction is Ownable2Step, GatewayCaller {
Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/TestAsyncDecrypt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.24;

import "../lib/TFHE.sol";
import "../gateway/GatewayCaller.sol";
import "../gatewayLib/GatewayCaller.sol";

/// @notice Contract for testing asynchronous decryption using the Gateway
contract TestAsyncDecrypt is GatewayCaller {
Expand Down
2 changes: 1 addition & 1 deletion contracts/tasks/etherscanVerify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ task('task:verifyFHEPayment').setAction(async function (taskArguments, { upgrade
});

task('task:verifyGatewayContract').setAction(async function (taskArguments, { upgrades, run }) {
const parsedEnvGateway = dotenv.parse(fs.readFileSync('gateway/.env.gateway'));
const parsedEnvGateway = dotenv.parse(fs.readFileSync('addresses/.env.gateway'));
const proxyGateway = parsedEnvGateway.GATEWAY_CONTRACT_PREDEPLOY_ADDRESS;
const implementationGatewayAddress = await upgrades.erc1967.getImplementationAddress(proxyGateway);
await run('verify:verify', {
Expand Down
2 changes: 1 addition & 1 deletion contracts/tasks/taskDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ task('task:deployGateway')
});
await Gateway.waitForDeployment();
const GatewayContractAddress = await Gateway.getAddress();
const envConfig = dotenv.parse(fs.readFileSync('gateway/.env.gateway'));
const envConfig = dotenv.parse(fs.readFileSync('addresses/.env.gateway'));
if (GatewayContractAddress !== envConfig.GATEWAY_CONTRACT_PREDEPLOY_ADDRESS) {
throw new Error(
`The nonce of the deployer account is not null. Please use another deployer private key or relaunch a clean instance of the fhEVM`,
Expand Down
17 changes: 10 additions & 7 deletions contracts/tasks/taskGatewayRelayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ task('task:computeGatewayAddress')
from: deployerAddress,
nonce: 1, // deployer is supposed to have nonce 0 when deploying GatewayContract (0 nonce for implementation, +1 for UUPS)
});
const envFilePath = path.join(__dirname, '../gateway/.env.gateway');
const envFilePath = path.join(__dirname, '../addresses/.env.gateway');
const content = `GATEWAY_CONTRACT_PREDEPLOY_ADDRESS=${gatewayContractAddressPrecomputed}`;
try {
fs.writeFileSync(envFilePath, content, { flag: 'w' });
console.log('gatewayContractAddress written to gateway/.env.gateway successfully!');
console.log('gatewayContractAddress written to addresses/.env.gateway successfully!');
} catch (err) {
console.error('Failed to write to gateway/.env.gateway:', err);
console.error('Failed to write to addresses/.env.gateway:', err);
}

const solidityTemplate = `// SPDX-License-Identifier: BSD-3-Clause-Clear
Expand All @@ -40,10 +40,13 @@ address constant GATEWAY_CONTRACT_PREDEPLOY_ADDRESS = ${gatewayContractAddressPr
`;

try {
fs.writeFileSync('./gateway/lib/GatewayContractAddress.sol', solidityTemplate, { encoding: 'utf8', flag: 'w' });
console.log('gateway/lib/GatewayContractAddress.sol file has been generated successfully.');
fs.writeFileSync('./addresses/GatewayContractAddress.sol', solidityTemplate, {
encoding: 'utf8',
flag: 'w',
});
console.log('addresses/GatewayContractAddress.sol file has been generated successfully.');
} catch (error) {
console.error('Failed to write gateway/lib/GatewayContractAddress.sol', error);
console.error('Failed to write addresses/GatewayContractAddress.sol', error);
}
});

Expand Down Expand Up @@ -115,7 +118,7 @@ task('task:launchFhevm')
}
await hre.run('task:deployGateway', { privateKey: privKeyDeployer, ownerAddress: deployerAddress });

const parsedEnv = dotenv.parse(fs.readFileSync('gateway/.env.gateway'));
const parsedEnv = dotenv.parse(fs.readFileSync('addresses/.env.gateway'));
const gatewayContractAddress = parsedEnv.GATEWAY_CONTRACT_PREDEPLOY_ADDRESS;

await hre.run('task:addRelayer', {
Expand Down
2 changes: 1 addition & 1 deletion contracts/tasks/upgradeProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ task('task:upgradeGatewayContract')
types.boolean,
)
.setAction(async function (taskArguments: TaskArguments, { ethers, upgrades, run }) {
const parsedEnv = dotenv.parse(fs.readFileSync('gateway/.env.gateway'));
const parsedEnv = dotenv.parse(fs.readFileSync('addresses/.env.gateway'));
const proxyAddress = parsedEnv.GATEWAY_CONTRACT_PREDEPLOY_ADDRESS;
await upgradeCurrentToNew(
taskArguments.privateKey,
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/asyncDecrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const currentTime = (): string => {
return now.toLocaleTimeString('en-US', { hour12: true, hour: 'numeric', minute: 'numeric', second: 'numeric' });
};

const parsedEnv = dotenv.parse(fs.readFileSync('gateway/.env.gateway'));
const parsedEnv = dotenv.parse(fs.readFileSync('addresses/.env.gateway'));
let relayer: Wallet;
if (networkName === 'hardhat') {
const privKeyRelayer = process.env.PRIVATE_KEY_GATEWAY_RELAYER;
Expand Down

0 comments on commit f3adb16

Please sign in to comment.