Requiring Valid Arguments

Learn how to incorporate test cases required for a valid contract.

We'll cover the following...

Update the test case

We’ve incorporated the split ratios into the contract. Now, we also need to ensure that there are no split ratios that are less than or equal to zero. We should iterate through every split ratio to see if they’re all greater than one. The test for this functionality looks like this:

Press + to interact
it("can NOT be deployed when any of the split ratios is less than one", async () => {
const Contract =
await hre.ethers.getContractFactory(
"Partnership"
);
const [owner, person1] =
await hre.ethers.getSigners();
const addresses = [
owner.address,
person1.address,
];
const splitRatios = [1, 0];
await expect(
Contract.deploy(addresses, splitRatios)
).to.be.revertedWith(
"Split ratio can not be 0 or less"
);
});
...