长话短说,我的合同是不通过部署测试使用松露,摩卡和chai。
我在松露控制台中单独运行代码,它返回的地址很好,但它无法通过我编写的测试。我肯定我把摩卡测试写得很好,但我搞不懂。
附带注意:从松露控制台运行truffle test会导致node.js抛出一个错误。但是,从CLI运行truffle test很好,只返回0 passing。
这是代码
const { expect } = require('chai')
.use(require('chai-as-promised'))
.should()
const Auction = artificats.require('./implementor.sol');
contract('Go',(accounts) => {
let contract
describe('deployment',async() =>{
it('deploys successfully',async ()=>{
contract = await Go.deployed()
const address = contract.address
console.log(address)
console.log('ran')
assert.NotEqual(address,'')
})
} )
})所以我试着这么做,因为我想也许合同根本就没有被创造出来。
const { expect } = require('chai')
.use(require('chai-as-promised'))
.should()
const Auction = artificats.require('./implementor.sol');
contract('Go',(accounts) => {
beforeEach(async () => {
this.Go = await Go.new()
});
describe('deployment',async() =>{
let contract
it('deploys successfully',async ()=>{
contract = await Go.deployed();
const address = contract.address;
assert.NotEqual(address,'');
return(address);
});
} );
});发布于 2021-01-02 04:37:39
我认为至少有几个问题需要解决:
artificats替换为artifactsAuction而不是Go。总结如下:
const Auction = artifacts.require('./implementor.sol');
contract('Go',(accounts) => {
let Go;
beforeEach(async () => {
Go = await Auction.new()
});
//...
}发布于 2021-01-02 15:10:22
所以,sergi Juanati是正确的,我的拼写是超错误的。然而,这并不是我没有得到任何回报的原因--甚至连一个错误都没有。原因是因为某种原因
truffle test不是在做实际的测试。无论我在哪个目录中,它都没有运行测试,所以我必须自己指定它。我感谢大家的帮助!
https://ethereum.stackexchange.com/questions/91777
复制相似问题