Questions tagged [testing]

questions regarding the testing during development of contracts and DApps

Filter by
Sorted by
Tagged with
1 vote
0 answers
10 views

Is it Possible to Run Multithreaded Tasks in Foundry?

I'm looking to run custom tasks/functions in parallel while using Foundry. Specifically, I'm interested in understanding if there's a way to use Foundry's fuzz testing capabilities to achieve ...
MShakeG's user avatar
  • 1,074
1 vote
1 answer
20 views

Is it possible to set a custom start time and block number for a local Hardhat node?

I'd like to configure my Hardhat node to start at a specific timestamp t, where t is less than the current timestamp Tc. The goal is to replay past mainnet transactions locally by setting the exact ...
MShakeG's user avatar
  • 1,074
0 votes
1 answer
70 views

vm.startPrank doesn't change the msg.sender in foundry

While I'm performing the testing in foundry. I'm facing an issue of vm.startPrank doesn't change the msg.sender. CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D); address ...
Saad Suri's user avatar
1 vote
1 answer
14 views

What is the right way to import a contract type that uses an interface in hardhat?

I have a contract with an interface that I want to test with hardhat the contract looks like this interface IGame { function play(uint guess) external; } contract Test { address private owner;...
Eugene1111's user avatar
1 vote
1 answer
26 views

Need help testing my smart contract

I am currently in the process of testing my solidity smart contract using hardhat and am a bit confused on how I should do it. This is the very first time I am testing a smart contract so I am bit ...
EGstacking's user avatar
1 vote
0 answers
18 views

Free functions cannot have function visibility

I am developing my Dapp and as I am trying to compile and test my contract I keep getting an error saying that free functions cannot have visibility and I am very frustrated and confused as to what is ...
EGstacking's user avatar
0 votes
1 answer
24 views

I need 1000 Ethereum wallets for load testing of my project, is there a way i can get that?

I have to test out the functionality of auto reinvest in my smart contract in staking, therefore I need about 1000 Ethereum wallets to test out my code! Please help me out here if there is any ...
Talha Sajid Chaudhary's user avatar
0 votes
0 answers
18 views

Error: call revert exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ]

const { getNamedAccounts, deployments, ethers, network } = require("hardhat") const { developmentChains, networkConfig } = require("../../helper-hardhat-config") const { assert } = ...
PRACHI PATIL's user avatar
0 votes
0 answers
72 views

Guidance on writing a Foundry Test for a deploy script! (Lesson 9: Raffle contract)

I am following the new foundry course by Patrick and was wondering if I could get tips on how to test the deploy script - https://github.com/Cyfrin/foundry-smart-contract-lottery-f23/blob/main/script/...
Philiplima's user avatar
0 votes
1 answer
59 views

Foundry Fuzzing How to increase the runs to be more than default 256

I am testing the Foundry Fuzzing feature. Therefore I created this simple contract: // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Vault { bool public s_locked; uint private ...
Dakata's user avatar
  • 195
0 votes
1 answer
117 views

Why do I get "Nothing to compile" everytime I run forge test -m *testname* on my foundry project?

I always get "Nothing to compile" everytime I run forge test -m testname on my foundry project and I don't know why
joe17ar's user avatar
  • 15
1 vote
1 answer
79 views

How to access the Event args while testing using ethers v6?

I am trying to access an events argument(s) while running tests for my smart contract using node.js/chai. Recently moved to using ethers v6, and the code that works on v5 is no longer valid. Namely: ...
Ahmed's user avatar
  • 11
1 vote
2 answers
569 views

Ethers 6 transaction receipt events information

