Error: No Contract deployed with name VRFCoordinatorV2Mock #3613
-
Hoped to solve this one on my own but can't tell what's causing the error. I have checked every question posted but didn't find a solution. Everything looks fine. I also have another test for BasicNft.test.js and that one runs fine. No idea why this can't see the VRFCoordinatorV2Mock. The deployments run without any issue too. I'm using this commad to run the deployments;
I'm writing a test to show the contract deploys successfully but it fails. Test
command
ErrorRandomIpfsNft Unit Tests
1) "before each" hook: runs before every test for "randomIpfsNft deploys successfully"
0 passing (751ms)
1 failing
1) RandomIpfsNft Unit Tests
"before each" hook: runs before every test for "randomIpfsNft deploys successfully":
ERROR processing /Users/k_frankline/projects/hardhat-nfts/deploy/02-deploy-randon-ipfs-nft.js:
Error: No Contract deployed with name VRFCoordinatorV2Mock
at Object.getContract (/Users/k_frankline/projects/hardhat-nfts/node_modules/@nomiclabs/hardhat-ethers/src/internal/helpers.ts:447:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Object.module.exports [as func] (/Users/k_frankline/projects/hardhat-nfts/deploy/02-deploy-randon-ipfs-nft.js:48:38)
at DeploymentsManager.executeDeployScripts (/Users/k_frankline/projects/hardhat-nfts/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1220:22)
at DeploymentsManager.runDeploy (/Users/k_frankline/projects/hardhat-nfts/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1053:5)
at Object.fixture (/Users/k_frankline/projects/hardhat-nfts/node_modules/hardhat-deploy/src/DeploymentsManager.ts:315:9)
at Context.<anonymous> (/Users/k_frankline/projects/hardhat-nfts/test/unit/randomIpfsNft.test.js:13:15)
Error: ERROR processing /Users/k_frankline/projects/hardhat-nfts/deploy/02-deploy-randon-ipfs-nft.js:
Error: No Contract deployed with name VRFCoordinatorV2Mock
at Object.getContract (node_modules/@nomiclabs/hardhat-ethers/src/internal/helpers.ts:447:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Object.module.exports [as func] (deploy/02-deploy-randon-ipfs-nft.js:48:38)
at DeploymentsManager.executeDeployScripts (node_modules/hardhat-deploy/src/DeploymentsManager.ts:1220:22)
at DeploymentsManager.runDeploy (node_modules/hardhat-deploy/src/DeploymentsManager.ts:1053:5)
at Object.fixture (node_modules/hardhat-deploy/src/DeploymentsManager.ts:315:9)
at Context.<anonymous> (test/unit/randomIpfsNft.test.js:13:15)
at DeploymentsManager.executeDeployScripts (node_modules/hardhat-deploy/src/DeploymentsManager.ts:1223:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at DeploymentsManager.runDeploy (node_modules/hardhat-deploy/src/DeploymentsManager.ts:1053:5)
at Object.fixture (node_modules/hardhat-deploy/src/DeploymentsManager.ts:315:9)
at Context.<anonymous> (test/unit/randomIpfsNft.test.js:13:15) 02-deploy-randon-ipfs-nft.js
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
Your unit test is deploying the script with the tag describe("RandomIpfsNft Unit Tests", () => {
let deployer, randomIpfsNft, vrfCoordinatorV2Mock
beforeEach("runs before every test", async () => {
accounts = await ethers.getSigners()
deployer = accounts[0]
// deployer = await getNamedAccounts()
await deployments.fixture(["mocks", "randomipfs"])
randomIpfsNft = await ethers.getContract("RandomIpfsNft", deployer)
vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock")
}) |
Beta Was this translation helpful? Give feedback.
-
@kihiuFrank : Correct this line in your tests : From this : That should make sure, You are getting all the deployments required for the test! |
Beta Was this translation helpful? Give feedback.
-
I got one such error because I've numbered the deploy scripts in wrong order. The Wrong naming:![]() The Right naming:![]() |
Beta Was this translation helpful? Give feedback.
-
change this >> |
Beta Was this translation helpful? Give feedback.
Your unit test is deploying the script with the tag
"randomipfs"
, but the code in that script is looking for the latest deployment ofVRFCoordinatorV2Mock
but can't find it because the mock is not being deploying by the test. Including the"mocks"
tag should fix this error: