[英]Smart Contract test with nodejs fails with an error message
我正在尝试测试智能合约并想做以下测试。
it('Transfer tokens from owner should fail if owner has a low balance.', async () => {
expect(await ptrTokenContract.transfer(receiverAddress1.address, 10000000)).to.be.revertedWith('Insufficient balance.Transfer failed !')
console.log(await ptrTokenContract.balanceOf(receiverAddress1.address))
})
我转移的价值实际上大于所有者的余额。 但不是通过测试失败并出现以下错误。
Error: VM Exception while processing transaction: reverted with reason string 'Insufficient balance.Transfer failed !'
at Token.transfer (contracts/Token.sol:59)
我在这里做错了什么?
您必须更改等待的 position,将其放在预期之外。
it('Transfer tokens from owner should fail if owner has a low balance.', async () => {
await expect(ptrTokenContract.transfer(receiverAddress1.address, 10000000)).to.be.revertedWith('Insufficient balance.Transfer failed !')
console.log(await ptrTokenContract.balanceOf(receiverAddress1.address))
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.