PatrickAlphaC / hardhat-smartcontract-lottery-fcc

MIT License
117 stars 182 forks source link

AssertionError: expected '980010413654199210' to equal '995338797427942330' #145

Closed ghost closed 1 year ago

ghost commented 1 year ago
const { getNamedAccounts, deployments, ethers, network } = require("hardhat");
const { assert, expect } = require("chai");
const { experimentalAddHardhatNetworkMessageTraceHook } = require("hardhat/config");

developmentChains.includes(network.name)
    ? describe.skip
    : describe("Lottery", function () {
          let lottery, lotteryEntranceFee, deployer;
          const chainId = network.config.chainId;

          beforeEach(async function () {
              deployer = (await getNamedAccounts()).deployer;
              lottery = await ethers.getContract("Lottery", deployer);
              lotteryEntranceFee = await lottery.getEntranceFee();
          });

          describe("fullfillRandomWords", async function () {
              it("Works with live chainlink keepers and chainlink VRF,we get random winner", async function () {
                  const startingTimestamp = lottery.getLatestTimeStamp();
                  const accounts = await ethers.getSigners();
                  await new Promise(async function (resolve, reject) {
                      lottery.once("WinnerPicked", async function () {
                          console.log("winner picked event happened");
                          try {
                              const recentWinner = await lottery.getRecentWinner();
                              const lotterySTate = await lottery.getLotteryState();
                              const winnerEndingBalnce = await accounts[0].getBalance();
                              const endingTimestamp = lottery.getLatestTimeStamp();

                              await expect(lottery.getPlayer()).to.be.reverted;
                              assert.equal(recentWinner.toString(), accounts[0].address);
                              assert.equal(lotterySTate, 0);
                              assert.equal(
                                  winnerEndingBalnce.toString(),
                                  winnerStartingBalance.add(lotteryEntranceFee).toString()
                              );
                              assert(endingTimestamp > startingTimestamp);
                              resolve();
                          } catch (error) {
                              console.log(error);
                              reject(e);
                          }
                      });
                      await lottery.enterLottery({ value: lotteryEntranceFee });
                      const winnerStartingBalance = await accounts[0].getBalance();
                  });
              });
          });
      });

i am getting this error for winner balance assertion AssertionError: expected '980010413654199210' to equal '995338797427942330' at FragmentRunningEvent. (/home/hari/Documents/solidity/lottery/test/staging/lottery.staging.test.js:34:38) at processTicksAndRejections (node:internal/process/task_queues:96:5) { showDiff: true, actual: '980010413654199210', expected: '995338797427942330', operator: 'strictEqual' }

PatrickAlphaC commented 1 year ago

Can you:

  1. Make this a discusson on the full repo? https://github.com/smartcontractkit/full-blockchain-solidity-course-js/
  2. Follow this section for formatting questions? https://www.youtube.com/watch?t=19846&v=gyMwXuJrbJQ&feature=youtu.be