# \#test-helpers

**URL:** https://forum.openzeppelin.com/tag/test-helpers/51.md

[Latest](https://forum.openzeppelin.com/latest.md) · [Categories](https://forum.openzeppelin.com/categories.md) · [Tags](https://forum.openzeppelin.com/tags.md)

---

## [How can one utilize the expectEvent function from the test-helpers library in a Hardhat test?](https://forum.openzeppelin.com/t/how-can-one-utilize-the-expectevent-function-from-the-test-helpers-library-in-a-hardhat-test/38510)

<div class="topic-metadata">

**Author:** [@Memsita](https://forum.openzeppelin.com/u/Memsita)\
**Replies:** 4\
**Last updated:** [November 17, 2023, 7:15am UTC](https://forum.openzeppelin.com/t/how-can-one-utilize-the-expectevent-function-from-the-test-helpers-library-in-a-hardhat-test/38510 "2023-11-17T07:15:33Z")

</div>

I'm migrating from Truffle to Hardhat. I've been using an upgradable contract for my smart contract. While hardhat-truffle5 works fine for tests with normal contracts, I find myself forced to use Ethers contract initiali…

---

## [Invalid JSON RPC response when using Test Helpers expectRevert OpenZeppelin Test Environment](https://forum.openzeppelin.com/t/invalid-json-rpc-response-when-using-test-helpers-expectrevert-openzeppelin-test-environment/4422)

<div class="topic-metadata">

**Author:** [@MichaelKashofer](https://forum.openzeppelin.com/u/MichaelKashofer)\
**Replies:** 9\
**Last updated:** [September 19, 2022, 6:11am UTC](https://forum.openzeppelin.com/t/invalid-json-rpc-response-when-using-test-helpers-expectrevert-openzeppelin-test-environment/4422 "2022-09-19T06:11:45Z")

</div>

The problem surfaces as: Error: Invalid JSON RPC response: "" at Object.InvalidResponse (node\_modules/web3/node\_modules/web3-core-helpe…

---

## [How to test accepting ERC20 tokens as payment?](https://forum.openzeppelin.com/t/how-to-test-accepting-erc20-tokens-as-payment/10714)

<div class="topic-metadata">

**Author:** [@EMarie1571](https://forum.openzeppelin.com/u/EMarie1571)\
**Replies:** 2\
**Last updated:** [June 1, 2022, 12:46pm UTC](https://forum.openzeppelin.com/t/how-to-test-accepting-erc20-tokens-as-payment/10714 "2022-06-01T12:46:55Z")

</div>

Hi! I am trying to test a function to accept ERC20 as payment, but unfortunately it’s not working, throwing the error: " Error: Returned error: VM Exception while processing transaction: revert".I know this error is not…

---

## [Time.increase() bug](https://forum.openzeppelin.com/t/time-increase-bug/28357)

<div class="topic-metadata">

**Author:** [@Spider149](https://forum.openzeppelin.com/u/Spider149)\
**Replies:** 1\
**Last updated:** [May 5, 2022, 1:28am UTC](https://forum.openzeppelin.com/t/time-increase-bug/28357 "2022-05-05T01:28:52Z")

</div>

truffle version: Truffle v5.5.11 (core: 5.5.11) Ganache v^7.0.4 Solidity - 0.8.13 (solc-js) Node v16.14.2 Web3.js v1.5.3 ganache: ganache@7.1.0 I'm using time.increase(seconds) to increase time ( = block time in …

---

## [Erc 998, the legend of](https://forum.openzeppelin.com/t/erc-998-the-legend-of/11337)

<div class="topic-metadata">

**Author:** [@tippi-fifestarr](https://forum.openzeppelin.com/u/tippi-fifestarr)\
**Replies:** 5\
**Last updated:** [April 22, 2022, 6:10pm UTC](https://forum.openzeppelin.com/t/erc-998-the-legend-of/11337 "2022-04-22T18:10:05Z")

</div>

i’m wanting a developer to help me understand erc 998 and/or implement. it’s so much more difficult and rarer than erc 721, which is what i’m still getting familiar with. the hope is that by teaming up with a high level …

---

## [Test for deposit from another erc20 contract to my contract, how do it right?](https://forum.openzeppelin.com/t/test-for-deposit-from-another-erc20-contract-to-my-contract-how-do-it-right/23665)

<div class="topic-metadata">

**Author:** [@adminoid](https://forum.openzeppelin.com/u/adminoid)\
**Replies:** 0\
**Last updated:** [January 30, 2022, 7:07pm UTC](https://forum.openzeppelin.com/t/test-for-deposit-from-another-erc20-contract-to-my-contract-how-do-it-right/23665 "2022-01-30T19:07:56Z")

</div>

I'm trying add deposit from one mock contract to my contract, but balance in my contract is zero. How I can do it right? Below is my code: // imports const { ethers, waffle } = require('hardhat') const { deployContract …

---

## [How to test interactions of my contract with other contracts, like a USDT/BUSD on a hardhat local environment?](https://forum.openzeppelin.com/t/how-to-test-interactions-of-my-contract-with-other-contracts-like-a-usdt-busd-on-a-hardhat-local-environment/23566)

<div class="topic-metadata">

**Author:** [@adminoid](https://forum.openzeppelin.com/u/adminoid)\
**Replies:** 4\
**Last updated:** [January 29, 2022, 1:18pm UTC](https://forum.openzeppelin.com/t/how-to-test-interactions-of-my-contract-with-other-contracts-like-a-usdt-busd-on-a-hardhat-local-environment/23566 "2022-01-29T13:18:03Z")

</div>

I write a smart contract, that should interact with another smart contract, such as USDT and BUSD. I use a hardhat environment and her local environment, not a testnet. For testing those interactions I must copy needed…

---

## [Exception while processing transaction: out of gas](https://forum.openzeppelin.com/t/exception-while-processing-transaction-out-of-gas/23413)

<div class="topic-metadata">

**Author:** [@Jordan\_Melendez](https://forum.openzeppelin.com/u/Jordan_Melendez)\
**Replies:** 6\
**Last updated:** [January 26, 2022, 7:39pm UTC](https://forum.openzeppelin.com/t/exception-while-processing-transaction-out-of-gas/23413 "2022-01-26T19:39:37Z")

</div>

I have developed a smart contract and was able to deploy it to the testnet via Remix. However, I am unit testing using mocha and am running into an error. This is an NFT contract using ERC721Enumerable and I set a reser…

---

## [NetStorm - React NFT Marketplace Template](https://forum.openzeppelin.com/t/netstorm-react-nft-marketplace-template/22080)

<div class="topic-metadata">

**Author:** [@djrthree](https://forum.openzeppelin.com/u/djrthree)\
**Replies:** 0\
**Last updated:** [January 3, 2022, 3:25am UTC](https://forum.openzeppelin.com/t/netstorm-react-nft-marketplace-template/22080 "2022-01-03T03:25:10Z")

</div>

Interest-earning limit orders. We Buy The Dip is an SVG-based, on-chain NFT that that gets loaded with ETH, converts to USDC, lent out to a vault to earn interest, and eventually repurchases ETH at some preset strike p…

---

## [Help with bep20 crowdsale token](https://forum.openzeppelin.com/t/help-with-bep20-crowdsale-token/6634)

<div class="topic-metadata">

**Author:** [@EMCsquarez\_Support](https://forum.openzeppelin.com/u/EMCsquarez_Support)\
**Replies:** 3\
**Last updated:** [November 19, 2021, 3:39am UTC](https://forum.openzeppelin.com/t/help-with-bep20-crowdsale-token/6634 "2021-11-19T03:39:04Z")

</div>

Hello, I am deploying a BEP20 token and I would like to start a crowdsale for which BNB in go to my wallet and the contract sends the token automatically to the sender. Otherwise can also be BNB go to contract but as ow…

---

## [Trouble migrating from truffle to openzeppelin's test environment. Doesn't seem to be connecting to ganache](https://forum.openzeppelin.com/t/trouble-migrating-from-truffle-to-openzeppelins-test-environment-doesnt-seem-to-be-connecting-to-ganache/11146)

<div class="topic-metadata">

**Author:** [@TommyG](https://forum.openzeppelin.com/u/TommyG)\
**Replies:** 8\
**Last updated:** [November 16, 2021, 1:22am UTC](https://forum.openzeppelin.com/t/trouble-migrating-from-truffle-to-openzeppelins-test-environment-doesnt-seem-to-be-connecting-to-ganache/11146 "2021-11-16T01:22:37Z")

</div>

Hello. I'm trying to take advantage of test-helpers, but I cannot seem to figure this out. Everything "just worked" with truffle and ganache. It doesn't seem like test-environment is even talking to ganache, it just fail…

---

## [Templates for testing](https://forum.openzeppelin.com/t/templates-for-testing/18145)

<div class="topic-metadata">

**Author:** [@mantasfam](https://forum.openzeppelin.com/u/mantasfam)\
**Replies:** 0\
**Last updated:** [November 3, 2021, 1:40pm UTC](https://forum.openzeppelin.com/t/templates-for-testing/18145 "2021-11-03T13:40:09Z")

</div>

Hello, Are there any templates for ERC20, ERC721 tokens testing? I wrote some contracts that will be used in mainnet and they have pretty standard (OpenZeppelin standard) implementation. So I'm wondering is there some M…

---

## [Percentages with Big Numbers Truffle Test](https://forum.openzeppelin.com/t/percentages-with-big-numbers-truffle-test/8122)

<div class="topic-metadata">

**Author:** [@jayman27](https://forum.openzeppelin.com/u/jayman27)\
**Replies:** 6\
**Last updated:** [July 11, 2021, 11:41pm UTC](https://forum.openzeppelin.com/t/percentages-with-big-numbers-truffle-test/8122 "2021-07-11T23:41:59Z")

</div>

I am trying to find a percentage using the Big Number library from @openzeppelin/test-helpers Here is the code: var someVarABC = new BN('2706'); var someVarDEF = new BN('5060584'); var total = someVarABC.add(someVarDEF…

---

## [Error using expectEvent.inTransaction](https://forum.openzeppelin.com/t/error-using-expectevent-intransaction/7789)

<div class="topic-metadata">

**Author:** [@hankoc](https://forum.openzeppelin.com/u/hankoc)\
**Replies:** 4\
**Last updated:** [May 31, 2021, 7:37pm UTC](https://forum.openzeppelin.com/t/error-using-expectevent-intransaction/7789 "2021-05-31T19:37:01Z")

</div>

Hi all, I’m trying to pass a test when a specific event is emitted using expectEvent.inTransaction() method provided by OZ test helpers. I call function1 with a JS Promise. function1 calls function2 which emits an eve…

---

## [Incorrect Product of BigDecimals](https://forum.openzeppelin.com/t/incorrect-product-of-bigdecimals/7853)

<div class="topic-metadata">

**Author:** [@jayman27](https://forum.openzeppelin.com/u/jayman27)\
**Replies:** 1\
**Last updated:** [May 6, 2021, 11:42am UTC](https://forum.openzeppelin.com/t/incorrect-product-of-bigdecimals/7853 "2021-05-06T11:42:44Z")

</div>

My solidity function emits an event with a uint256 of: 5060584000000000000000000 The problem is on the truffle side in my javascript test. Here is the code: const { BN, expectEvent, constants } = require('@openzeppelin…

---

## [Correct setup to test openzeppelin-contracts-upgradeable](https://forum.openzeppelin.com/t/correct-setup-to-test-openzeppelin-contracts-upgradeable/5861)

<div class="topic-metadata">

**Author:** [@Hantok](https://forum.openzeppelin.com/u/Hantok)\
**Replies:** 5\
**Last updated:** [February 24, 2021, 6:32pm UTC](https://forum.openzeppelin.com/t/correct-setup-to-test-openzeppelin-contracts-upgradeable/5861 "2021-02-24T18:32:40Z")

</div>

I checked out openzeppelin-contracts-upgradeable from GitHub and docs as well. I created my own Token contract from preset: https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/v3.0.0/contracts/preset…

---

## [OpenZeppelin Test Helpers: Timeout issues when advancing blocks in tests](https://forum.openzeppelin.com/t/openzeppelin-test-helpers-timeout-issues-when-advancing-blocks-in-tests/5550)

<div class="topic-metadata">

**Author:** [@viraj124](https://forum.openzeppelin.com/u/viraj124)\
**Replies:** 5\
**Last updated:** [January 28, 2021, 7:31pm UTC](https://forum.openzeppelin.com/t/openzeppelin-test-helpers-timeout-issues-when-advancing-blocks-in-tests/5550 "2021-01-28T19:31:06Z")

</div>

Hi, I have a time of 2 mins in my truffle config and I am trying to advance 1 hour worth of blocks with advanceBlockTo but my test keeps getting timed out actually ideally I want to advance to a week worth of blocks but…

---

## [Web3 ignores Test Helpers configuration for Test Environment](https://forum.openzeppelin.com/t/web3-ignores-test-helpers-configuration-for-test-environment/4806)

<div class="topic-metadata">

**Author:** [@golden-idea](https://forum.openzeppelin.com/u/golden-idea)\
**Replies:** 2\
**Last updated:** [November 27, 2020, 9:28am UTC](https://forum.openzeppelin.com/t/web3-ignores-test-helpers-configuration-for-test-environment/4806 "2020-11-27T09:28:02Z")

</div>

:bomb: Problem Recently I have switched from the Truffle test-environment to the OpenZeppeling test-environment and I am extremely enjoying the features. However, something confuses me. At the top of my test code I writ…

---

## [OpenZeppelin Test Helpers (OpenZeppelin Solidity version): "web3.currentProvider.sendAsync is not a function"](https://forum.openzeppelin.com/t/openzeppelin-test-helpers-openzeppelin-solidity-version-web3-currentprovider-sendasync-is-not-a-function/4246)

<div class="topic-metadata">

**Author:** [@zaryab2000](https://forum.openzeppelin.com/u/zaryab2000)\
**Replies:** 1\
**Last updated:** [October 26, 2020, 8:32am UTC](https://forum.openzeppelin.com/t/openzeppelin-test-helpers-openzeppelin-solidity-version-web3-currentprovider-sendasync-is-not-a-function/4246 "2020-10-26T08:32:46Z")

</div>

Hello @abcoathup I was trying to use the increaseTimeto function of Openzepplin test helpers. I was importing from - openzeppelin-solidity/test/helpers/increaseTime However I got an error which(I assume) is related to…
