diff --git a/contracts/protocol/bases/PriceDiscoveryBase.sol b/contracts/protocol/bases/PriceDiscoveryBase.sol index 9c0556079..07fb88e64 100644 --- a/contracts/protocol/bases/PriceDiscoveryBase.sol +++ b/contracts/protocol/bases/PriceDiscoveryBase.sol @@ -31,6 +31,7 @@ contract PriceDiscoveryBase is ProtocolBase { */ //solhint-disable-next-line constructor(address _wNative) { + if (_wNative == address(0)) revert InvalidAddress(); wNative = IWrappedNative(_wNative); } diff --git a/test/protocol/PriceDiscoveryHandlerFacet.js b/test/protocol/PriceDiscoveryHandlerFacet.js index 3f8c6b348..6837f23e3 100644 --- a/test/protocol/PriceDiscoveryHandlerFacet.js +++ b/test/protocol/PriceDiscoveryHandlerFacet.js @@ -152,6 +152,17 @@ describe("IPriceDiscoveryHandlerFacet", function () { }); }); + context("📋 Constructor", async function () { + it("Deployment fails if wrapped native address is 0", async function () { + const priceDiscoveryFactory = await getContractFactory("PriceDiscoveryHandlerFacet"); + + await expect(priceDiscoveryFactory.deploy(ZeroAddress)).to.revertedWithCustomError( + bosonErrors, + RevertReasons.INVALID_ADDRESS + ); + }); + }); + // All supported Price discovery methods context("📋 Price discovery Methods", async function () { beforeEach(async function () { diff --git a/test/protocol/SequentialCommitHandlerTest.js b/test/protocol/SequentialCommitHandlerTest.js index 8a670c8b1..edc879998 100644 --- a/test/protocol/SequentialCommitHandlerTest.js +++ b/test/protocol/SequentialCommitHandlerTest.js @@ -151,6 +151,17 @@ describe("IBosonSequentialCommitHandler", function () { }); }); + context("📋 Constructor", async function () { + it("Deployment fails if wrapped native address is 0", async function () { + const sequentialCommitFactory = await getContractFactory("SequentialCommitHandlerFacet"); + + await expect(sequentialCommitFactory.deploy(ZeroAddress)).to.revertedWithCustomError( + bosonErrors, + RevertReasons.INVALID_ADDRESS + ); + }); + }); + // All supported Sequential commit methods context("📋 Sequential Commit Methods", async function () { beforeEach(async function () { diff --git a/test/util/utils.js b/test/util/utils.js index b508a9125..7214cf997 100644 --- a/test/util/utils.js +++ b/test/util/utils.js @@ -494,9 +494,10 @@ async function setupTestEnvironment(contracts, { bosonTokenAddress, forwarderAdd ]; const facetsToDeploy = await getFacetsWithArgs(facetNames, protocolConfig); - facetsToDeploy["SequentialCommitHandlerFacet"].constructorArgs[0] = wethAddress || ZeroAddress; // update only weth address - facetsToDeploy["PriceDiscoveryHandlerFacet"].constructorArgs[0] = wethAddress || ZeroAddress; // update only weth address - + if (wethAddress) { + facetsToDeploy["SequentialCommitHandlerFacet"].constructorArgs[0] = wethAddress; // update only weth address + facetsToDeploy["PriceDiscoveryHandlerFacet"].constructorArgs[0] = wethAddress; // update only weth address + } // Cut the protocol handler facets into the Diamond await deployAndCutFacets(await protocolDiamond.getAddress(), facetsToDeploy, maxPriorityFeePerGas);