PatrickAlphaC / hardhat-fund-me-fcc

82 stars 182 forks source link

module.export.tags #159

Closed muhammet72 closed 1 year ago

muhammet72 commented 1 year ago

module.exports.tags does not work


yarn hardhat deploy --tags mocks yarn run v1.22.15 $ /home/code/hardhat-fund-me/node_modules/.bin/hardhat deploy --tags mocks Nothing to compile An unexpected error occurred:

Error: ERROR processing skip func of /home/code/hardhat-fund-me/deploy/01-deploy-fund-me.js: ReferenceError: chainId is not defined at Object. (/home/code/hardhat-fund-me/deploy/01-deploy-fund-me.js:4:46) at Module._compile (node:internal/modules/cjs/loader:1103:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at DeploymentsManager.executeDeployScripts (/home/code/hardhat-fund-me/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1093:22) at DeploymentsManager.runDeploy (/home/code/hardhat-fund-me/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1052:16) at SimpleTaskDefinition.action (/home/code/hardhat-fund-me/node_modules/hardhat-deploy/src/index.ts:438:5) at DeploymentsManager.executeDeployScripts (/home/code/hardhat-fund-me/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1100:15) at DeploymentsManager.runDeploy (/home/code/hardhat-fund-me/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1052:16) at SimpleTaskDefinition.action (/home/code/hardhat-fund-me/node_modules/hardhat-deploy/src/index.ts:438:5) at Environment._runTaskDefinition (/home/code/hardhat-fund-me/node_modules/hardhat/src/internal/core/runtime-environment.ts:330:14) at Environment.run (/home/code/hardhat-fund-me/node_modules/hardhat/src/internal/core/runtime-environment.ts:163:14) at SimpleTaskDefinition.action (/home/code/hardhat-fund-me/node_modules/hardhat-deploy/src/index.ts:584:32) at Environment._runTaskDefinition (/home/code/hardhat-fund-me/node_modules/hardhat/src/internal/core/runtime-environment.ts:330:14) at Environment.run (/home/code/hardhat-fund-me/node_modules/hardhat/src/internal/core/runtime-environment.ts:163:14) at SimpleTaskDefinition.action (/home/code/hardhat-fund-me/node_modules/hardhat-deploy/src/index.ts:669:5) at Environment._runTaskDefinition (/home/code/hardhat-fund-me/node_modules/hardhat/src/internal/core/runtime-environment.ts:330:14) error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

cryptocambi commented 1 year ago

Hi Mohammet72,

Yes I did:

require("@nomiclabs/hardhat-waffle") require("hardhat-gas-reporter") require("@nomiclabs/hardhat-etherscan") require("dotenv").config() require("solidity-coverage") require("hardhat-deploy") // You need to export an object to set up your config // Go to https://hardhat.org/config/ to learn more /**

const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY || "" const SEPOLIA_RPC_URL = process.env.SEPOLIA_RPC_URL || "https://eth-sepolia.g.alchemy.com/v2/YOUR-API-KEY" const PRIVATE_KEY = process.env.PRIVATE_KEY || "0x11ee3108a03081fe260ecdc106554d09d9d1209bcafd46942b10e02943effc4a" const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY || ""

module.exports = { defaultNetwork: "hardhat", networks: { hardhat: { chainId: 31337, // gasPrice: 130000000000, }, sepolia: { url: SEPOLIA_RPC_URL, accounts: [PRIVATE_KEY], chainId: 11155111, blockConfirmations: 6, }, }, solidity: { compilers: [ { version: "0.8.7", }, { version: "0.6.6", }, ], }, etherscan: { apiKey: ETHERSCAN_API_KEY, // customChains: [], // uncomment this line if you are getting a TypeError: customChains is not iterable }, gasReporter: { enabled: true, currency: "USD", outputFile: "gas-report.txt", noColors: true, // coinmarketcap: COINMARKETCAP_API_KEY, }, namedAccounts: { deployer: { default: 0, // here this will by default take the first account as deployer 1: 0, // similarly on mainnet it will take the first account as deployer. Note though that depending on how hardhat network are configured, the account 0 on one network can be different than on another }, }, mocha: { timeout: 500000, }, }

when I run the command "yarn hardhat", this is what appear:

Hardhat version 2.14.0

Usage: hardhat [GLOBAL OPTIONS] [TASK OPTIONS]

GLOBAL OPTIONS:

--config A Hardhat config file. --emoji Use emoji in messages. --flamegraph Generate a flamegraph of your Hardhat tasks --help Shows this message, or a task's help if its name is provided --max-memory The maximum amount of memory that Hardhat can use. --network The network to connect to. --show-stack-traces Show stack traces (always enabled on CI servers). --tsconfig A TypeScript config file. --typecheck Enable TypeScript type-checking of your scripts/tests --verbose Enables Hardhat verbose logging --version Shows hardhat's version.

AVAILABLE TASKS:

check Check whatever you need clean Clears the cache and deletes all artifacts compile Compiles the entire project, building all artifacts compile:solidity:get-compilation-job-for-file compile:solidity:get-compiler-input console Opens a hardhat console coverage Generates a code coverage report for tests flatten Flattens and prints contracts and their dependencies. If no file is passed, all the contracts in the project will be flattened. help Prints this message node Starts a JSON-RPC server on top of Hardhat Network run Runs a user-defined script after compiling the project test Runs mocha tests typechain Generate Typechain typings for compiled contracts verify Verifies contract on Etherscan

To get help for a specific task run: npx hardhat help [task]

Done in 2.05s.

I am thinking to add it manually on "hardhat.config.js", I don't know how to do it and where to find materials to learn how to do it.

GIRISHNP commented 1 year ago

@PatrickAlphaC
"Sorry to bother u" yarn hardhat deploy --tags mocks It gives 'Nothing to compile'

here is the code 'const { developmentChains, DECIMALS, INITIAL_ANSWER } = require("../helper-hardhat-config") const { network } = require("hardhat"); module.exports = async ({ getNamedAcoounts, deployments }) => { const { deploy, log } = deployments const { deployer } = await getNamedAcoounts() const chainId = network.config.chainId console.log(network.name);

if (chainId == 31337) {
    log("Local network detected ! Deploying mocks .... ")
    await deploy("MockV3Aggregator", {
        contract: "MockV3Aggregator",
        from: deployer,
        log: true,
        args: [DECIMALS, INITIAL_ANSWER]
    })
    log("Mock deployed !")
    log("-------------------------------------------")
}

} module.exports.tags = ["all", "mocks"]'

cryptocambi commented 1 year ago

Hi, No bother me, actually thank for your help! I copy your code, but still saying "Nothing to compile".

In the meantime those days I started lesson 9, and also with the lottery contract I have "Nothing to compile" as answer. Might be that I am missing some dependencies?

On Thu, 11 May 2023 at 16:11, GIRISH N P @.***> wrote:

@PatrickAlphaC https://github.com/PatrickAlphaC "Sorry to bother u" yarn hardhat deploy --tags mocks It gives 'Nothing to compile'

here is the code 'const { developmentChains, DECIMALS, INITIAL_ANSWER } = require("../helper-hardhat-config") const { network } = require("hardhat"); module.exports = async ({ getNamedAcoounts, deployments }) => { const { deploy, log } = deployments const { deployer } = await getNamedAcoounts() const chainId = network.config.chainId console.log(network.name);

if (chainId == 31337) { log("Local network detected ! Deploying mocks .... ") await deploy("MockV3Aggregator", { contract: "MockV3Aggregator", from: deployer, log: true, args: [DECIMALS, INITIAL_ANSWER] }) log("Mock deployed !") log("-------------------------------------------") }

} module.exports.tags = ["all", "mocks"]'

— Reply to this email directly, view it on GitHub https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#issuecomment-1544058801, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4HG4OWSFAZ6HESB2M2PBSDXFTXRXANCNFSM6AAAAAAWUHCASE . You are receiving this because you commented.Message ID: @.***>

GIRISHNP commented 1 year ago

version 6 in MockV3Aggregator.sol its no longer working iam using version that may be the issue or mocks,tags are not working in that verion anymore, //Iam thinking to go with next lesson , I got frustrated to solving this issue

GIRISHNP commented 1 year ago

How many lessons do you completed bro

cryptocambi commented 1 year ago

At the moment I am working on the Lottery contract, lesson 9. I did finish the Simple storage contract and getting issue with issue with the Fund me contract. What version of the MocksV3Aggregator are you using?

On Fri, 12 May 2023 at 06:00, GIRISH N P @.***> wrote:

How many lessons do you completed bro

— Reply to this email directly, view it on GitHub https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#issuecomment-1545072987, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4HG4OTHNEAYCN2QSAJJPNDXFWYWDANCNFSM6AAAAAAWUHCASE . You are receiving this because you commented.Message ID: @.***>

cryptocambi commented 1 year ago

My man,

I managed to compile and deploy the fund me contract. I followed this link explanation: https://hardhat.org/hardhat-runner/docs/guides/compile-contracts I basically clean the case and compiled and after deployed, it works.

Its really frustrating when you understand why is not working, but when you get it the amount of knowledge you acquire is pure dopamine :).

By the way, where are you based?

On Fri, 12 May 2023 at 10:41, Kiflom Adhanom @.***> wrote:

At the moment I am working on the Lottery contract, lesson 9. I did finish the Simple storage contract and getting issue with issue with the Fund me contract. What version of the MocksV3Aggregator are you using?

On Fri, 12 May 2023 at 06:00, GIRISH N P @.***> wrote:

How many lessons do you completed bro

— Reply to this email directly, view it on GitHub https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#issuecomment-1545072987, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4HG4OTHNEAYCN2QSAJJPNDXFWYWDANCNFSM6AAAAAAWUHCASE . You are receiving this because you commented.Message ID: @.***>

GIRISHNP commented 1 year ago

I used all the versions, still it won't work ..., I removed module.export and tried to run specific file (00-fund-me.js) it doesn't work , no anonymous func is calling itself .., Can I get yr IG or mail-id , linked in to have touch with you , if i got stuck in any problem we can discuss, vice versa

On Fri, 12 May, 2023, 4:01 pm Cryptocambi, @.***> wrote:

My man,

I managed to compile and deploy the fund me contract. I followed this link explanation: https://hardhat.org/hardhat-runner/docs/guides/compile-contracts I basically clean the case and compiled and after deployed, it works.

Its really frustrating when you understand why is not working, but when you get it the amount of knowledge you acquire is pure dopamine :).

