【问题标题】:TypeError: assert.equal is not a function类型错误:assert.equal 不是函数
【发布时间】:2022-11-12 00:45:41
【问题描述】:

我创建了solidity合约并成功用松露编译它但是当我对我的合约的测试文件运行松露测试时它给出了错误

类型错误:assert.equal 不是函数

我的代码

const { assert } = require('console');

const Tether = artifacts.require('Tether.sol');
const RWD = artifacts.require('RWD');
const DecentralBank = artifacts.require('DecentralBank');

require('chai')
.use(require('chai-as-promised'))
.should()

contract('DecentralBank', ([owner, customer]) => {
    let tether, rwd, decentralBank;

    function  tokens(number) {
        return web3.utils.toWei(number, 'ether')
    }

    before(async () => {
        tether = await Tether.new()
        rwd = await RWD.new()
        decentralBank = await DecentralBank.new(rwd.address, tether.address)

       await rwd.transfer(decentralBank.address, tokens('1000000'));

       await tether.transfer(customer, tokens('100'),{from: owner});
    })

    describe('Tether', async () =>{
        it('matches name successfully', async () => {
            const name = await tether.name()
            console.log(name)
            assert.equal(name, 'Tether')
        })
    })

})

【问题讨论】:

    标签: reactjs solidity web3js truffle


    【解决方案1】:

    你使用了错误的assert。你不需要这个

    const { assert } = require('console');
    

    您可能在输入assert 时错误地自动导入。 Truffle 使用 mocha,assert 全球可用。

    【讨论】:

      猜你喜欢
      • 2016-02-26
      • 2013-04-01
      • 2016-03-06
      • 1970-01-01
      • 2018-04-28
      • 2019-02-14
      • 2021-10-02
      • 2021-10-30
      相关资源
      最近更新 更多