Questions tagged [testing]

questions regarding the testing during development of contracts and DApps

Filter by
Sorted by
Tagged with
0 votes
0 answers
16 views

Staging test is getting timeout error on rinkeby network: Chainlink VRF and Keeper Issue

I am following Patrick Collins course. At chapter 9, when we do a testnet test on rinkeby. The event is not firing. I am using chainlink Keeper and VRF to run the the code as detailed below. Console ...
user avatar
1 vote
0 answers
8 views

Why Is HardHat Mainnet Fork Always Behind By Roughly 5 Blocks?

Whenever I do a fork on mainnet at latest with hardhat, it's never at the latest block. Why is that? For example in the below: console.log("BLOCK FRO ALCHEMY: ", (await ...
user avatar
0 votes
0 answers
13 views

hardhat & waffle - deploy a contract from an address

I'm trying to test a factory contract using hardhat and waffle. I have a contract called Domain: //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "hardhat/console.sol"; ...
user avatar
0 votes
0 answers
12 views

How would I access a variable defined in solidity from my `JS` script

I am trying to write test for a function addPerson() that takes stirng name and uint256 favNumber and creates a People object and add it to the people list, this addPerson() is defined in Solidity and ...
user avatar
0 votes
1 answer
43 views

UNIT Test Error: No Contract deployed with name Raffle

This is the section of my unit testing... I've been working on this problem for the last few hours. I couldn't, however... I think the error is in const { deployer } = await getNamedAccounts() this ...
user avatar
0 votes
0 answers
15 views

solidity-coverage giving wrong report

The first time I ran npx hardhat coverage it hadn't removed the files that should be ignored and I got this result, which is correct. But after I added this to .solcover.js: module.exports = { ...
user avatar
  • 331
1 vote
1 answer
22 views

evm_increaseTime in hardhat

Ive seen people use examples of increasing the time of hardhat for time deoendent functions using evm_increaseTime in a test, but how can i manually do this? Im not even sure what file im supposed to ...
user avatar
0 votes
0 answers
8 views

Brownie Stateful Testing

I currently decided to up my test game by going into property based tests and stateful tests on brownie using hypothesis and state machines. In the brownie documentation on stateful tests. In the ...
user avatar
0 votes
1 answer
12 views

How should I approach testing functions that call already deployed contracts? [ethers.js] [chai] [mocha]