By the way, where are you based?

On Fri, 12 May 2023 at 10:41, Kiflom Adhanom @.***> wrote:

At the moment I am working on the Lottery contract, lesson 9. I did finish the Simple storage contract and getting issue with issue with the Fund me contract. What version of the MocksV3Aggregator are you using?

On Fri, 12 May 2023 at 06:00, GIRISH N P @.***> wrote:

How many lessons do you completed bro

— Reply to this email directly, view it on GitHub < https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#issuecomment-1545072987 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/A4HG4OTHNEAYCN2QSAJJPNDXFWYWDANCNFSM6AAAAAAWUHCASE

. You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#issuecomment-1545531312, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYPEWXCDRXCYWFZHVDMNU4DXFYGPTANCNFSM6AAAAAAWUHCASE . You are receiving this because you commented.Message ID: @.***>

cryptocambi commented 1 year ago

yes, of course. On IG look for @cryptocambi

I notice spelling mistake on the contract that you paste, you wrote " getNamedAcoount" instead than "getNamedAccounts" Actually depend how you wrote it when you defined on your hardhat.config.js file

On Fri, 12 May 2023 at 13:19, GIRISH N P @.***> wrote:

I used all the versions, still it won't work ..., I removed module.export and tried to run specific file (00-fund-me.js) it doesn't work , no anonymous func is calling itself .., Can I get yr IG or mail-id , linked in to have touch with you , if i got stuck in any problem we can discuss, vice versa

