首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >坚固性- HardHat -不能测试合同

坚固性- HardHat -不能测试合同
EN

Stack Overflow用户
提问于 2022-06-25 03:05:45
回答 1查看 181关注 0票数 -1

这是由于缺乏平衡而失败的考验。

代码语言:javascript
复制
const { expect } = require('chai');

describe("TestBirds", function () {
    it ("Should return correct name, URI, owner and beneficiary", async function () {

        const [owner, addr1] = await hre.ethers.getSigners()
               
        provider = ethers.provider

        const TestBirdsContract = await hre.ethers.getContractFactory("TestBirds")
        const testBirdsContractDeployed = await TestBirdsContract.deploy(
            "TestBirds",
            "XXXX",
            "https://test.url/",
            owner.address,
            owner.address)

        console.log(await provider.getBalance(owner.address));
        await testBirdsContractDeployed.deployed()
        await testBirdsContractDeployed.mintPublic(owner.address)

        expect(await testBirdsContractDeployed.name()).to.equal("TestBirds")
        expect(await testBirdsContractDeployed.tokenURI(0), "https://test.url/0")
        expect(await testBirdsContractDeployed.ownerOf(0)).to.equal(owner.address)
    })
})

在控制台日志中,余额看起来是正常的,但是在铸币时测试失败。

代码语言:javascript
复制
TestBirds

BigNumber { value: "10000000000000000000000" }
    1) Should return correct name, URI, owner and beneficiary

  0 passing (788ms)
  1 failing

  1) TestBirds
       Should return correct name, URI, owner and beneficiary:
     Error: VM Exception while processing transaction: reverted with reason string 'Seller: Costs 2500000000 GWei'
      at TestBirds.onlyOwner (@openzeppelin/contracts/access/Ownable.sol:43)
      at TestBirds._purchase (@divergencetech/ethier/contracts/sales/Seller.sol:229)
      at TestBirds._purchase (@divergencetech/ethier/contracts/sales/Seller.sol:216)
      at TestBirds.mintPublic (contracts/TestBirds.sol:85)
      at HardhatNode._mineBlockWithPendingTxs (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:1650:23)
      at HardhatNode.mineBlock (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:459:16)
      at EthModule._sendTransactionAndReturnHash (node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:1496:18)
      at HardhatNetworkProvider.request (node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:117:18)
      at EthersProviderWrapper.send (node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)

我的余额超过2500000000 GWei,所以我不确定哪个是问题所在。

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-06-26 18:47:30

您目前没有支付您的薄荷糖。您需要积极发送造币费沿合同电话交易。

代码语言:javascript
复制
await testBirdsContractDeployed.mintPublic(owner.address, {
      value: ethers.utils.parseEther("2.5"),
});
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72750985

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档