Suppose my contract utilizes the WETH contract (address 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) in some manner. I can write test cases with Chai/Mocha just fine for most cases (they're "...
user avatar
0 votes
2 answers
120 views

[SOLVED]PatrickCollins Solidity Course 2022 - Lesson 7: 11:20:38 -> TypeError: ethers.getContract is not a function

AssertionError: Expected transaction to be reverted with You need to spend more ETH!, but other exception was thrown: Error: Transaction reverted: function returned an unexpected amount of data I was ...
user avatar
0 votes
0 answers
22 views

EVM RPC Test Suite to test proper implementation of JSON-RPC Specifications

I'm looking for an existing and still supported EVM RPC Test Suite to test if a custom RPC implementation is in line with the official JSON-RPC Specifications. I'm not looking to build my own suite, I ...
user avatar
1 vote
1 answer
19 views

Hardhat chain fork on the test rather than config file

I saw that it is possible to test with Hardhat on a forked chain, via the config file. Is it possible to do it on the test file instead? In a beforeEach, maybe. I only want some of my tests to run on ...
user avatar
0 votes
0 answers
15 views

Is there a way to mock ExternalProvider with testnet RPC link?

I'm making simple swap service and I would like to write unit tests for my swapping class. I would like to know if there is a way to mock ExternalProvider so to use real testnet url and real wallet. I'...
user avatar
  • 11
0 votes
0 answers
21 views

Redeploy contract after each test case

I'm using hardhat for testing contract and what I've noticed when I was testing pause and unpause - that beforeEach doesn't actually redeploy contract from It to It, so if in the first It I pause ...
user avatar
0 votes
1 answer
23 views

How to mock an instance of an interface?

Having these interfaces interface IERC20 { function totalSupply() external view returns (uint); function balanceOf(address account) external view returns (uint); function transfer(address ...
user avatar
0 votes
1 answer
24 views

What are the kind of unit tests or tests in general that needs to be done on the following smart contract?

https://gist.github.com/shobhitic/44f1d88c58b8c80d431e156654167d0d I am super new to testing so I am not entirely sure how to frame this question but what are the tests that should be done on a smart ...
user avatar
0 votes
0 answers
57 views

hardhat test console.log does not work

I'm trying to test one contract using console.log, but it does not work, the outcome its always the same, 0 passing... any help out there. i tried to use hardhatclean but did not work. im using the ...
user avatar
0 votes
2 answers
27 views

How do I change addresses while testing in HardHat?

I'm attempting to setup some fairly comprehensive testing of a Solidity contract I wrote using hardhat & waffle, etc. One of the things I want to do is things like mint using various addresses ...
user avatar
  • 1
0 votes
2 answers
71 views

"Invalid signature" error in ERC20Permit (EIP2612)

I use ERC20Permit token extension contract from openzeppelin for approval via signatures. In tests (hardhat testnet), I use ethers and signing typed data as described here: Ethers Signers. So the ...
user avatar
0 votes
1 answer
22 views

How to test the Solidity-By-Example Mapping smart contract in Remix?

I want to test the following code in Remix. But what is the procedure? What do I put in the input field for the function labeled set? Mapping.sol // https://solidity-by-example.org/mapping // Mapping /...
user avatar
  • 189
0 votes
1 answer
60 views

Truffle Test Console Logging

I'm having some trouble with Truffle logging configuration. During tests, each submitted transaction and its hash is logged on the console and this one becomes full of useless messages that disturb ...
user avatar
0 votes
0 answers
47 views

Hardhat mumbai forking is throwing ConnectTimeoutError

I've started to learning Chainlink and made a simple contract that query a Data Feed ETH/USD, as you can see in details in this repository: https://github.com/fabianorodrigo/chainlink-experiments. ...
user avatar
  • 43
0 votes
0 answers
95 views

How do I set the allowance for ERC20 tokens in Foundry?

In the following minimum viable test I'm failing to mock the allowance so that the ReceiverContract can transfer ERC20 tokens. The expected use-case would be a user (=externally-owned account) ...
user avatar
0 votes
0 answers
29 views

Testing require failures and events with HardHat

There are two things I want to do with Hardhat that I cannot figure out. The first is having a test pass when the "require" logic inside my contract causes a transaction to fail. As a ...
user avatar
1 vote
1 answer
144 views

Comparing ethers BigNumber does not work

I'm testing the value of a BigNumber returned from a function call to a contract and its not working as expected. I have this const { BigNumber } = require('ethers'); ... const totalSupply = await ...
user avatar
0 votes
0 answers
19 views

Test Multi-chain interactions hardhat tets

Is there a way to spin up two separate local instances and interact with them via hardhat tests? e.g. let token1 = await token.deploy({network:"localhost:8545"}); let token2 = await token....
user avatar
  • 3,274
0 votes
1 answer
327 views

Hardhat + Waffle + Hardhat: Nonce has already been used

This week at a talking by our friend Patrick Collins during the Chainlink Spring 2022 Hackathon schedule, I took knowledge of the possibility of moving ahead of time on the blockchain during tests: ...
user avatar
  • 43
0 votes
1 answer
29 views

I can't figure out why my test dont pass

I always get this an error when i run my test, i dont know what to do anymore you can test at my repository on github here
user avatar
0 votes
1 answer
202 views

Set deployer address in Hardhat tests

I am using HardHat to write some unit tests. This part is related to deploying the contract, though I am not seeing how hardhat set address of deployer here. Say we have these addresses: let user1: ...
user avatar
  • 105
0 votes
2 answers
47 views

Best testing Ethereum practices

My team recently starting learning Ethereum and smart contracts. Wanted to ask what are the best practices for testing. I have read about creating private networks: Can we have our own private ...
user avatar
0 votes
1 answer
870 views

Error: Transaction reverted without a reason string

I am trying to write test for erc20 token and when I try to revert the transaction if the sender has insufficient balance, it is throwing an error. Solidity code for transfer function function ...
user avatar
1 vote
1 answer
165 views

How to test recoverSigner and splitSignature

I am currently trying to test a function that uses a recoverSigner inside and I'm not sure how to proceed. Here is the function: function claimToken(bytes32 message, bytes memory _signature, address ...
user avatar
0 votes
1 answer
345 views

What are the good (and active) faucets for Rinkeby? [duplicate]

I am new to BlockChain Development and currently working on Smart Contracts. Can I know a place where I can get Test ETH to be used with Rinkeby please? https://faucet.rinkeby.io/ is offline and other ...
user avatar
  • 101
3 votes
1 answer
160 views

How to test if msg.sender is equal to 0x0

I am trying to write a test for one of my smart contract functions but I'm finding it difficult to change the value of msg.sender to 0x0. I know that msg.sender's value is gonna be the address that ...
user avatar
0 votes
1 answer
39 views

Solidity function // for loop

Im calling in a for loop a set function in js, but it stops/crashes after the 2nd or 3rd loop. I want to run it for about 5000 times, without losing queue. Is it possible? How can i implement this? I ...
user avatar
0 votes
0 answers
27 views

Check if a function does not exist in chai

I'm using chai to test my contracts. I have a test that calls a function that does not exist in that contract. This is the contract: // SPDX-License-Identifier: MIT pragma solidity 0.8.13; import &...
user avatar
0 votes
2 answers
73 views

How can I pass an amount with the gas fee and msg.value in solidity unit test

Id like to test this function of buyTokens but i can't figure out how to pass the amount of tokens as argument This is the test contract Function to be tested
user avatar
0 votes
1 answer
39 views

Is Waffle an obsolete library?

I was always using web3 for anything but now it looks like ethers is more suitable for my needs so I'm playing with it. I'm using hardhat for testing as probably all of us, and I found out that in ...
user avatar
0 votes
0 answers
8 views

What bugs are revealed by testing in a multi-node environment vs a single node environment?

It's recommended practice to generally deploy to a public testnet before deploying to mainnet. I am confident in my unit tests (that are running against ganache). a. Is there a benefit to testing my ...
user avatar
  • 101
0 votes
0 answers
17 views

Testing problems (updated variables go to another "it" block)

Problem with testing. Usually when I tested contracts, each "it" block created like a new statement (and variables) of contract (from scratch). But in this contract after each "it" ...
user avatar
  • 59
1 vote
1 answer
28 views

How can i test this solidity contract for(lets say) 5000 calls of the set function(.sol or .js)?

// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; contract storeData { uint256 internal index = 0; struct IslandFcst { uint islandId; uint forecastDate; ...
user avatar
0 votes
0 answers
58 views

How do you separate development environments between networks?

I'm utterly confused at how to properly navigate certain aspects of the development workflow between ethereum networks. How I understand it: network <-> front-end dapp LOCAL: hardhat localhost (...
user avatar
0 votes
1 answer
20 views

My variable can't be seeing in testing

Why when I'm trying to use acdmToken instance in "it" block, programm can't see it (undefined)? TypeError: Cannot read property 'balanceOf' of undefined Since I declared it on beforeEach. ...
user avatar
  • 59
0 votes
1 answer
451 views

How to use HardHat tasks directly from the code (and tests)

I'm starting to use HardHat for my project and I created a list of (super useful) tasks ans now I'm trying to implement tests and I want to use some task (like deploy to setup my smart-contract ...
user avatar
  • 154
1 vote
0 answers
30 views

Failing to run/build fresh dapptools project after importing Uniswap v3

Am i missing something simple here =[ ? I tried to mimic what was done here as per the docs. Exception fatal: cannot change to 'lib/v3-core/src': No such file or directory child_process.js:661 ...
user avatar
  • 111
1 vote
1 answer
230 views

How to spoof accounts using Foundry?

Currently using Foundry & Hardhat for development, Foundry for testing & Hardhat for deployment. I'm trying to fuzz a test input of a function that adds an address to a whitelist and I need a ...
user avatar
  • 45
0 votes
2 answers
66 views

Testing against local network vs testnet

I have a simple test to mint tokens on a newly deployed contract. While developing, I was testing locally and the test never failed. Now that the contract is deployed to the testnet, I get a 50% ...
user avatar
  • 103
1 vote
0 answers
17 views

Writing tests for a contract function that uses a struct

I have a contract that implements an interface which contains a struct that is used in both the arguments to a function as well as the return value. // IContract.sol interface IContract { struct ...
user avatar
0 votes
0 answers
28 views

Issue in test-environment install

I tried to install test-environment, it throws the error. Please advice on how to solve this. npm ERR! enoent undefined ls-remote -h -t https://github.com/ethereumjs/ethereumjs-abi.git PS E:\...
user avatar
  • 623
1 vote
2 answers
1k views

How to get more than 20 Signers with ethers.js / hardhat / waffles

I'm using Hardhat with the waffle plugin to test my smart contract. To get Signers (ether.js) I'm using : await ethers.getSigners(); This return an array with 20 signers. If I call again, I get the ...
user avatar

1
2 3 4 5
10