On Fri, 12 May, 2023, 4:01 pm Cryptocambi, @.***> wrote:

My man,

I managed to compile and deploy the fund me contract. I followed this link explanation: https://hardhat.org/hardhat-runner/docs/guides/compile-contracts I basically clean the case and compiled and after deployed, it works.

Its really frustrating when you understand why is not working, but when you get it the amount of knowledge you acquire is pure dopamine :).

By the way, where are you based?

On Fri, 12 May 2023 at 10:41, Kiflom Adhanom @.***> wrote:

At the moment I am working on the Lottery contract, lesson 9. I did finish the Simple storage contract and getting issue with issue with the Fund me contract. What version of the MocksV3Aggregator are you using?

On Fri, 12 May 2023 at 06:00, GIRISH N P @.***> wrote:

How many lessons do you completed bro

— Reply to this email directly, view it on GitHub <

https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#issuecomment-1545072987

,

or unsubscribe <

https://github.com/notifications/unsubscribe-auth/A4HG4OTHNEAYCN2QSAJJPNDXFWYWDANCNFSM6AAAAAAWUHCASE

. You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub < https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#issuecomment-1545531312 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AYPEWXCDRXCYWFZHVDMNU4DXFYGPTANCNFSM6AAAAAAWUHCASE

. You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#issuecomment-1545585690, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4HG4OQINJJ5WEJKKTZ32R3XFYMDRANCNFSM6AAAAAAWUHCASE . You are receiving this because you commented.Message ID: @.***>

PatrickAlphaC commented 1 year ago

Nice work together :)

GIRISHNP commented 1 year ago

Hey bro its been 3 days that I sent u a message in insta u r not responding, stay active there

On Mon, 15 May, 2023, 5:41 am Patrick Collins, @.***> wrote:

Closed #159 https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159 as completed.

— Reply to this email directly, view it on GitHub https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#event-9240989738, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYPEWXGV2RDJJCMFSOHOHRLXGFYDLANCNFSM6AAAAAAWUHCASE . You are receiving this because you commented.Message ID: @.*** .com>

PatrickAlphaC commented 1 year ago

@GIRISHNP they are helping out of the goodness of their heart. Please don't abuse that. Sometimes people won't be able to get back to you.

cryptocambi commented 1 year ago

Hi Girish,

I am having this issue "Lesson 9 Error: "before each" hook for "initializes the raffle correctly": #1714" The solution if to pull a request and merge it. But I think I am missing something in the process. check attachment

thank bro

On Wed, 17 May 2023 at 03:04, Patrick Collins @.***> wrote:

@GIRISHNP https://github.com/GIRISHNP they are helping out of the goodness of their heart. Please don't abuse that. Sometimes people won't be able to get back to you.

— Reply to this email directly, view it on GitHub https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#issuecomment-1550542271, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4HG4OW5PMNWV7ODZDMIXELXGQP3RANCNFSM6AAAAAAWUHCASE . You are receiving this because you were mentioned.Message ID: @.***>

cryptocambi commented 1 year ago

Hi Girish,

I have just tested my raffle mock deploy contract, it works. Here if you want to compare it:

const { developmentChains } = require("../helper-hardhat-config") const { ethers } = require("hardhat")

const BASE_FEE = ethers.utils.parseEther("0.25") const GAS_PRICE_LINK = 1e9

