Lesson 9: invalid signer or provider #5424
-
hello everyone, const { assert, expect } = require("chai")
const { developmentChains, networkConfig } = require("../../helper-hardhat-config")
const { getNamedAccounts, deployments, ethers, network } = require("hardhat")
!developmentChains.includes(network.name)
? describe.skip
: describe("Lottery", async function () {
let lottery, vrf_coordinatorV2_mock
network.config.chainId
// setting up our test variables
beforeEach(async function () {
const deployer = getNamedAccounts()
await deployments.fixture("all")
lottery = await ethers.getContract("Lottery", deployer)
vrf_coordinatorV2_mock = await ethers.getContract("VRFCoordinatorV2Mock", deployer)
})
describe("constructor", async function () {
it(" -> initializes the lottery correctly", async function () {
const lottery_state = await lottery.getLotteryState()
const interval = await lottery.getInterval()
assert.equal(lottery_state.toString(), "0")
// 0 = OPEN
assert.equal(
interval.toString(),
networkConfig[network.config.chainId]["interval"]
)
})
})
describe("enterLottery", async function () {
it("reverts when you don't pay enough", async function () {
await expect(
lottery.EnterLottery().to.be.revertedWith("Lottery_NotEnoughETHEntered")
)
})
})
}) and in the output I get 0 passing (789ms)
1 failing
1) Lottery
"before each" hook for "reverts when you don't pay enough":
Error: invalid signer or provider (argument="signerOrProvider", value={}, code=INVALID_ARGUMENT, version=contracts/5.7.0) |
Beta Was this translation helpful? Give feedback.
Answered by
parishill25
May 2, 2023
Replies: 2 comments 1 reply
-
try const deployer = await getNamedAccounts() |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
naman1402
-
@NamanMohnani here is the issue; const deployer = (await getNamedAccounts()).deployer; and as @parishill25 said add this in hardhat.config.js file; namedAccounts: {
deployer: {
default: 0,
},
user:{
default:1,
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
try const deployer = await getNamedAccounts()
and don't forget to add :
namedAccounts: {
deployer: {
default: 0,
},
user:{
default:1,
}
to your config file