I want to test whether my smart contract functions return the correct error messages
example function in solidity
function transform (uint256 input) public returns (uint256){
require (input>1, "the value has to be greater than 1"
}
However, when i try to test whether a value of 0 triggers the correct error message, my test fails.
expect(await contract.connect(addr1).transform(0)).to.throw("values smaller than 1 are not allowed");
The error I am receiving:
1 passing (828ms)
1 failing
1) Minting of Tokens
transform should throw the correct errors:
Error: VM Exception while processing transaction: reverted with reason string 'values smaller than 1 are not allowed'
at ProjectL.mintLottoSchein (contracts/tests.sol:104)
at EdrProviderWrapper.request (node_modules\hardhat\src\internal\hardhat-network\provider\provider.ts:446:41)
at HardhatEthersSigner.sendTransaction (node_modules\@nomicfoundation\hardhat-ethers\src\signers.ts:125:18)
at send (node_modules\ethers\src.ts\contract\contract.ts:313:20)
at Proxy.mintLottoSchein (node_modules\ethers\src.ts\contract\contract.ts:352:16)
at Context.<anonymous> (test\test.js:42:14)
Could someone please help me out?
thx