module.exports = async function ({ getNamedAccounts, deployments }) { const { deploy, log } = deployments const { deployer } = await getNamedAccounts() const chainId = network.config.chainId const args = [BASE_FEE, GAS_PRICE_LINK]

if (chainId == 31337) {
    log("Local network detected: Deeploying mocks....")

    await deploy("VRFCoordinatorV2Mock", {
        from: deployer,
        log: true,
        args: args,
    })

    log("Mock deployed!")
    log("----------------------------------------")
}

} module.exports.tags = ["all", "mocks"]

the command that I use to deploy it is :

yarn hardhat deploy --tags deploy-mock.js

On Mon, 15 May 2023 at 05:09, GIRISH N P @.***> wrote:

Hey bro its been 3 days that I sent u a message in insta u r not responding, stay active there

On Mon, 15 May, 2023, 5:41 am Patrick Collins, @.***> wrote:

Closed #159 https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159 as completed.

— Reply to this email directly, view it on GitHub < https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#event-9240989738 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AYPEWXGV2RDJJCMFSOHOHRLXGFYDLANCNFSM6AAAAAAWUHCASE

. You are receiving this because you commented.Message ID: @.*** .com>

— Reply to this email directly, view it on GitHub https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#issuecomment-1547130394, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4HG4OS4NH6HZJFXH323BI3XGGM77ANCNFSM6AAAAAAWUHCASE . You are receiving this because you were mentioned.Message ID: @.***>

cryptocambi commented 1 year ago

Hi, this my fund me deploy mock contract: const { developmentChains } = require("../helper-hardhat-config") const { ethers } = require("hardhat")

const BASE_FEE = ethers.utils.parseEther("0.25") const GAS_PRICE_LINK = 1e9

module.exports = async function ({ getNamedAccounts, deployments }) { const { deploy, log } = deployments const { deployer } = await getNamedAccounts() const chainId = network.config.chainId const args = [BASE_FEE, GAS_PRICE_LINK]

if (chainId == 31337) {
    log("Local network detected: Deeploying mocks....")

    await deploy("VRFCoordinatorV2Mock", {
        from: deployer,
        log: true,
        args: args,
    })

    log("Mock deployed!")
    log("----------------------------------------")
}

} module.exports.tags = ["all", "mocks"]

keep me update pls On Mon, 22 May 2023 at 11:28, Kiflom Adhanom @.***> wrote:

Hi Girish,

I have just tested my raffle mock deploy contract, it works. Here if you want to compare it:

const { developmentChains } = require("../helper-hardhat-config") const { ethers } = require("hardhat")

const BASE_FEE = ethers.utils.parseEther("0.25") const GAS_PRICE_LINK = 1e9

module.exports = async function ({ getNamedAccounts, deployments }) { const { deploy, log } = deployments const { deployer } = await getNamedAccounts() const chainId = network.config.chainId const args = [BASE_FEE, GAS_PRICE_LINK]

if (chainId == 31337) {
    log("Local network detected: Deeploying mocks....")

    await deploy("VRFCoordinatorV2Mock", {
        from: deployer,
        log: true,
        args: args,
    })

    log("Mock deployed!")
    log("----------------------------------------")
}

} module.exports.tags = ["all", "mocks"]

the command that I use to deploy it is :

yarn hardhat deploy --tags deploy-mock.js

On Mon, 15 May 2023 at 05:09, GIRISH N P @.***> wrote:

Hey bro its been 3 days that I sent u a message in insta u r not responding, stay active there

On Mon, 15 May, 2023, 5:41 am Patrick Collins, @.***> wrote:

Closed #159 https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159 as completed.

— Reply to this email directly, view it on GitHub < https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#event-9240989738 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AYPEWXGV2RDJJCMFSOHOHRLXGFYDLANCNFSM6AAAAAAWUHCASE

. You are receiving this because you commented.Message ID: @.*** .com>

— Reply to this email directly, view it on GitHub https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#issuecomment-1547130394, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4HG4OS4NH6HZJFXH323BI3XGGM77ANCNFSM6AAAAAAWUHCASE . You are receiving this because you were mentioned.Message ID: @.***>

cryptocambi commented 1 year ago

Hi,

this is the unit test

const { developmentChains, networkConfig } = require( "../../helper-hardhat-config") const { getNamedAccounts, deployments, ethers, network } = require("hardhat" ) const { assert, expect } = require("chai")

