-
Hello to everyone. My staging test pending after returning Promise. All logic is executed, but the test does not ends. And its not trowing timeout error. Maybe somebody had same issue const { network, getNamedAccounts, ethers } = require("hardhat")
const { developmentChains } = require("../../helper-hardhat-config")
const { assert, expect } = require("chai")
developmentChains.includes(network.name)
? describe.scip
: describe("Raffle Unit Test", function () {
let raffle, deployer, raffleEntranceFee
beforeEach(async () => {
deployer = (await getNamedAccounts()).deployer
raffle = await ethers.getContract("Raffle", deployer)
raffleEntranceFee = await raffle.getEntranceFee()
})
describe("fulfillRandomWords", function () {
it("works with life ChainlinkKeepers and Chainlunk VRF, randomly picks winner", async function () {
console.log("Setting up test...")
const startingTimeStamp = await raffle.getLatestTimeStamp()
const accounts = await ethers.getSigners()
console.log("Setting up Listener...")
await new Promise(async (resolve, reject) => {
raffle.once("WinnerPicked", async () => {
console.log("WinnerPicked event fired!")
try {
const recentWinner = await raffle.getRecentWinner()
const winnerEndingBalance = await ethers.provider.getBalance(
accounts[0].address,
)
const endingTimeStamp = await raffle.getLatestTimeStamp()
const raffleState = await raffle.getRaffleState()
await expect(raffle.getPlayers(0)).to.be.reverted
assert(endingTimeStamp > startingTimeStamp)
assert.equal(raffleState, 0n)
assert.equal(
winnerEndingBalance,
winnerStartingBalance + raffleEntranceFee,
)
assert.equal(recentWinner, accounts[0].address)
resolve()
console.log("resolve done")
} catch (error) {
console.log(error)
reject(error)
}
})
console.log("Entering Raffle...")
const tx = await raffle.enterRaffle({ value: raffleEntranceFee })
await tx.wait(1)
console.log("Ok, time to wait...")
const winnerStartingBalance = await ethers.provider.getBalance(
accounts[0].address,
)
})
console.log("Success")
})
})
}) i added some extra logs to see where its stops:
so its resolving promise, but in some reason test is not finishing. Here is my Repo |
Beta Was this translation helpful? Give feedback.
Answered by
Amrit-ko
Aug 15, 2023
Replies: 1 comment 16 replies
-
hi @Amrit-ko Please try changing below: assert.equal(raffleState, 0n)
assert.equal(winnerEndingBalance,winnerStartingBalance + raffleEntranceFee,)
assert.equal(recentWinner, accounts[0].address) Into: assert.equal(raffleState, 0)
assert.equal(winnerEndingBalance.toString(), winnerStartingBalance.add(raffleEntranceFee).toString())
assert.equal(recentWinner.toString(), accounts[0].address) Please also change below in your sepolia: {
url: SEPOLIA_RPC_URL,
accounts: [PRIVATE_KEY],
chainId: 11155111,
saveDeployments: true,
blockConfirmations: 6,
},
goerli: {
url: GOERLI_RPC_URL,
accounts: [PRIVATE_KEY],
chainId: 5,
saveDeployments: true,
blockConfirmations: 6,
},
mocha: {
timeout: 500000,
}, |
Beta Was this translation helpful? Give feedback.
16 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have tried today without any changes) and it passed successfully) but it tooks 21 min)))