-
error while passing empty bytes array to performUpkeep method TypeError: invalid BytesLike value (argument="value", value="[]", code=INVALID_ARGUMENT, version=6.6.4) bugged part of code: try {
await raffle.performUpkeep([])
} catch (error) {
console.log(error)
process.exit(1)
} complete Raffle.test.js code: const {assert,expect}=require("chai")
const {getNamedAccounts,deployments,ethers,network}=require("hardhat")
const {networkConfig,developmentChains}=require("../../helper-hardhat-config")
const {time,helpers}=require("@nomicfoundation/hardhat-network-helpers")
!developmentChains.includes(network.name)
?describe.skip
:
describe("Raffle",()=>{
//contract var def should be given here else scope error is most likely going to occur such as
//ReferenceError: raffle is not defined etcc....
let raffle,vrfCoordinatorV2,ethEntranceFee,deployer,interval
let interval1=31
const chainId=network.config.chainId;
beforeEach(async ()=>{
// const {deployer}= await getNamedAccounts()
const accounts = await ethers.getSigners();
deployer=accounts[0];
await deployments.fixture("all");
const raffle_address= (await deployments.get("Raffle")).address;
raffle=await ethers.getContractAt("Raffle",raffle_address);
raffle=raffle.connect(deployer);
const vrfCoordinatorV2_address= (await deployments.get("VRFCoordinatorV2Mock")).address;
vrfCoordinatorV2= await ethers.getContractAt("VRFCoordinatorV2Mock",vrfCoordinatorV2_address);
vrfCoordinatorV2=vrfCoordinatorV2.connect(deployer);
ethEntranceFee=await raffle.getEntranceFee();
interval= await raffle.getInterval();
// interval=interval.toNumber()
interval=ethers.toNumber(interval)
console.log(interval)
});
describe("constructor",()=>{
it("should set initial raffle state to open",async ()=>{
const raffle_state= await raffle.getRaffleState()
console.log(raffle_state)
assert(raffle_state.toString(),"0")
});
it("should set the min interval to 30 seconds ",async () =>{
// const interval= await raffle.getInterval()
console.log(interval)
assert(interval.toString(),networkConfig[chainId]["interval"])
});
});
describe("enterRaffle",()=>{
it("should revert if no min eth is provided to enter raffle",async ()=>{
await expect (raffle.enterRaffle()).to.be.revertedWithCustomError(raffle,"Raffle_sendMoreToEnterRaffle")
})
it("should add players to array entering raffle",async()=>{
await raffle.enterRaffle({value:ethEntranceFee})
const player= raffle.getPlayer(0)
assert(player.toString(),deployer.toString())
})
it("should not allow to enter if state is calculating",async()=>{
//increase interval just enough to make raffle state calculating
console.log("hello")
console.log(`${typeof(interval)}`)
await raffle.enterRaffle({value:ethEntranceFee})
console.log("breaking here")
// await network.provider.request({ method: "evm_increaseTime", params: [300] })
// await network.provider.send(`evm_increaseTime`,[40])
// await helpers.time.increase(interval+1)
await time.increase(interval+1)
// await network.provider.send()
//mines a single block to simulate next state of blockchain
// await network.provider.send("evm_mine",[])
//now we are acting as the chainlink keepers and calling performKeep to
//simulate the raffle state to be CALCULATING
try {
await raffle.performUpkeep([])
} catch (error) {
console.log(error)
process.exit(1)
}
console.log("End")
await expect(raffle.enterRaffle({value:ethEntranceFee})).to.be.revertedWithCustomError(raffle,"Raffle_RaffleNotOpen")
})
})
}); |
Beta Was this translation helpful? Give feedback.
Answered by
Amrit-ko
Aug 7, 2023
Replies: 1 comment 6 replies
-
hello @J-dev740 , you need to change this
|
Beta Was this translation helpful? Give feedback.
6 replies
Answer selected by
J-dev740
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello @J-dev740 , you need to change this
- await raffle.performUpkeep([])
+ await raffle.performUpkeep("0x")