token - AssertionError:错误消息必须包含revert
问题描述
当我运行测试时,我得到了这个错误..
我正在尝试使用 DAPPuniversity 教程制作自己的加密货币,但是,我的代码不断抛出异常。
Contract: ValleyToken
√ initialize the contract with correct values (363ms)
√ sets the initial supply upon deployment (363ms)
1) transfers token ownership
> No events were emitted
2 passing (869ms)
1 failing
1) Contract: ValleyToken
transfers token ownership:
ReferenceError: Faicoin is not defined
at Context.<anonymous> (test\ValleyToken.js:47:5)
at process._tickCallback (internal/process/next_tick.js:68:7)
解决方案
用您的测试替换此代码:)
it("transfers token ownership", function () {
return ValleyToken.deployed()
.then(function (instance) {
tokenInstance = instance;
return tokenInstance.transfer.call(accounts[1], 9999999999999999);
})
.then(assert.fail)
.catch(function (error) {
assert(error.message, "error message must contain revert");
return tokenInstance.transfer.call(accounts[1], 250000, {
from: accounts[0],
});
})
.then(function (success) {
assert(success, true, "it returns true");
return tokenInstance.transfer(accounts[1], 250000, {
from: accounts[0],
});
})
.then(function (receipt) {
assert.equal(receipt.logs.length, 1, "triggers one event");
assert.equal(
receipt.logs[0].event,
"Transfer",
'should be the "Transfer" event'
);
assert.equal(
receipt.logs[0].args._from,
accounts[0],
"logs the account the tokens are transferred from"
);
assert.equal(
receipt.logs[0].args._to,
accounts[1],
"logs the account the tokens are transferred to"
);
assert.equal(
receipt.logs[0].args._value,
250000,
"logs the transfer amount"
);
return tokenInstance.balanceOf(accounts[1]);
})
.then(function (reciept) {
return tokenInstance.balanceOf(accounts[1]);
})
.then(function (balance) {
assert.equal(
balance.toNumber(),
250000,
"adds the amount to the recieving amount"
);
return tokenInstance.balanceOf(accounts[0]);
})
.then(function (balance) {
assert.equal(
balance.toNumber(),
750000,
"deducts the amount from the sending account"
);
});
});
推荐阅读
- javascript - 编写 reactJS 网页标记的所有选项有哪些?
- python - Django,使用字典列表的响应
- react-native - 我正在尝试安装 axios 但发生了这样的错误
- javascript - odoo 11 不加载 javascript 代码
- reactjs - 从 material-ui 日期选择器中删除年份
- android - 在 kotlin 的另一个线程中运行 Room Insert 的推荐方法
- javascript - Socket.on 内的 socket.on
- websocket - 带有 JWT 身份验证的 NGINX 反向代理 WebSockets 没有 Access-Control-Allow-Origin 标头
- bbc-microbit - micro:bit 上的按钮 B 总是被按下
- laravel - Laravel validate unique with postgresql error array_map(): Argument #2 should be an array