Lesson 9: Staging test no result #4172
Unanswered
JovanniChen
asked this question in
Q&A
Replies: 2 comments 10 replies
-
Raffle.staging.test.js const { assert, expect } = require("chai")
const { network, getNamedAccounts, deployments, ethers } = require("hardhat")
const { developmentChains } = require("../../helper-hardhat-config")
developmentChains.includes(network.name)
? describe.skip
: describe("Raffle Staging Test", function () {
let raffle, raffleEntranceFee, deployer
beforeEach(async () => {
deployer = (await getNamedAccounts()).deployer
raffle = await ethers.getContract("Raffle", deployer)
raffleEntranceFee = await raffle.getEntranceFee()
})
describe("fullfillRandomWords", () => {
it("works with live Chainlink Keepers and Chainlink VRF, we get a random winner", async () => {
console.log("Setting up test...")
const startingTimestamp = await raffle.getLastTimeStamp()
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 raffleState = await raffle.getRaffleState()
const winnerEndingBalance =
await accounts[0].getBalance()
const endingTimestamp =
await raffle.getLastTimeStamp()
await expect(raffle.getPlayer(0)).to.be.reverted
assert.equal(
recentWinner.toString(),
accounts[0].address
)
assert.equal(raffleState, 0)
assert.equal(
winnerEndingBalance.toString(),
winnerStartingBalance
.add(raffleEntranceFee)
.toString()
)
assert(endingTimestamp > startingTimestamp)
console.log("staging test done.")
} catch (error) {
console.log(error)
reject(error)
}
resolve()
})
console.log("Entering Raffle...")
const tx = await raffle.enterRaffle({
value: raffleEntranceFee,
})
await tx.wait(1)
console.log("Ok, time to wait...")
const winnerStartingBalance =
await accounts[0].getBalance()
})
})
})
}) |
Beta Was this translation helpful? Give feedback.
0 replies
-
Can someone give some advice? |
Beta Was this translation helpful? Give feedback.
10 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This is my REPO
Everything works fine, enter raffle works well, i got the reward, upkeep and vrf works well all, but when i got this in staging test.
what happened with my staging test?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions