Error: too many arguments: passed to contract (count=2, expectedCount=1, code=UNEXPECTED_ARGUMENT, version=contracts/5.7.0) #3004
-
Hello guys, I'm getting the error: Error: too many arguments: passed to contract (count=2, expectedCount=1, code=UNEXPECTED_ARGUMENT, version=contracts/5.7.0) Here is my test code: const { assert, expect } = require("chai")
const { deployments, ethers, getNamedAccounts } = require("hardhat")
describe("FundMe", async function () {
let fundMe
let deployer
let mockV3Aggregator
const sendValue = ethers.utils.parseEther("1")
beforeEach(async function () {
deployer = (await getNamedAccounts()).deployer
await deployments.fixture(["all"])
fundMe = await ethers.getContract("FundMe", deployer)
mockV3Aggregator = await ethers.getContract(
"MockV3Aggregator",
deployer
)
})
describe("constructor", async function () {
it("sets the aggregator addresses correctly", async function () {
const response = await fundMe.priceFeed()
assert.equal(response, mockV3Aggregator.address)
})
})
describe("fund", async function () {
it("fails if you dont send enough ETH", async function () {
await expect(fundMe.fund()).to.be.revertedWith(
"you need to spend more ETH"
)
})
it("updates the amount funded data structure", async function () {
await fundMe.fund({ value: sendValue })
const response = await fundMe.addressToAmountFunded(deployer)
assert.equal(response.toString(), sendValue.toString())
})
it("Adds funder to array fo funders", async function () {
await fundMe.fund({ value: sendValue })
const funder = await fundMe.funders(0)
assert.equal(funder, deployer)
})
})
describe("withdraw", async function () {
beforeEach(async function () {
await fundMe.fund({ value: sendValue })
})
it("Withdraw ETH from a single funder", async function () {
// Arrange
const startingFundMeBalance = await fundMe.provider.getBalance(
fundMe.address
)
const startingDeployerBalance = await fundMe.provider.getBalance(
deployer
)
// Act
const transactionresponse = await fundMe.withdraw()
const transactionReceipt = await transactionresponse.wait(1)
const { gasUsed, effectiveGasPrice } = transactionReceipt
const gasCost = gasUsed.mul(effectiveGasPrice)
const endingFundMeBalance = await fundMe.provider.getBalance(
fundMe.address
)
const endingDeployerBalance = await fundMe.provider.getBalance(
deployer
)
// Assert
assert.equal(endingFundMeBalance, 0)
assert.equal(
startingFundMeBalance.add(startingDeployerBalance),
endingDeployerBalance.add(gasCost).toString()
)
})
it("Alows us to withdraw with multiple funders", async function () {
// Arrange
const accounts = await ethers.getSigners()
for (let i = 0; i < 6; i++) {
const fundMeConnectedContract = await fundMe.connect(
accounts[i]
)
await fundMeConnectedContract.fund({ value: sendValue })
}
const startingFundMeBalance = await fundMe.provider.getBalance(
fundMe.address
)
const startingDeployerBalance = await fundMe.provider.getBalance(
deployer
)
// Act
const transactionResponse = await fundMe.withdraw()
const transactionReceipt = await transactionResponse.wait(1)
const { gasUsed, effectiveGasPrice } = transactionReceipt
const gasCost = gasUsed.mul(effectiveGasPrice)
const endingFundMeBalance = await fundMe.provider.getBalance(
fundMe.address
)
const endingDeployerBalance = await fundMe.provider.getBalance(
deployer
)
// Assert
assert.equal(endingFundMeBalance, 0)
assert.equal(
startingFundMeBalance.add(startingDeployerBalance).toString(),
endingDeployerBalance.add(gasCost).toString()
)
// Make sure the funders array is reset properly by
await expect(fundMe.funders(0)).to.be.reverted
for (let i = 1; i < 6; i++) {
assert.equal(
await fundMe.addressToAmountFunded(accounts[i].address, 0)
)
}
})
})
}) I dont know how there are too many arguments. Please help |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
@blaynejosh |
Beta Was this translation helpful? Give feedback.
-
@blaynejosh : send me your contracts files and deploy script! |
Beta Was this translation helpful? Give feedback.
@blaynejosh : send me your contracts files and deploy script!