Search⌘ K
AI Features

Requiring Valid Arguments

Explore how to enforce valid argument checks in Solidity smart contracts. This lesson guides you through implementing functions that verify input values, ensuring all split ratios are greater than zero and calculating their total for secure fund management.

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:

Node.js
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"
);
});

Update the

...