How i can get event name and params from tx receipt with Ethers 6? I wanna write test to check if event was emitted. Before each beforeEach(async () => { amount = tokens(10) const ...
HideME's user avatar
  • 125
0 votes
0 answers
16 views

Hardhat Errors: Invalid value null supplied to : QUANTITY

Getting this error some times while testing a Hardhat file. But when I cancel that script and run that same script again, it works. The complete error is here: "before each" hook: Before ...
Pankaj Jagtap's user avatar
1 vote
0 answers
9 views

Vyper: How to test internal helper functions?

I'm writing a Roulette contract as a learning activity in Vyper. My contract seems to be working through manual testing, and now I'm starting to write unit tests. I have an internal helper function ...
JoshOrndorff's user avatar
0 votes
0 answers
32 views

Burn ERC1155 from ERC721 Contract

Would like to understand on how burn mechanism works on ERC1155, the ERC1155 is an airdrop token that will be use on GeneratedNFT.sol mint function so that it will to mint an ERC721 token and burn the ...
0xhaz's user avatar
  • 3
0 votes
1 answer
323 views

Getting the error: getAddress is not a function

I am running tests in hardhat and trying to get the contract deployed in the testing environment. Here is the code I am using: const { assert, expect } = require("chai"); const { deployments,...
Chris's user avatar
  • 1
0 votes
2 answers
886 views

Getting the Error: "Could not decode result data"

I am trying to run a FundMe.sol contract test on hardhat and I am getting the following error: Error: could not decode result data (value="0x", info={ "method": "getPriceFeed&...
Chris's user avatar
  • 1
0 votes
2 answers
45 views

Solidity: Contract gets stuck in a for loop (Hardhat local Blockchain)

my smart contract keeps stopping in a for loop while testing with hardhat. Here is the solidity Code: function fulfillRandomWords( uint256 requestId, uint256[] memory randomWords ) internal ...
Bl4d3rR's user avatar
0 votes
0 answers
47 views

How to get the error message from the require statement?

I am using this test contract on Remix IDE // SPDX-License-Identifier: MIT pragma solidity 0.8.0; contract testfunction{ function test() public pure{ require(false,"Testing ...
sounxk's user avatar
  • 1
1 vote
1 answer
22 views

Smart Contract Testing of Crowd Funding

Hi Iam new in solidity program i don't know how to test the donate function can anybody help me how to test? Actually I want to test when some donate the donater balance is minus and the person who ...
Yasir Saeed's user avatar
0 votes
2 answers
122 views

Testing ERC20 Token: Unable to cover Transfer and Approve from null/zero address

I'm working on a project using Hardhat and OpenZeppelin library for an ERC20 token. I've been able to achieve almost 100% coverage, but there are two lines that I'm struggling to cover: transfer ...
pridegsu's user avatar
  • 111
0 votes
2 answers
78 views

Hardhat test error, missing argument in contract constructor

okay, I have edited my test file and now I am getting an entirely different error. ERROR 1) BCCasino tests "before each" hook for "..should deploy correctly": ...
Shawngilbert107's user avatar
0 votes
0 answers
123 views

Cannot read properties of undefined (reading '0')

I am following FreeCodeCamp's javascript Blockchain/SmartContract course. Facing issue at lesson 9 staging test. Contract deployment and unit tests are running fine. Running mocha test on sepolia ...
mohmaya's user avatar
0 votes
0 answers
86 views

Trying Uniswap V3 Swap Example - Error: Transaction reverted: function call to a non-contract address

Have been getting bellow error message: SwapExamples swapExactInputSingle: Error: Transaction reverted: function call to a non-contract account at SwapExamples.swapExactInputSingle (contracts/...
EMintela's user avatar
0 votes
1 answer
61 views

What is the best way of setting limits of fuzz test input parameters in Foundry?

Let's take an example, where we have a stake function, with the stake's endTimestamp in uin64. function stake(uint256 amount, uin64 endTimestamp) It is assumed endTimestamp should never be less than ...
Nal Luksic's user avatar
  • 1,039
1 vote
0 answers
18 views

Contract is not deploying locally while testing for testcases

I am trying to write test cases for my code, here the MockV3Aggregator is supposed to run locally, upon deploying it works fine but when I try to only run the test case it seems that the ...
kaushik choudhury's user avatar
0 votes
1 answer
22 views

How to assert that a BigNumber is included in a list of numbers?

I am trying to assert a uint256 the following way: expect(tokenType).to.be.oneOf([1, 2, 3, 4]); I just want to check that its value is any of the ones on that list, as I am using a ...
Falcon Stakepool's user avatar
0 votes
0 answers
14 views

Request testnet ETH and LINK tokens for the Sepolia testnet [duplicate]

I am trying to get a sepolia test link from faucets.chain.link, I have inserted my wallet address, I have selected the Request type (0.1Eth), I have verified that i am human; But the send request ...
ndifreke Etukudo's user avatar
1 vote
1 answer
158 views

How to test a function that returns array type struct using Foundry

I'm a beginner with Solidity, and I'm working on a smart contract that mints an NFT and stores relevant information inside a struct. The issue I'm currently facing is that when testing the ...
David Jay's user avatar
  • 301
0 votes
0 answers
11 views

Not able to dynamically assign values to array

I am testing the correct emission of NFTMintedAll event on the following function, using hardhat: event NFTMintedAll( uint256 requestId, address indexed owner, uint256[] ...
Falcon Stakepool's user avatar
0 votes
1 answer
23 views

Is it possible to load contracts in hardhat genesis block?

I am trying to test certain aspects of BSC chain. I need some system contracts, which I can't easily deploy to other addresses without breaking the whole existing system. Is it possible to add ...
Shocky2's user avatar
  • 131
2 votes
0 answers
56 views

Can not sign transaction with signer get from mnemonic

I'm writing test for MAX_SUPPLY of this function // contract.sol function mintStandard() public payable whenNotPaused { require( _standardCounter.current() <= 2222, &...
dtnwen's user avatar
  • 33
1 vote
3 answers
161 views

Simple OpenZeppeling mockCoin for local testing, Mint function gets stuck in testing

I have a very simple smart contract for a MOCK coin where I need a mint function to be able to be run by any address as it is just for testing. I took the code from OpenZepplin and removed OnlyOwner. /...
Robert Mazurowski's user avatar
0 votes
0 answers
54 views

TypeError: Cannot read property 'JsonRpcProvider' of undefined

I get this error when I run npm hardhat test on my sample-test.js file and I have no idea why it happens, here is the test code file: // Import the necessary dependencies const { expect } = require(&...
Eyad Ahmed's user avatar
0 votes
0 answers
35 views

Foundry fuzzing fails and then passes when parameters are hardcoded

The following test will fail a fuzz test but then works when the same args are hardcoded. function testOverflow(uint256 a, uint256 b) public { // UINT256_MAX = ...
user10110100's user avatar
0 votes
1 answer
353 views

Trying to `forge init` in Foundry but getting below error. Also tried to `git commit -a` but then also its not solving the problem

$ forge init Error: The target directory is a part of or on its own an already initialized git repository, and it requires clean working and staging areas, including no untracked files. Check the ...
Coollaitar's user avatar
0 votes
1 answer
20 views

How to you write tests for the transferFrom function for my ICO contract?

I want to write a test for the transferFrom(). I'm doing it by checking that the address balances change after the function is called. When I run the test, I get the error below. It's caused by the ...
kihiuFrank's user avatar
0 votes
2 answers
236 views

How to configure custom ethereum node in foundry project?

Hardhat allows users to configure a custom network in the networks configuration object. This allows developers to run their JS/TS test suites against another local node such as Ganache or even a live ...
MShakeG's user avatar
  • 1,074
0 votes
1 answer
70 views

Why my test is failing here?

I am writing a test for checking a upgradable contract: function test_Proxy() public { vm.startPrank(address(user)); // checking is non-owner address can call the upgradeTo() or not ...
Hacek 's user avatar
  • 645
1 vote
1 answer
146 views

Error: Transaction reverted: function call to a non-contract account when calling flashLoan on balancer

I have forked the polygone mainnet in hardhat and when I call the makeFlashLoan function in my test I get the following error. Error: Transaction reverted: function call to a non-contract account Here ...
Mubashir Waheed's user avatar
0 votes
0 answers
60 views

Mocha Tests unexpected error

My tests where running well but not when I run yarn hardhat test, I get the error below. Error An unexpected error occurred: TypeError: describe is not a function at Object.<anonymous> (/...
kihiuFrank's user avatar
0 votes
0 answers
132 views

AssertionError: expected not equal to actual

here I have a written a code for testing a fund function this is the code snippet describe("fund", async function () { it("it fails when you dont send enough money", async ...
jeevan siddu's user avatar
0 votes
1 answer
202 views

Getting Fail with error 'ERC20: insufficient allowance'

First I'm deploying Cafe contract and get deployedId from it and then deploy CAFToken contract with deployedId of cafe contract. I've also added deploy script and test case, I guess everything is ...
Akshar Prajapati's user avatar
1 vote
0 answers
50 views

Is VRFCoordinatorV2Mock working on mainnet forking or only in local network?

I'm testing my contracts, where I use Chainlink's VRF. I use the mainnet forking in a hardhat. I deployed VRFCoordinatorV2Mock, although it doesn't seem to work. Is VRFCoordinatorV2Mock supposed to ...
cutedwannabe's user avatar
2 votes
1 answer
199 views

How to compare before and after balance of any address in while testing in hardhat?

I was writing test script for a contract. I am stuck at a point where there is a claim function. whenever a user calls it, he gets the claimable ether, whatever available. The problem is when I ...
Zartaj Afser's user avatar
  • 1,257
0 votes
2 answers
48 views

Enhancing testability of contracts with immutable state variables

I have been encountering challenges when testing contracts that utilize immutable state variables. As we know, immutable variables are assigned only once during contract deployment and cannot be ...
Ahmed Ihsan Tawfeeq's user avatar
0 votes
0 answers
39 views

Hardhat Chai expect to.be.reverted fails on reversion

I have a basic ERC contract with the user deployer that is owner and only has rights to mint. The mint function has an "onlyOwner" modifier with no message sent when reversion is triggered ...
Gnostication's user avatar
0 votes
1 answer
267 views

Goerli ETH - Where get funds [duplicate]

I'm doing my computer engineering final degree work on Ethereum development. I am having a lot of problems to get GoerliETH, how do you guys get funding from testnets to develop your projects? If ...
Marc Gonzalez Amores's user avatar
1 vote
1 answer
46 views

Hardhat deploys contract to 2 different contract addresses while deploying uniswap clone

I am learning about writing tests with Hard Hat and using fixtures, but I am having the strangest issue when deploying a uniswap clone. My deployWETH fixture consistently returns the same contract ...
Jared Hodgkins's user avatar

1
2 3 4 5
13