!developmentChains.includes(network.name) ? describe.skip : describe("Raffle unit test", function () { let raffle, vrfCoordinatorV2Mock, raffleEntranceFee, deployer, interval const chainId = network.config.chainId beforeEach(async function () { deployer = (await getNamedAccounts()).deployer await deployments.fixture(["all"]) raffle = await ethers.getContract("Raffle", deployer) raffleEntranceFee = await raffle.getEntranceFee() vrfCoordinatorV2Mock = await ethers.getContract( "VRFCoordinatorV2Mock", deployer) interval = await raffle.getInterval() }) describe("constructor", function () { it("initialised the raffle correctly", async () => { const raffleState = await raffle.getRaffleState() assert.equal(raffleState.toString(), "0") assert.equal(interval.toString(), networkConfig[chainId][ "interval"]) }) }) describe("enterRaffle", function () { it("revert when you don't pay enough", async () => { await expect(raffle.enterRaffle()).to.be.revertedWith( "RaffleNotEnoughETHEntered" ) }) it("records player when they enter", async () => { await raffle.enterRaffle({ value: raffleEntranceFee }) const playerFromContract = await raffle.getPlayers(0) assert.equal(playerFromContract, deployer) }) it("emits event on Enter", async () => { await expect(raffle.enterRaffle({ value: raffleEntranceFee })).to.emit( raffle, "RaffleEnter" ) }) it("doesn't allow entrance when raffle is calculatin", async () => { await raffle.enterRaffle({ value: raffleEntranceFee }) await network.provider.send("evm_increaseTime", [interval. toNumber() + 1]) await network.provider.send("evm_mine", []) await raffle.performUpkeep([]) await expect(raffle.enterRaffle({ value: raffleEntranceFee })).to.be.revertedWith( "RaffleNotOpen" ) }) }) describe("checkUpkeep", function () { it("returns false if ppl haven't sent any ETH", async () => { //await raffle.enterRaffle({ value: raffleEntranceFee }) await network.provider.send("evm_increaseTime", [interval. toNumber() + 1]) await network.provider.send("evm_mine", []) const { upkeepNeeded } = await raffle.callStatic. checkUpkeep([]) assert(!upkeepNeeded) }) it("returns false if raffle isn't open", async () => { await raffle.enterRaffle({ value: raffleEntranceFee }) await network.provider.send("evm_increaseTime", [interval. toNumber() + 1]) await network.provider.send("evm_mine", []) await raffle.performUpkeep([]) const raffleState = await raffle.getRaffleState() const { upkeepNeeded } = await raffle.callStatic. checkUpkeep([]) assert.equal(raffleState.toString(), "1") assert.equal(upkeepNeeded, false) }) it("returns false if enough time hasn't passed", async () => { await raffle.enterRaffle({ value: raffleEntranceFee }) await network.provider.send("evm_increaseTime", [interval. toNumber() - 5]) // use a higher number here if this test fails await network.provider.request({ method: "evm_mine", params: [] }) const { upkeepNeeded } = await raffle.callStatic. checkUpkeep("0x") // upkeepNeeded = (timePassed && isOpen && hasBalance && hasPlayers) assert(!upkeepNeeded) }) it("returns true if enough time has passed, has players, eth, and is open", async () => { await raffle.enterRaffle({ value: raffleEntranceFee }) await network.provider.send("evm_increaseTime", [interval. toNumber() + 1]) await network.provider.request({ method: "evm_mine", params: [] }) const { upkeepNeeded } = await raffle.callStatic. checkUpkeep("0x") // upkeepNeeded = (timePassed && isOpen && hasBalance && hasPlayers) assert(upkeepNeeded) }) }) describe("performUpkeep", function () { it("it can only run if checkupkeep is true", async () => { await raffle.enterRaffle({ value: raffleEntranceFee }) await network.provider.send("evm_increaseTime", [interval. toNumber() + 1]) await network.provider.request({ method: "evm_mine", params: [] }) const tx = await raffle.performUpkeep([]) assert(tx) }) it("revert when checkupkeep is false", async () => { await expect(raffle.performUpkeep([])).to.be.revertedWith( "Raffle_UpkeepNotNeeded" ) }) it("update the raffle state, emits an event, and calls the vrf coordiantor", async () => { await raffle.enterRaffle({ value: raffleEntranceFee }) await network.provider.send("evm_increaseTime", [interval. toNumber() + 1]) await network.provider.request({ method: "evm_mine", params: [] }) const txResponse = await raffle.performUpkeep([]) const txReceipt = await txResponse.wait(1) const requestId = txReceipt.events[1].args.requestId const raffleState = await raffle.getRaffleState() assert(requestId.toNumber() > 0) assert(raffleState.toString() == "1") }) }) describe("FullfilrandomWord", async () => { beforeEach(async () => { await raffle.enterRaffle({ value: raffleEntranceFee }) await network.provider.send("evm_increaseTime", [interval. toNumber() + 1]) await network.provider.request({ method: "evm_mine", params: [] }) }) it("can only be call after performUpkeep", async () => { await expect( vrfCoordinatorV2Mock.fulfillRandomWords(0, raffle. address) ).to.be.revertedWith("nonexistent request") await expect( vrfCoordinatorV2Mock.fulfillRandomWords(1, raffle. address) ).to.be.revertedWith("nonexistent request") }) it("picks a winner, resets the lottery, and sends money", async () => { const additionalEntrance = 3 const startingAccountIndex = 1 // 0 deployer const accounts = await ethers.getSigners() for ( let i = startingAccountIndex; i < startingAccountIndex + additionalEntrance; i++ ) { const accountConnectRaffle = raffle.connect(accounts[i ]) await accountConnectRaffle.enterRaffle({ value: raffleEntranceFee }) }

              const startingTimeStamp = await raffle.getLastTimeStamp()
              await new Promise(async (resolve, reject) => {
                  raffle.once("WinnerPicked", async () => {
                      console.log("Found the event!!")
                      try {
                          const recentWinner = await raffle.

getRecentWinner() console.log(recentWinner) console.log(accounts[2].address) console.log(accounts[0].address) console.log(accounts[1].address) console.log(accounts[3].address) const raffleState = await raffle. getRaffleState() const endingTimeStamp = await raffle. getLastTimeStamp() const numPlayers = await raffle. getNumberOfPlayers() const winnerEndingBalance = await accounts[1]. getBalance() assert.equal(numPlayers.toString(), "0") assert.equal(raffleState.toString(), "0") assert(endingTimeStamp > startingTimeStamp) assert.equal( winnerEndingBalance, winnerStartingBalance .add( raffleEntranceFee .mul(additionalEntrance) .add(raffleEntranceFee) ) .toString() ) } catch (e) { reject(e) } resolve() }) const tx = await raffle.performUpkeep([]) const txReceipt = await tx.wait(1) const winnerStartingBalance = await accounts[1]. getBalance() await vrfCoordinatorV2Mock.fulfillRandomWords( txReceipt.events[1].args.requestId, raffle.address ) }) }) }) })

