Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
toni-calvin committed Mar 1, 2024
1 parent 4bd5908 commit 9aa18ef
Showing 1 changed file with 40 additions and 39 deletions.
79 changes: 40 additions & 39 deletions l1-contracts/test/unit_tests/mailbox_test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import * as ethers from "ethers";

describe("Mailbox tests", function () {
let mailbox: MailboxFacet;
let proxyGetters: GettersFacet;
let proxyAsMockExecutor: MockExecutorFacet;
let diamondProxyContract: ethers.Contract;
let owner: ethers.Signer;
Expand Down Expand Up @@ -91,7 +90,6 @@ describe("Mailbox tests", function () {
const forwarderFactory = await hardhat.ethers.getContractFactory("Forwarder");
const forwarderContract = await forwarderFactory.deploy();
forwarder = ForwarderFactory.connect(forwarderContract.address, forwarderContract.signer);

});

it("Should accept correctly formatted bytecode", async () => {
Expand Down Expand Up @@ -217,6 +215,8 @@ describe("Mailbox tests", function () {

describe("L2 gas price", async () => {
let testContract: MailboxFacetTest;
let proxyGetters: GettersFacet;
let diamondProxyContract: ethers.Contract;
const TEST_GAS_PRICES = [];

async function testOnAllGasPrices(
Expand All @@ -237,47 +237,48 @@ describe("Mailbox tests", function () {
const gettersFacet = GettersFacetFactory.connect(gettersContract.address, gettersContract.signer);

// Note, that while this testsuit is focused on testing MailboxFaucet only,
// we still need to initialize its storage via DiamondProxy
const diamondInitFactory = await hardhat.ethers.getContractFactory("DiamondInit");
const diamondInitContract = await diamondInitFactory.deploy();
const diamondInit = DiamondInitFactory.connect(diamondInitContract.address, diamondInitContract.signer);

const dummyHash = new Uint8Array(32);
dummyHash.set([1, 0, 0, 1]);
const dummyAddress = ethers.utils.hexlify(ethers.utils.randomBytes(20));
const diamondInitData = diamondInit.interface.encodeFunctionData("initialize", [
{
verifier: dummyAddress,
governor: dummyAddress,
admin: dummyAddress,
genesisBatchHash: ethers.constants.HashZero,
genesisIndexRepeatedStorageChanges: 0,
genesisBatchCommitment: ethers.constants.HashZero,
verifierParams: {
recursionCircuitsSetVksHash: ethers.constants.HashZero,
recursionLeafLevelVkHash: ethers.constants.HashZero,
recursionNodeLevelVkHash: ethers.constants.HashZero,
// we still need to initialize its storage via DiamondProxy
const diamondInitFactory = await hardhat.ethers.getContractFactory("DiamondInit");
const diamondInitContract = await diamondInitFactory.deploy();
const diamondInit = DiamondInitFactory.connect(diamondInitContract.address, diamondInitContract.signer);

const dummyHash = new Uint8Array(32);
dummyHash.set([1, 0, 0, 1]);
const dummyAddress = ethers.utils.hexlify(ethers.utils.randomBytes(20));
const diamondInitData = diamondInit.interface.encodeFunctionData("initialize", [
{
verifier: dummyAddress,
governor: dummyAddress,
admin: dummyAddress,
genesisBatchHash: ethers.constants.HashZero,
genesisIndexRepeatedStorageChanges: 0,
genesisBatchCommitment: ethers.constants.HashZero,
verifierParams: {
recursionCircuitsSetVksHash: ethers.constants.HashZero,
recursionLeafLevelVkHash: ethers.constants.HashZero,
recursionNodeLevelVkHash: ethers.constants.HashZero,
},
zkPorterIsAvailable: false,
l2BootloaderBytecodeHash: dummyHash,
l2DefaultAccountBytecodeHash: dummyHash,
priorityTxMaxGasLimit: 10000000,
initialProtocolVersion: 0,
feeParams: defaultFeeParams(),
},
zkPorterIsAvailable: false,
l2BootloaderBytecodeHash: dummyHash,
l2DefaultAccountBytecodeHash: dummyHash,
priorityTxMaxGasLimit: 10000000,
initialProtocolVersion: 0,
feeParams: defaultFeeParams(),
},
]);
]);

const facetCuts = [
facetCut(gettersFacet.address, gettersFacet.interface, Action.Add, false),
facetCut(testContract.address, testContract.interface, Action.Add, false),
];
const diamondCutData = diamondCut(facetCuts, diamondInit.address, diamondInitData);
const facetCuts = [
facetCut(gettersFacet.address, gettersFacet.interface, Action.Add, false),
facetCut(testContract.address, testContract.interface, Action.Add, false),
];
const diamondCutData = diamondCut(facetCuts, diamondInit.address, diamondInitData);

const diamondProxyFactory = await hardhat.ethers.getContractFactory("DiamondProxy");
const chainId = hardhat.network.config.chainId;
diamondProxyContract = await diamondProxyFactory.deploy(chainId, diamondCutData);
const diamondProxyFactory = await hardhat.ethers.getContractFactory("DiamondProxy");
const chainId = hardhat.network.config.chainId;
diamondProxyContract = await diamondProxyFactory.deploy(chainId, diamondCutData);

proxyGetters = GettersFacetFactory.connect(diamondProxyContract.address, gettersContract.signer);
proxyGetters = GettersFacetFactory.connect(diamondProxyContract.address, gettersContract.signer);
testContract = MailboxFacetTestFactory.connect(diamondProxyContract.address, mailboxTestContract.signer);

// Generating 10 more gas prices for test suit
let priceGwei = 0.001;
Expand Down

0 comments on commit 9aa18ef

Please sign in to comment.