【问题标题】:Simple problem with testing contracts with Truffle用 Truffle 测试合约的简单问题
【发布时间】:2019-08-30 08:05:26
【问题描述】:

当我在终端中放入“truffle test”时,我有一个 Marketplace.test.js 文件,它甚至在测试文件中的 const 之前给出了语法错误。

我用谷歌搜索并寻找答案,但无济于事。我觉得这应该很容易解决,但还没有结果。在使用区块链时仍然是一个菜鸟,这非常令人沮丧。任何帮助将不胜感激。谢谢。

const Marketplace = artifacts.require('./Marketplace.sol')

contract('Marketplace', (accounts) => {
    let marketplace

    before(async () => {
        marketplace = await Marketplace.deployed()
    })

    describe('deployment', async () => {
        it('deploys successfully', async () => {
            const address = await marketplace.address
            assert.notEqual(address, 0x0)
            assert.notEqual(address, '')
            assert.notEqual(address, null)
            assert.notEqual(address, undefined)
        })
    })
})

语法错误:C:/ETHDev/marketplace/test/Marketplace.test.js: 意外字符 '�' (1:0)

1 | ��c o n s t M a r k e t p l a c e = a r t i f a c t s 。 r e q u i r e ( ' . / M a r k e t p l a c e . s o l ' ) ;

【问题讨论】:

  • 这看起来像是文件编码问题。确保使用带有标准 UTF-8 编码的纯文本编辑器。在优秀的编辑器中,您还可以激活一项功能以查看任何空白字符,您可能还想检查一下。

标签: javascript ethereum truffle


【解决方案1】:

这个错误可能是因为您使用的编辑器,请尝试切换到任何其他编辑器。

如果您使用的是记事本++,请更改此设置。 "Encoding" -> "Convert to UTF-8 without BOM"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    • 2022-01-21
    相关资源
    最近更新 更多