On Mon, 22 May 2023 at 12:01, Kiflom Adhanom @.***> wrote:

Hi, this my fund me deploy mock contract: const { developmentChains } = require("../helper-hardhat-config") const { ethers } = require("hardhat")

const BASE_FEE = ethers.utils.parseEther("0.25") const GAS_PRICE_LINK = 1e9

module.exports = async function ({ getNamedAccounts, deployments }) { const { deploy, log } = deployments const { deployer } = await getNamedAccounts() const chainId = network.config.chainId const args = [BASE_FEE, GAS_PRICE_LINK]

if (chainId == 31337) {
    log("Local network detected: Deeploying mocks....")

    await deploy("VRFCoordinatorV2Mock", {
        from: deployer,
        log: true,
        args: args,
    })

    log("Mock deployed!")
    log("----------------------------------------")
}

} module.exports.tags = ["all", "mocks"]

keep me update pls On Mon, 22 May 2023 at 11:28, Kiflom Adhanom @.***> wrote:

Hi Girish,

I have just tested my raffle mock deploy contract, it works. Here if you want to compare it:

const { developmentChains } = require("../helper-hardhat-config") const { ethers } = require("hardhat")

const BASE_FEE = ethers.utils.parseEther("0.25") const GAS_PRICE_LINK = 1e9

module.exports = async function ({ getNamedAccounts, deployments }) { const { deploy, log } = deployments const { deployer } = await getNamedAccounts() const chainId = network.config.chainId const args = [BASE_FEE, GAS_PRICE_LINK]

if (chainId == 31337) {
    log("Local network detected: Deeploying mocks....")

    await deploy("VRFCoordinatorV2Mock", {
        from: deployer,
        log: true,
        args: args,
    })

    log("Mock deployed!")
    log("----------------------------------------")
}

} module.exports.tags = ["all", "mocks"]

the command that I use to deploy it is :

yarn hardhat deploy --tags deploy-mock.js

On Mon, 15 May 2023 at 05:09, GIRISH N P @.***> wrote:

Hey bro its been 3 days that I sent u a message in insta u r not responding, stay active there

On Mon, 15 May, 2023, 5:41 am Patrick Collins, @.***> wrote:

Closed #159 https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159 as completed.

— Reply to this email directly, view it on GitHub < https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#event-9240989738 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AYPEWXGV2RDJJCMFSOHOHRLXGFYDLANCNFSM6AAAAAAWUHCASE

. You are receiving this because you commented.Message ID: @.*** .com>

— Reply to this email directly, view it on GitHub https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#issuecomment-1547130394, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4HG4OS4NH6HZJFXH323BI3XGGM77ANCNFSM6AAAAAAWUHCASE . You are receiving this because you were mentioned.Message ID: @.***>

cryptocambi commented 1 year ago

Hi Bro, this is the staging test :

const { developmentChains, networkConfig } = require("../../helper-hardhat-config") const { getNamedAccounts, deployments, ethers, network } = require("hardhat") const { assert, expect } = require("chai")

