diff --git a/scripts/util/utils.js b/scripts/util/utils.js index 1d6cfc826..3cf7b0fb1 100644 --- a/scripts/util/utils.js +++ b/scripts/util/utils.js @@ -50,6 +50,7 @@ function readContracts(chainId, network, env) { async function getFees(maxPriorityFeePerGas) { const { baseFeePerGas } = await provider.getBlock(); + // Set maxFeePerGas so it's likely to be accepted by the network // maxFeePerGas = maxPriorityFeePerGas + 2 * lastBaseFeePerGas return { maxPriorityFeePerGas, maxFeePerGas: maxPriorityFeePerGas + BigInt(baseFeePerGas) * 2n }; diff --git a/test/protocol/ProtocolInitializationHandlerTest.js b/test/protocol/ProtocolInitializationHandlerTest.js index 0629abe55..726c923b6 100644 --- a/test/protocol/ProtocolInitializationHandlerTest.js +++ b/test/protocol/ProtocolInitializationHandlerTest.js @@ -1,4 +1,3 @@ -const { expect } = require("chai"); const hre = require("hardhat"); const { deployMockTokens } = require("../../scripts/util/deploy-mock-tokens"); const { @@ -20,6 +19,7 @@ const { deployProtocolDiamond } = require("../../scripts/util/deploy-protocol-di const { deployAndCutFacets, deployProtocolFacets } = require("../../scripts/util/deploy-protocol-handler-facets"); const { getInterfaceIds, interfaceImplementers } = require("../../scripts/config/supported-interfaces"); const { maxPriorityFeePerGas, oneWeek } = require("../util/constants"); + const { getFees } = require("../../scripts/util/utils"); const { getFacetAddCut, getFacetReplaceCut } = require("../../scripts/util/diamond-utils"); const { RevertReasons } = require("../../scripts/config/revert-reasons.js"); @@ -97,9 +97,7 @@ describe("ProtocolInitializationHandler", async function () { beforeEach(async function () { const ProtocolInitilizationContractFactory = await getContractFactory("ProtocolInitializationHandlerFacet"); - protocolInitializationFacetDeployed = await ProtocolInitilizationContractFactory.deploy( - await getFees(maxPriorityFeePerGas) - ); + protocolInitializationFacetDeployed = await ProtocolInitilizationContractFactory.deploy(); await protocolInitializationFacetDeployed.waitForDeployment(); }); @@ -451,8 +449,7 @@ describe("ProtocolInitializationHandler", async function () { maxPriorityFeePerGas, version, mockInitializationFacetDeployed, - [], - maxPriorityFeePerGas + [] ); // Deploy v2.2.0 facets @@ -736,7 +733,7 @@ describe("ProtocolInitializationHandler", async function () { await deployProtocolFacets( ["ProtocolInitializationHandlerFacet", "ConfigHandlerFacet", "SellerHandlerFacet"], {}, - await getFees(maxPriorityFeePerGas) + maxPriorityFeePerGas ); snapshotId = await getSnapshot(); @@ -775,8 +772,7 @@ describe("ProtocolInitializationHandler", async function () { diamondCutFacet.diamondCut( [facetCut], deployedProtocolInitializationHandlerFacetAddress, - calldataProtocolInitialization, - await getFees(maxPriorityFeePerGas) + calldataProtocolInitialization ) ) .to.emit(configHandler, "MinResolutionPeriodChanged") @@ -788,8 +784,7 @@ describe("ProtocolInitializationHandler", async function () { await diamondCutFacet.diamondCut( [facetCut], deployedProtocolInitializationHandlerFacetAddress, - calldataProtocolInitialization, - await getFees(maxPriorityFeePerGas) + calldataProtocolInitialization ); // Verify that new value is stored @@ -811,8 +806,7 @@ describe("ProtocolInitializationHandler", async function () { diamondCutFacet.diamondCut( [facetCut], deployedProtocolInitializationHandlerFacetAddress, - calldataProtocolInitialization, - await getFees(maxPriorityFeePerGas) + calldataProtocolInitialization ) ).to.be.revertedWith(RevertReasons.TWINS_ALREADY_EXIST); }); @@ -832,8 +826,7 @@ describe("ProtocolInitializationHandler", async function () { diamondCutFacet.diamondCut( [facetCut], deployedProtocolInitializationHandlerFacetAddress, - calldataProtocolInitialization, - await getFees(maxPriorityFeePerGas) + calldataProtocolInitialization ) ).to.be.revertedWith(RevertReasons.VALUE_ZERO_NOT_ALLOWED); }); @@ -852,8 +845,7 @@ describe("ProtocolInitializationHandler", async function () { diamondCutFacet.diamondCut( [facetCut], deployedProtocolInitializationHandlerFacetAddress, - calldataProtocolInitialization, - await getFees(maxPriorityFeePerGas) + calldataProtocolInitialization ) ).to.be.revertedWith(RevertReasons.ARRAY_LENGTH_MISMATCH); }); @@ -874,8 +866,7 @@ describe("ProtocolInitializationHandler", async function () { diamondCutFacet.diamondCut( [facetCut], deployedProtocolInitializationHandlerFacetAddress, - calldataProtocolInitialization, - await getFees(maxPriorityFeePerGas) + calldataProtocolInitialization ) ).to.be.revertedWith(RevertReasons.NO_SUCH_SELLER); }); @@ -896,8 +887,7 @@ describe("ProtocolInitializationHandler", async function () { diamondCutFacet.diamondCut( [facetCut], deployedProtocolInitializationHandlerFacetAddress, - calldataProtocolInitialization, - await getFees(maxPriorityFeePerGas) + calldataProtocolInitialization ) ).to.be.revertedWith(RevertReasons.INVALID_ADDRESS); }); @@ -920,8 +910,7 @@ describe("ProtocolInitializationHandler", async function () { await diamondCutFacet.diamondCut( [facetCut], await deployedProtocolInitializationHandlerFacet.getAddress(), - calldataProtocolInitialization, - await getFees(maxPriorityFeePerGas) + calldataProtocolInitialization ); // Prepare 2.3.0 deployment @@ -944,8 +933,7 @@ describe("ProtocolInitializationHandler", async function () { diamondCutFacet.diamondCut( [facetCut], await deployedProtocolInitializationHandlerFacet.getAddress(), - calldataProtocolInitialization, - await getFees(maxPriorityFeePerGas) + calldataProtocolInitialization ) ).to.be.revertedWith(RevertReasons.WRONG_CURRENT_VERSION); });