Skip to main content

Questions tagged [waffle]

The tag has no usage guidance.

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

Hardhat, problem with uninstalled dependencies

I can compile my contracts successfully. I had some problems with some of the hardhat functions so i installed Waffle and its dependencies. However it doesn't work and throws an error stating missing ...
אליה שלמה's user avatar
0 votes
1 answer
232 views

typeError: Cannot read properties of undefined (reading 'format')

I am getting this error whenever I run my hardhat deploy script for uniswap pool contract : TypeError: Cannot read properties of undefined (reading 'format') at Function.from (/home/abdulaleem/token/...
Abdul Aleem's user avatar
0 votes
2 answers
296 views

Testing contract selfdestruct in Hardhat - Chai matchers

I'm writing unit tests for a solidity contract in a Hardhat project and I can't seem to find a selfdestruct matcher. Solidity Chai Matchers are a set of helper functions that make testing solidity ...
Adham's user avatar
  • 181
0 votes
0 answers
53 views

Sending eth while testing a smart contract

const sendEth = ethers.utils.parseUnits("0.1") describe("fund", async function () { it("update the amount funded data structure", async function () { const ...
Yana Gupta's user avatar
1 vote
1 answer
3k views

Getting an error of : "TypeError: Cannot read properties of undefined (reading 'provider')"

I am getting this error TypeError: Cannot read properties of undefined (reading 'provider') Here is my code for buy-coffee.js inside of scripts. // We require the Hardhat Runtime Environment ...
Abhishek Bhagat's user avatar
1 vote
1 answer
346 views

Testing BigNumber values in Hardhat unit tests the safest way?

I have seen at least three different ways to test two BigNumbers. Using waffle BigNumber Convert toString() Cast to Number As an example hardhat test with chai and waffle. const sendValueBN = ethers....
Viggos's user avatar
  • 131
1 vote
0 answers
35 views

Waffle revertedWith() matcher docs misleading?

In the Waffle documentation here, it shows that revertedWith() can be used with a regular expression. When used I am presented with an error claiming otherwise, already wasted too much time on this ...
7FigureSwagger's user avatar
0 votes
1 answer
548 views

Hardhat tests - deploy with arguments [typescript]

I am writing tests for my contract in typescript. I am deploying the contracts like this: import { Contract } from "../typechain-types/index"; import ContractArtifact from "../artifacts/...
David's user avatar
  • 153
1 vote
2 answers
454 views

to.be.revertedWith("Error Message ") returning failed test despite custom error matching "Error Message"

I'm running tests on a raffle smart contract from Patrick Collin's tutorial. I have custom errors in my Solidity file. When running tests that expect the transaction to be reverted, every single time ...
David Kong's user avatar
3 votes
2 answers
559 views

Override mock contracts's address in test

I have a smart contract that is dependent on a pre-deployed ERC-20 smart contract that is always deployed to the same address (in the local test network as well as public ones). I want to override the ...
OneThunder's user avatar
0 votes
2 answers
195 views

Migrating from Waffle

sorry for a newbie question. I have a file from my study with the following code: const { expect, assert } = require("chai"); const { ethers } = require("hardhat"); const { ...
Viktor Cortez's user avatar
0 votes
1 answer
218 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"; ...
David J.'s user avatar
0 votes
1 answer
931 views

Unable to transfer eth into contract in hardhat

I am working on some ERC20 tokens in which user have to send it to get tokens, i am getting some error while running it!! i am stuck at the const txHash = await addr1.sendTransaction({ to: ...
DereK's user avatar
  • 294
0 votes
1 answer
313 views

Solidity: Mock function return value

I'm writing an ERC-721 contract but I'm struggling to write a proper unit test when all token ids are minted. Function I want to test: uint256 public constant MAX_SUPPLY = 10000; function ...
rpajunen's user avatar
1 vote
2 answers
605 views

How do I tell hardhat and waffle where my test is?

I created a basic hardhat sample project. When I do npx hardhat test , Hardhat is running the out of the box test in scripts/sample-script.js (which supposedly is the deployment pipeline) and hardhat ...
GUZZ's user avatar
  • 51
4 votes
2 answers
4k views

How to mock smart contract function for testing (in hardhat)

In my Test I want to mock an external function that I call inside my smart contract to test both conditions without writing and deploying an extra fake smart contract. My Contract //SPDX-License-...
Majd TL's user avatar
  • 3,237
1 vote
1 answer
3k 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: ...
Fabiano's user avatar
  • 183
1 vote
1 answer
1k views

Hardhat/Waffle/Chai : Display Revert Reason?

I'm testing a simple call and expect it to not revert await expect(swapCall).to.not.be.reverted The test fails currently and I get a AssertionError: Expected transaction NOT to be reverted How do I ...
TommyF's user avatar
  • 152
0 votes
2 answers
140 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% ...
Adam's user avatar
  • 103
8 votes
3 answers
6k 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 ...
Kaizoku Gambare's user avatar
15 votes
3 answers
8k views

Testing for custom error reverts in hardhat

I have a custom error described as such: error AlreadyListed(address nftAddress, uint256 tokenId); And in my tests, I'd like to check to see that it's thrown: expect(await nftMarketplace.listItem(...
Patrick Collins's user avatar
0 votes
1 answer
542 views

Can't install Waffle on M1: 'assert.h' file not found

I'm trying to install Waffle on an M1 Mac. Per documentation, after creating a fresh new project with npx hardhat, I use npm like this: npm install --save-dev ethereum-waffle This is the result: npm ...
Gian Segato's user avatar
6 votes
4 answers
3k views

Property 'revertedWith' does not exist on type 'Assertion'

I'm running a test using waffle in hardhat. import { assert, expect } from "chai" . . . it("can only be changed through governance", async () => { await expect(box.store(...
Patrick Collins's user avatar
0 votes
1 answer
861 views

Hardhat Basic Test Fails

I had a few problems with testing smart contracts that seemed perfectly fine to me. I have reduced the repository further and further and am left with this. MappingContract.sol pragma solidity = 0.8....
Tom's user avatar
  • 3
0 votes
1 answer
112 views

Waffle Ethereum tests: advancing N blocks efficiently [duplicate]

Title really says it all. I am writing a test for a smart contract that needs to wait 200 blocks before something can happen. Is there any way I can advance forward 200 blocks in order to test the ...
gdoug's user avatar
  • 101
0 votes
1 answer
589 views

Getting "Provider not found" while testing my contract with waffle

I am testing my contract using Waffle and I am following the documentation provided, using const provider = new MockProvider(); to get a provider for testing. An error was raised in expect().catch() ...
Serban Chisca's user avatar
0 votes
1 answer
736 views

Smart Contract Testing - ethereum-waffle expect function

Can someone please explain the significance of the location of the "await" keyword in the "expect" function from the waffle testing framework? for example: this passes (assume its ...
Nolan Jannotta's user avatar
0 votes
2 answers
1k views

How to use changeEtherBalance from waffle-hardhat?

I want to check if the ether balance of an account decreased after the transaction using changeEtherBalance I tried to follow the waffle docs but couldn't do it either. await token.connect(...
n3n3's user avatar
  • 608
3 votes
1 answer
380 views

Struggling with waffle - mock not initialized

I've got problem with mocking method call. Below is my solidity code and test. I would like to pass mock into withdraw method and check if transfer function was called. But instead I am getting error &...
Tomasz Kulig's user avatar
13 votes
3 answers
10k views

Hardhat get last block timestamp, block number, block hash, nonce, gas limit, gas used

How to get last block information in a Hardhat Waffle test? I checked here https://hardhat.org/hardhat-network/#json-rpc-methods-support And here https://hardhat.org/hardhat-network/reference/ it ...
Russo's user avatar
  • 1,784
2 votes
1 answer
406 views

How to mock out a signed transaction w/ Waffle Mocks?

When applying Waffle mock to simulate a contract method that must be explicity signed an error is thrown: Error: Contract with a Signer cannot override from (operation="overrides.from", code=...
Juan Ignacio Pérez Sacristán's user avatar