Questions tagged [testing]

questions regarding the testing during development of contracts and DApps

Filter by
Sorted by
Tagged with
0 votes
2 answers
38 views

Does Uniswap allow testing swap on testnets?

I am testing my smart contract on goerli testnet. Everything is working. After I complete adding an LP when I want to test whether it is able to swap, the system keep showing "Insufficient ...
yaoyao's user avatar
  • 1
0 votes
0 answers
15 views

Hyperledger-caliper Ethereum Benchmarking (Error: nonce undefined)

I am using hyperledger-caliper to benchmark the Ethereum local network (Ganache). The contract is a simple storage contract, nothing fancy. I can deploy the contract using the code provided below. But ...
111Seven's user avatar
0 votes
1 answer
26 views

Does Integration-Testing can be done in local blockchain using Hardhat?

I'm currently working on a project where I need to perform integration testing involving a third-party contract. This contract is part of a library that I've included in my project as a git submodule ...
codekoriko's user avatar
0 votes
2 answers
49 views

How to use native token as fee in CCIP local unit tests?

Setting up unit tests for CCIP with the LINK token as the fee token is successful, but how can the same thing be done using native tokens such as ETH as the fee token? For example, here is part of the ...
palmcivet's user avatar
2 votes
0 answers
78 views

How to mock smart contract with hardhat and ethers v6

I found here 2 ways to mock Smart contract but they all limited to ethers.js v5: @nomiclabs/hardhat-waffle @defi-wonderland/smock Today hardhat-toolbox is at version 4 and migrated away from hardhat-...
codekoriko's user avatar
2 votes
0 answers
49 views

How to Statefully Fuzz in Foundry without Invariants?

I want to Statefully (not Statelessly) Fuzz my Protocol. However, I don't have any Invariants to check. I just want to call all of my Protocol's functions, and see if anything breaks. This is my ...
António Gonçalves's user avatar
0 votes
0 answers
17 views

Error in plugin solidity-coverage: TypeError: Cannot read properties of undefined (reading 'match')

when running yarn hardhat coverage, it compiled the solidity files successfully and then gave the following error message: Error in plugin solidity-coverage: TypeError: Cannot read properties of ...
Liron Achdut's user avatar
0 votes
1 answer
9 views

Weird bug when testing contract in foundry

