当我运行测试时,我得到这个错误..
我正在尝试使用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)发布于 2020-05-31 12:26:44
将此代码替换为您的测试:)
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"
);
});
});https://stackoverflow.com/questions/62111564
复制相似问题