New answers tagged

0 votes

How to use truffle-assertions to check if a constructor will revert?

With @openzeppelin/test-helpers you can do: const { expectRevert } = require("@openzeppelin/test-helpers"); const Reverts = artifacts.require("Reverts"); contract("Reverts&...
user avatar
  • 183
1 vote
Accepted

Why am I getting incorrect WBTC when swapping it with DAI using Uniswap?

script is just using the Uniswap v2 router and routing directly from DAI -> WBTC within the DAI <> WBTC pool, which only has enough depth to get you ~34 WBTC with 1m DAI The Uniswap site will ...
user avatar
  • 10.9k
-1 votes

How to properly write Solidity unit tests?

I'm currently going through this FreeCodeCamp tutorial, which has several examples of both unit and staging testing. They use Hardhat, Chai, ethers, Waffle, and Mocha. Highly recommend. Very efficient ...
user avatar
0 votes

"Error: Returned error: VM Exception while processing transaction" when I run truffle test

It tells you that the line await lottery.buyTicket({from : accounts[2]}); reverts with the message "Lottery is not started yet". You should either: Start the lottery (although, going by ...
user avatar
  • 170
1 vote
Accepted

"insuffiecient allowance" running my unit test

You need to set the allowance of token for the smart contract. As token is a separate smart contract, the Lottery is not allowed to manipulate with any tokens it doesn't own or is allowed to ...
user avatar
0 votes
Accepted

Error: No events were emitted

The second test is using DappTokenSale as the token it("facilities token buying", function () { //-------------------------- // Should use DappToken here //-----------------------...
user avatar
  • 29.6k

Top 50 recent answers are included