这是由于缺乏平衡而失败的考验。
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,所以我不确定哪个是问题所在。
谢谢
发布于 2022-06-26 18:47:30
您目前没有支付您的薄荷糖。您需要积极发送造币费沿合同电话交易。
await testBirdsContractDeployed.mintPublic(owner.address, {
value: ethers.utils.parseEther("2.5"),
});https://stackoverflow.com/questions/72750985
复制相似问题