I am creating a ERC20 token solidity contract and when writing tests I encountered a problem. Here is a function I use to test the token cap with. function testTokenCap() public { uint256 ...
stitas's user avatar
  • 1
0 votes
0 answers
7 views

Is it possible to verify that an event is not emitted in Hardhat tests?

I know that it's possible to check for emitted events in a call in Hardhat using .to.emit method. Is there a way to make sure that an event should not be emitted in a call? For example I may want to ...
mahdi's user avatar
  • 178
0 votes
1 answer
543 views

Instead change the require of chai.js in to a dynamic import() which is available in all CommonJS modules

.js file const { expect } = require('chai'); describe("Token contract",function(){ it("Deployment should assign the total supply of the owner", async function(){ const[owner] =...
Vaibhav_01's user avatar
0 votes
0 answers
25 views

Testing incrementation in Foundry

Currently testing my smart contract using Foundry and I believe it is going pretty well. However, I have some incrementation going on in my smart contract program which is an NFT Marketplace and I am ...
EGstacking's user avatar
4 votes
1 answer
143 views

How to use forge coverage effectively?

I am trying to get the test coverage for our Smart Contracts. Couple of questions I have. While running the coverage command, it doesn't include all the test cases in the folder, is it because we ...
Zartaj Afser's user avatar
  • 3,239
0 votes
1 answer
60 views

Forge Testing issue

I am looking to get some tips and advice for my smart contract testing as I am a bit stuck. I am currently using Foundry to test my smart contract for my NFT Marketplace project however since I am ...
EGstacking's user avatar
0 votes
1 answer
17 views

Facing Issue with test files in Hardhat

I am trying to build a Dapp with hardhat installed in my vs Code my smart contracts parts are over and it gets compiled but I am facing a problem with test files I don't know why they are not getting ...
Abhik Chanda's user avatar
2 votes
1 answer
121 views

`vm.expectRevert` is not working as expected in Foundry

Here is the file I am working with SubscribeBySig.t.sol . You can replicate the scenario by cloning the above repo, switch to the 230-migrate-comm-unit-tests branch and run forge test. The problem is ...
Zartaj Afser's user avatar
  • 3,239
0 votes
2 answers
26 views

problem with reverted when testing smart contract

In my smart contract there is a function: function fund() public payable { require( msg.value.getConversionRate(priceFeed) >= MINIMUM_USD, "You need to spend more ETH!"...
vinh nguyen's user avatar
0 votes
0 answers
16 views

Learning to test

I am currently learning how to test SC with foundry and I feel with each different contract that I test that I really don't learn anything, any study recommendations?
David Antunez's user avatar
2 votes
1 answer
140 views

How to generate a signature in foundry if Private key is a string?

I have been testing some contract that includes EIP712 signatures, with foundry. As per this doc we need to pass the private key which is being accepted as a uint256. (uint8 v, bytes32 r, bytes32 s) = ...
Zartaj Afser's user avatar
  • 3,239
1 vote
0 answers
10 views

Why are my exceptions rendered differently after versions update?

I don't remember the previous versions I was using but I remember upgrading because I hoped to have a local test network (via Ganache) supporting EIP-1559. My versions are: Truffle v5.11.5 (core: 5.11....
Luis Masuelli's user avatar
0 votes
1 answer
31 views

[Hardhat]: Passing ether to function during call cause an error to be triggered

I have this test suite written with Hardhat it('Should reveal bid', async () => { const { blindAuction, bidder3, bidData } = await loadFixture( deployBlindAuctionFixture ...
lilpolymath's user avatar
0 votes
1 answer
20 views

How to advance blocks in a Hardhat test that uses block.timestamp?

I have this code for a Voting smart contract test: it("Should return true if end time is less than the current timestamp", async function () { const { votingSmartContract } = await ...
Falcon Stakepool's user avatar
1 vote
2 answers
102 views

Foundry Test for a function with array of structs

I have this foundry function and I don't have any idea how to pass an array of structs to batchList function function test_ListMockERC721() public { vm.prank(add1); erc721Mock.mint(msg.sender);...
Catalin's user avatar
  • 426
0 votes
0 answers
23 views

VRFV2Wrapper::onTokenTransfer reverts, although it shouldnt

I'm trying to test a contract "BrewBurner" which inherits VRFV2WrapperConsumerBase and should receive a a callback to the fulfillRandomWords() function. I deploy all the contracts on the ...
itsPinkDev's user avatar
0 votes
1 answer
93 views

How to Specify an Acceptable Range or Ignore a Field When Testing Event Emissions in Foundry?

In a foundry project I encountered a scenario where I need to test the emission of an event with specific conditions. My requirement is either to check if a field in the emitted event falls within a ...
MShakeG's user avatar
  • 1,593
0 votes
1 answer
93 views

Extracting input data when writing Forge tests/POCs

I would like to write a test in Foundry but I need to be able to first read data from a previous transaction that was submitted in some point in the past. For example, the transaction I'm interested ...
SKA's user avatar
  • 47
0 votes
0 answers
72 views

What is causing Arithmetic over/underflow when LINK.transferFrom() is called for ccipSend() fees?

I'm trying to write unit tests for a CCIP Sender contract. ccipSend() on the Router is called and this line appears to be where things stop working: IERC20(message.feeToken).safeTransferFrom(msg....
palmcivet's user avatar
1 vote
1 answer
97 views

When testing Chainlink CCIP with Router.sol, what address should the onRamp be?

I'm trying to write unit tests for a Chainlink CCIPSender contract, but as far as I can tell it is reverting when calling getFee() to pay for the transaction. In my test I call applyRampUpdates() from ...
palmcivet's user avatar
0 votes
0 answers
21 views

Set forge fuzz.runs in github CI tests

I have a test using forge like so: /** * Reduce fuzz runs. * forge-config: default.fuzz.runs=10 */ function testMyThing(uint256 rng) external { // ... } When I run ...
Milk's user avatar
  • 421
3 votes
2 answers
101 views

assertEq() fails on seemingly same strings

I have a simple contract that just sets a string private state variable in contract's slot 1. Below, I write a test that is supposed to set that private string variable to a new value and then I go in ...
SKA's user avatar
  • 47
0 votes
1 answer
49 views

Send Function is not working in test file using ethers.js

I write a wallet smart contract in which one address can send ethers to other addresses. I'm using the HardHat framework and this package. when i use await addr1.sendTransaction( {to: addr2, value: ...
Huzaifa Ahmed's user avatar
0 votes
1 answer
148 views

HardhatError: HH700: Artifact for contract "Lock" not found

If I run yarn hardhat test. I'm getting this error: yarn run v1.22.19 warning ../../../package.json: No license field $ /Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/.bin/hardhat ...
Deepak Chaudhary's user avatar
0 votes
2 answers
157 views

vm,prank(address) not working as msg,sender in Foundry [duplicate]

I have a function in contract A given as-> function fun() public view returns (address) { return msg.sender; } } I was testing this function in foundry as-> ...
Divyansh Gupta's user avatar
0 votes
1 answer
326 views

TypeError (0, ethers_1.getAddress) is not a function

I keep getting this TypeError(0, ethers_1.getAddress) is not a function while running my test for my smart contract and I am very confused on how to solve it. On top of that, for my create listing ...
EGstacking's user avatar
0 votes
0 answers
63 views

MetaMask app/browser SSL Error (local server HTTPS testing)

Creating a dApp using Vite; within the config file I've imported mkcert to produce SSL certs. I've also installed these on my mobile device. I have no issues at all using the website/dApp in Chrome (...
HAT0ken's user avatar
0 votes
1 answer
103 views

Problem with testing mappings and structs in foundry

Hey everyone I'm using foundry for solidity development and I have some issues with using mappings and structs in my tests. here are my problems: Problem 1 the problem : the function below lets users ...
emtothed's user avatar
1 vote
0 answers
37 views

How to get transaction fees and minus it from balance

I created an auction exchange smart contract using solidity programming language and I am using ganache for testing this is a test file written in JavaScript. seller is the creator of auction and ...
Huzaifa Ahmed's user avatar
1 vote
0 answers
42 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,593
1 vote
1 answer
110 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,593
0 votes
1 answer
292 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
40 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
53 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
22 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
26 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
20 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
1 answer
301 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
280 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
  • 205
0 votes
1 answer
471 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
2 votes
2 answers
496 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
  • 21
2 votes
2 answers
3k 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
  • 135
0 votes
0 answers
91 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
2 3 4 5
14