LESSON 9 staging test help #1111
Answered
by
alymurtazamemon
AlexK020908
asked this question in
Q&A
-
I have read all the possible fixes for the staging test part but someone still can not land a test pass in the end. Whenever I run the staging test, this the error I end up getting
below the my code for the staging test developmentChains.includes(network.name)
? describe.skip
: describe("Smart Raffle", function () {
//variblaes
let raffle
//first we need to deploy with beforeEach
let deployer
let entranceFee
beforeEach(async function () {
deployer = (await getNamedAccounts()).deployer
// await deployments.fixture(["all"]) --> no need for this as when we run out deploy script --> it will already be deployed
//mock and raffle
raffle = await ethers.getContract("Raffle", deployer) //deploy the contract with deployer as the deployer
entranceFee = await raffle.getEntraceFee()
})
describe("fullfillrandomwords", function () {
it("works with live chianlink keepers and VRF, get a random number", async function () {
//we need to enter raffle --> nothing else since chianlink keepers and vrf will start the raffle for us
const accounts = await ethers.getSigners() //question --> does getsigners get the deployer as well ? why
console.log("setting up accounts and starting time stamp")
const startingTimeStamp = await raffle.getLatestTimeStamp()
//set up listeners before we enter raffle
await new Promise(async (resolve, reject) => {
console.log("setting up listenr...S")
raffle.once("winnerpicked", async () => {
console.log("winner picked event fired")
try {
//let us get the recent winer
const recentWinner = await raffle.getRecentWinner()
const raffleState = await raffle.getrafflestate()
const winnerBalance = await accounts[0].getBalance()
const endingTimeStamp = await raffle.getLatestTimeStamp()
console.log(`winner ending balance : ${winnerBalance}`)
await expect(raffle.getPlayer(0)).to.be.reverted
assert.equal(recentWinner, accounts[0].address)
//assert.equal(raffleState.toString(), "0");
assert.equal(
winnerBalance.toString(),
winnerStartingBalance.add(entranceFee).toString()
)
assert(startingTimeStamp > endingTimeStamp)
resolve()
} catch (error) {
console.error(error)
reject()
}
})
console.log("entering raffle...")
//then entering the raffle --> and this code will not complete
//until the listener stopped listening --> "once" keyword
const tx = await raffle.enterRaffle({ value: entranceFee })
//get the starting balance
console.log("waiting for one block confirmation")
await tx.wait(1) //we need to await tx.wait(3) becuase this only goes on when the wait confirmation finishes
const winnerStartingBalance = await accounts[0].getBalance()
console.log(`starting balance is : ${winnerStartingBalance}`)
})
})
})
}) everything works correctly on metamask but I am not sure what the issue is here... |
Beta Was this translation helpful? Give feedback.
Answered by
alymurtazamemon
Jul 19, 2022
Replies: 1 comment 3 replies
-
- assert(startingTimeStamp > endingTimeStamp)
+ expect(endingTimeStamp).to.be.greaterThan(startingTimeStamp); |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
AlexK020908
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@AlexK020908