Skip to content

Commit

Permalink
Fix contract tests
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavBreadless committed Jun 1, 2021
1 parent 48dd8dd commit 5135c5b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 39 deletions.
2 changes: 1 addition & 1 deletion contracts/src.ts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export class Deployer {
const regenesisMultisigContract = await deployContract(
this.deployWallet,
this.contracts.regenesisMultisig,
[process.env.MISC_REGENESIS_GNOSIS_ADDRESS],
[process.env.MISC_REGENESIS_THRESHOLD],
{
gasLimit: 6000000,
...ethTxOptions
Expand Down
84 changes: 49 additions & 35 deletions contracts/test/unit_tests/regenesis_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ describe('Regenesis test', function () {
const walletPrivateKey = '0x6878e5113d9fae7eec373bd9f7975e692c1c4ace22b536c63aa2c818ef92ef00';
const wallet = new ethers.Wallet(walletPrivateKey).connect(hardhat.ethers.provider);

// These are the private keys of the default security council members
const securityCouncil: ethers.Wallet[] = [
new ethers.Wallet('0xa5a9359481bd7926b11f66ba584415fb7c2a254429bb6465f09a0af6afc4e7ad').connect(
hardhat.ethers.provider
),
new ethers.Wallet('0xa1fd94d61050530de6bc46253d90012e3ae30c53fec0870d004d7b937a89c645').connect(
hardhat.ethers.provider
),
new ethers.Wallet('0x125f11e79ce6ac43caa6f6845b6d1bf8ef0494007fa72f6295f315ed91cb2a1f').connect(
hardhat.ethers.provider
)
];

it('Test that regenesis upgrade works', async () => {
// Fund the deployer wallet
const hardhatWallets = await hardhat.ethers.getSigners();
Expand All @@ -25,6 +38,14 @@ describe('Regenesis test', function () {
});
await supplyMultisigCreatorTx.wait();

for (let councilMember of securityCouncil) {
const supplyCouncilMemberTx = await hardhatWallet.sendTransaction({
to: councilMember.address,
value: utils.parseEther('10')
});
await supplyCouncilMemberTx.wait();
}

// Deploying the contracts
const contracts = readProductionContracts();
contracts.zkSync = readContractCode('dev-contracts/ZkSyncRegenesisTest');
Expand Down Expand Up @@ -65,6 +86,34 @@ describe('Regenesis test', function () {
const submitSignaturesTx = await regenesisMultisigContract.submitHash(oldRootHash, newRootHash);
await submitSignaturesTx.wait();

expect(await regenesisMultisigContract.candidateNewRootHash()).to.eq(
newRootHash,
'Candidate new root hash was not set correctly'
);
expect(await regenesisMultisigContract.candidateOldRootHash()).to.eq(
oldRootHash,
'Candidate old root hash was not set correctly'
);
expect(await regenesisMultisigContract.oldRootHash()).to.eq(
ethers.constants.HashZero,
'New temporary root hash was not set correctly'
);
expect(await regenesisMultisigContract.newRootHash()).to.eq(
ethers.constants.HashZero,
'Old temporary root hash was not set correctly'
);

for (let i = 0; i < +process.env.MISC_REGENESIS_THRESHOLD; i++) {
const councilMember = securityCouncil[i];

const regenesisMultisigContract = RegenesisMultisigFactory.connect(
deployer.addresses.RegenesisMultisig,
councilMember
);

await (await regenesisMultisigContract.approveHash()).wait();
}

// After the new root hash has been submitted to the multisig,
// we need to finish regenesis
const genesisBlock = {
Expand Down Expand Up @@ -102,39 +151,4 @@ describe('Regenesis test', function () {
'The additional zkSync address has been changed wrongly'
);
});

it('Test data submission', async () => {
const [hardhatWallet]: ethers.Wallet[] = await hardhat.ethers.getSigners();
const fundingWalletTx = await hardhatWallet.sendTransaction({
to: wallet.address,
value: utils.parseEther('3.0')
});
await fundingWalletTx.wait();

const contracts = readProductionContracts();
const deployer = new Deployer({ deployWallet: wallet, contracts });
await deployer.deployRegenesisMultisig({ gasLimit: 6500000 });
await deployer.deployAll({ gasLimit: 6500000 });

const regenesisMultisigContract = RegenesisMultisigFactory.connect(
deployer.addresses.RegenesisMultisig,
wallet
);

const tx = await wallet.sendTransaction({
to: regenesisMultisigContract.address,
// The calldata was retrieved from the regen-root-hash tool
data: '0x905717402f59c906954c0445843de5e33ceb41d60b5ed5d3d78f0575bc345bd3514ea0910c0c243023dce4bb411344d572dcc24bd77d393ef5a02ef4f5ffd12649634d5e'
});
await tx.wait();

expect(await regenesisMultisigContract.oldRootHash()).to.eq(
'0x2f59c906954c0445843de5e33ceb41d60b5ed5d3d78f0575bc345bd3514ea091',
'The old root hash was not set correctly'
);
expect(await regenesisMultisigContract.newRootHash()).to.eq(
'0x0c0c243023dce4bb411344d572dcc24bd77d393ef5a02ef4f5ffd12649634d5e',
'The new root hash was not set correctly'
);
});
});
6 changes: 3 additions & 3 deletions etc/env/base/misc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ sentry_url="unset"
# The address of the regenesis multisig smart contract
regenesis_multisig_address="0xAA7113B9de498556dC76eDFEFc57681083c861C1"

# The address of the regenesis gnosis smart contract
regenesis_gnosis_address="0xbD5Ca6f189111A1befd4ffAa6F17f62D4535F254"
# The number of parter signatures we need to get for the regenesis
regenesis_threshold=2

# The address of the new additional zkSync
new_additional_zksync_address="0x7fbaD9d9C9a1204F45FA38CcbF732B0930F8B582"
Expand All @@ -54,7 +54,7 @@ listing_governance="0xaFe6A91979021206ad79F58562Eef4204720E2A3"

# Security council parameters
security_council_members_number=3
security_council_members=["0xaFe6A91979021206ad79F58562Eef4204720E2A3","0xbD5Ca6f189111A1befd4ffAa6F17f62D4535F254","0xAA7113B9de498556dC76eDFEFc57681083c861C1"]
security_council_members=["0x22C3F9177F485bF9a058cE4C7253Da81a59495Db","0x56dF84566a67e87808A73dA0Be61a40bda3e2AFA","0xCE004d039cD86b08274FC453bd5536E6e9F6Fac7"]

security_council_2_weeks_threshold=1
security_council_1_week_threshold=2
Expand Down

0 comments on commit 5135c5b

Please sign in to comment.