Skip to main content

Questions tagged [testing]

questions regarding the testing during development of contracts and DApps

Filter by
Sorted by
Tagged with
0 votes
1 answer
26 views

How to mine on a POS private network

For testing purposes, I source-installed go-ethereum and built a private network. After setting up the genesis.json file, I successfully created a private network, but I don't know how to mine the ...
deuk's user avatar
  • 1
1 vote
1 answer
13 views

TransferFrom Reverted on Foundry Test

I'm trying to create a test for TradingPairExchange contract where the liquidity provider provide his liquidity tokens by using transferFrom and transfer the tokens to the contract. The next step ...
0xhaz's user avatar
  • 15
0 votes
0 answers
14 views

Hyperledger Caliper - Can we build a work load module that can invoke and query from already deployed contract in the blockchain?

I am trying to benchmark a smart contract that interacts with an already deployed contract on the blockchain using Hyperledger Caliper. The overall framework is functioning correctly for other ...
111Seven's user avatar
0 votes
1 answer
21 views

Error in Fork Testing

I ran the test: forge test --fork-url $SEPOLIA_RPC_URL and this error was returned: error: a value is required for '--fork-url <URL>' but none was supplied. // SPDX-License-Identifier: MIT /...
Kwesili Okafor's user avatar
0 votes
1 answer
14 views

How to set Pool Extension for staking function?

Now I am trying to test stake and claimReward function following existing sample codes. StakingPool.sol contract StakingPool is Context, Ownable, ReentrancyGuard { //rest codes function stake(...
Apple-Tim's user avatar
0 votes
1 answer
16 views

Displaying terminal logs while calling a function from a specific wallet in Forge test?

Context As part of a test I would like to assert the funds from wallet investorWallet are reduced with the investmentAmount after an investment is made (by calling the receiveInvestment function in ...
a.t.'s user avatar
  • 79
0 votes
1 answer
44 views

error staging test on sepolia testnet(1) Uncaught error outside test suite)

I'm trying to deploy a smart contract on the sepolia testnet ,so the contract is deployed successfully as seen on the etherscan ,but when im trying to test the contract with staging test by running ...
Divyanshu Madhav's user avatar
1 vote
1 answer
75 views

Hardhat doesn't recognize custom errors from inherited Contracts

I am trying to test TimelockController contract from Openzeppelin using their test. The timelockController imports Address.sol, which has a custom Error called FailedCall. Now for my case, I have ...
Zartaj Afser's user avatar
  • 4,396
0 votes
1 answer
35 views

How I can test smart contract which has logic based on chainId

Dear blockchain developers, I have a ERC20 with restriction of minting only on Polygon chain: // SPDX-License-Identifier: MIT pragma solidity 0.8.23; import "@openzeppelin/contracts/token/ERC20/...
Arkenstone's user avatar
0 votes
0 answers
15 views

Solidity inline assembly custom error revert foundry testing

I have written test cases for the original high level code to test the reverting case of a custome error - ERC20InsufficientBalance(address,uint256,uint256) with the following code: function ...
Xenox's user avatar
  • 1
2 votes
0 answers
16 views

How to Estimate Deployment of a Contract on Mainnet Using Foundry

I'm trying to estimate the deployment cost of a smart contract on the Ethereum Mainnet using Foundry. Can anyone provide guidance or a step-by-step process for making this estimation accurately?
adam mr's user avatar
  • 131
0 votes
2 answers
601 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
37 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
33 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
74 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
3 votes
0 answers
202 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
64 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
44 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
31 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
11 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
1 vote
1 answer
2k 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
28 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
2 answers
378 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
  • 4,396
0 votes
1 answer
231 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
25 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
1 vote
1 answer
351 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
  • 4,396
0 votes
2 answers
37 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
1 vote
1 answer
346 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
  • 4,396
1 vote
0 answers
14 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
33 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
78 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
180 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
  • 436
0 votes
0 answers
26 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
143 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,723
0 votes
1 answer
182 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
76 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
122 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
1 vote
1 answer
29 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
  • 463
3 votes
2 answers
136 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
69 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
290 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
386 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
525 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
108 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
151 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
41 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
54 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,723
1 vote
1 answer
216 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,723
0 votes
1 answer
480 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
  • 109

1
2 3 4 5
14