坚固 - 硬汉 - 无法测试合同
这是由于缺乏平衡而失败的测试
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)
})
})
,在控制台日志上余额看起来还不错,但是测试失败了
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,因此我不确定哪个问题是问题所在。
谢谢
This is the test that it is failing due to the lack of balance
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)
})
})
The balance looks ok on the console log, but test fails on minting
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)
I have more than 2500000000 GWei on my balance, so I am not sure which is the problem.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您目前没有为薄荷付费。
您需要在合同电话交易中积极发送铸造费。
You are currently not paying for your mint.
You need to actively send the minting fee along the contract call transaction.