developmentChains.includes(network.name) ? describe.skip : describe("Raffle unit test", function () { let raffle, raffleEntranceFee, deployer

      beforeEach(async function () {
          deployer = (await getNamedAccounts()).deployer
          raffle = await ethers.getContract("Raffle", deployer)
          raffleEntranceFee = await raffle.getEntranceFee()
      })

      describe("FulfillRandomWord", function () {
          it("works with live chainlink keepers and Chainlink VRF, we

get a random winner", async () => { const startingTimeStamp = await raffle.getLastTimeStamp() const accounts = await ethers.getSigners()

              console.log("Entering Raffle...")
              const tx = await raffle.enterRaffle({ value:

raffleEntranceFee }) const txReceipt = await tx.wait(1) console.log("Ok, time to wait...") const winnerStartingBalance = await accounts[0].getBalance()

              await new Promise(async (resolve, reject) => {
                  raffle.once("WinnerPicked", async () => {
                      console.log("Winner event has been 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) resolve() } catch (error) { reject(error) console.log(error) } }) }) }) }) })

On Wed, 31 May 2023 at 18:11, Kiflom Adhanom @.***> wrote:

Hi,

this is the unit test

const { developmentChains, networkConfig } = require( "../../helper-hardhat-config") const { getNamedAccounts, deployments, ethers, network } = require( "hardhat") const { assert, expect } = require("chai")

!developmentChains.includes(network.name) ? describe.skip : describe("Raffle unit test", function () { let raffle, vrfCoordinatorV2Mock, raffleEntranceFee, deployer, interval const chainId = network.config.chainId beforeEach(async function () { deployer = (await getNamedAccounts()).deployer await deployments.fixture(["all"]) raffle = await ethers.getContract("Raffle", deployer) raffleEntranceFee = await raffle.getEntranceFee() vrfCoordinatorV2Mock = await ethers.getContract( "VRFCoordinatorV2Mock", deployer) interval = await raffle.getInterval() }) describe("constructor", function () { it("initialised the raffle correctly", async () => { const raffleState = await raffle.getRaffleState() assert.equal(raffleState.toString(), "0") assert.equal(interval.toString(), networkConfig[chainId ]["interval"]) }) }) describe("enterRaffle", function () { it("revert when you don't pay enough", async () => { await expect(raffle.enterRaffle()).to.be.revertedWith( "RaffleNotEnoughETHEntered" ) }) it("records player when they enter", async () => { await raffle.enterRaffle({ value: raffleEntranceFee }) const playerFromContract = await raffle.getPlayers(0) assert.equal(playerFromContract, deployer) }) it("emits event on Enter", async () => { await expect(raffle.enterRaffle({ value: raffleEntranceFee })).to.emit( raffle, "RaffleEnter" ) }) it("doesn't allow entrance when raffle is calculatin", async () => { await raffle.enterRaffle({ value: raffleEntranceFee }) await network.provider.send("evm_increaseTime", [ interval.toNumber() + 1]) await network.provider.send("evm_mine", []) await raffle.performUpkeep([]) await expect(raffle.enterRaffle({ value: raffleEntranceFee })).to.be.revertedWith( "RaffleNotOpen" ) }) }) describe("checkUpkeep", function () { it("returns false if ppl haven't sent any ETH", async () => { //await raffle.enterRaffle({ value: raffleEntranceFee }) await network.provider.send("evm_increaseTime", [ interval.toNumber() + 1]) await network.provider.send("evm_mine", []) const { upkeepNeeded } = await raffle.callStatic. checkUpkeep([]) assert(!upkeepNeeded) }) it("returns false if raffle isn't open", async () => { await raffle.enterRaffle({ value: raffleEntranceFee }) await network.provider.send("evm_increaseTime", [ interval.toNumber() + 1]) await network.provider.send("evm_mine", []) await raffle.performUpkeep([]) const raffleState = await raffle.getRaffleState() const { upkeepNeeded } = await raffle.callStatic. checkUpkeep([]) assert.equal(raffleState.toString(), "1") assert.equal(upkeepNeeded, false) }) it("returns false if enough time hasn't passed", async () => { await raffle.enterRaffle({ value: raffleEntranceFee }) await network.provider.send("evm_increaseTime", [ interval.toNumber() - 5]) // use a higher number here if this test fails await network.provider.request({ method: "evm_mine", params: [] }) const { upkeepNeeded } = await raffle.callStatic. checkUpkeep("0x") // upkeepNeeded = (timePassed && isOpen && hasBalance && hasPlayers) assert(!upkeepNeeded) }) it("returns true if enough time has passed, has players, eth, and is open", async () => { await raffle.enterRaffle({ value: raffleEntranceFee }) await network.provider.send("evm_increaseTime", [ interval.toNumber() + 1]) await network.provider.request({ method: "evm_mine", params: [] }) const { upkeepNeeded } = await raffle.callStatic. checkUpkeep("0x") // upkeepNeeded = (timePassed && isOpen && hasBalance && hasPlayers) assert(upkeepNeeded) }) }) describe("performUpkeep", function () { it("it can only run if checkupkeep is true", async () => { await raffle.enterRaffle({ value: raffleEntranceFee }) await network.provider.send("evm_increaseTime", [ interval.toNumber() + 1]) await network.provider.request({ method: "evm_mine", params: [] }) const tx = await raffle.performUpkeep([]) assert(tx) }) it("revert when checkupkeep is false", async () => { await expect(raffle.performUpkeep([])).to.be. revertedWith( "Raffle_UpkeepNotNeeded" ) }) it("update the raffle state, emits an event, and calls the vrf coordiantor", async () => { await raffle.enterRaffle({ value: raffleEntranceFee }) await network.provider.send("evm_increaseTime", [ interval.toNumber() + 1]) await network.provider.request({ method: "evm_mine", params: [] }) const txResponse = await raffle.performUpkeep([]) const txReceipt = await txResponse.wait(1) const requestId = txReceipt.events[1].args.requestId const raffleState = await raffle.getRaffleState() assert(requestId.toNumber() > 0) assert(raffleState.toString() == "1") }) }) describe("FullfilrandomWord", async () => { beforeEach(async () => { await raffle.enterRaffle({ value: raffleEntranceFee }) await network.provider.send("evm_increaseTime", [ interval.toNumber() + 1]) await network.provider.request({ method: "evm_mine", params: [] }) }) it("can only be call after performUpkeep", async () => { await expect( vrfCoordinatorV2Mock.fulfillRandomWords(0, raffle. address) ).to.be.revertedWith("nonexistent request") await expect( vrfCoordinatorV2Mock.fulfillRandomWords(1, raffle. address) ).to.be.revertedWith("nonexistent request") }) it("picks a winner, resets the lottery, and sends money", async () => { const additionalEntrance = 3 const startingAccountIndex = 1 // 0 deployer const accounts = await ethers.getSigners() for ( let i = startingAccountIndex; i < startingAccountIndex + additionalEntrance; i++ ) { const accountConnectRaffle = raffle.connect(accounts [i]) await accountConnectRaffle.enterRaffle({ value: raffleEntranceFee }) }

              const startingTimeStamp = await raffle.getLastTimeStamp

() await new Promise(async (resolve, reject) => { raffle.once("WinnerPicked", async () => { console.log("Found the event!!") try { const recentWinner = await raffle. getRecentWinner() console.log(recentWinner) console.log(accounts[2].address) console.log(accounts[0].address) console.log(accounts[1].address) console.log(accounts[3].address) const raffleState = await raffle. getRaffleState() const endingTimeStamp = await raffle. getLastTimeStamp() const numPlayers = await raffle. getNumberOfPlayers() const winnerEndingBalance = await accounts[1 ].getBalance() assert.equal(numPlayers.toString(), "0") assert.equal(raffleState.toString(), "0") assert(endingTimeStamp > startingTimeStamp) assert.equal( winnerEndingBalance, winnerStartingBalance .add( raffleEntranceFee .mul(additionalEntrance) .add(raffleEntranceFee) ) .toString() ) } catch (e) { reject(e) } resolve() }) const tx = await raffle.performUpkeep([]) const txReceipt = await tx.wait(1) const winnerStartingBalance = await accounts[1]. getBalance() await vrfCoordinatorV2Mock.fulfillRandomWords( txReceipt.events[1].args.requestId, raffle.address ) }) }) }) })

On Mon, 22 May 2023 at 12:01, Kiflom Adhanom @.***> wrote:

Hi, this my fund me deploy mock contract: const { developmentChains } = require("../helper-hardhat-config") const { ethers } = require("hardhat")

const BASE_FEE = ethers.utils.parseEther("0.25") const GAS_PRICE_LINK = 1e9

module.exports = async function ({ getNamedAccounts, deployments }) { const { deploy, log } = deployments const { deployer } = await getNamedAccounts() const chainId = network.config.chainId const args = [BASE_FEE, GAS_PRICE_LINK]

if (chainId == 31337) {
    log("Local network detected: Deeploying mocks....")

    await deploy("VRFCoordinatorV2Mock", {
        from: deployer,
        log: true,
        args: args,
    })

    log("Mock deployed!")
    log("----------------------------------------")
}

} module.exports.tags = ["all", "mocks"]

keep me update pls On Mon, 22 May 2023 at 11:28, Kiflom Adhanom @.***> wrote:

Hi Girish,

I have just tested my raffle mock deploy contract, it works. Here if you want to compare it:

const { developmentChains } = require("../helper-hardhat-config") const { ethers } = require("hardhat")

const BASE_FEE = ethers.utils.parseEther("0.25") const GAS_PRICE_LINK = 1e9

module.exports = async function ({ getNamedAccounts, deployments }) { const { deploy, log } = deployments const { deployer } = await getNamedAccounts() const chainId = network.config.chainId const args = [BASE_FEE, GAS_PRICE_LINK]

if (chainId == 31337) {
    log("Local network detected: Deeploying mocks....")

    await deploy("VRFCoordinatorV2Mock", {
        from: deployer,
        log: true,
        args: args,
    })

    log("Mock deployed!")
    log("----------------------------------------")
}

} module.exports.tags = ["all", "mocks"]

the command that I use to deploy it is :

yarn hardhat deploy --tags deploy-mock.js

On Mon, 15 May 2023 at 05:09, GIRISH N P @.***> wrote:

Hey bro its been 3 days that I sent u a message in insta u r not responding, stay active there

On Mon, 15 May, 2023, 5:41 am Patrick Collins, @.***> wrote:

Closed #159 https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159 as completed.

— Reply to this email directly, view it on GitHub < https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#event-9240989738 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AYPEWXGV2RDJJCMFSOHOHRLXGFYDLANCNFSM6AAAAAAWUHCASE

. You are receiving this because you commented.Message ID: @.*** .com>

— Reply to this email directly, view it on GitHub https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/159#issuecomment-1547130394, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4HG4OS4NH6HZJFXH323BI3XGGM77ANCNFSM6AAAAAAWUHCASE . You are receiving this because you were mentioned.Message ID: @.***>