Questions tagged [truffle-test]

The tag has no usage guidance.

80 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
1answer
498 views

Truffle test fails to call the base function, wants the override

I have an extended ERC20 contract with ERC827 functions, which are overrides of ERC20 with an extra callback parameter. I have these two pairs of base/override functions: Base: function ...
4
votes
0answers
314 views

`eth_getTransactionReceipt` returns the transaction hash not the receipt

I use sol-coverage in a truffle project. Ganache is my development blockchain. I have a lot of tests which end up doing more than a few thousand JSON RPC calls. Due to unbeknownst reasons, the ...
3
votes
0answers
57 views

Many Contract Testing strategies

I'm trying to wrap my brain around how to effectively test multi "projects" in Truffle, assume a simple ganache setup, also assume that these contracts seem to work, in remix, and in unit tests, but, ...
2
votes
0answers
23 views

1) “before all” hook: prepare suite for “ ”

I am trying to create an Integrated test (to test multiple smartContracts working together). I re-initialize them inside beforeEach() function. So I get the clean test for each test case. I have done ...
2
votes
0answers
38 views

How to simulate time increase in Remix IDE?

In my JavaScript tests: module.exports = { increaseTime: (duration) => { const id = Date.now(); return new Promise((resolve, reject) => { web3.currentProvider.send({ ...
2
votes
0answers
315 views

Conflicting solc versions on Truffle-test

I'm developing some smart contracts sing solc 0.7.0. I'm able to successfully compile and deploy the contracts, but when I try to run $truffle test I get the following error: Using network '...
2
votes
1answer
238 views

Truffle test: how to get the block number of deployed contract?

In my test I would like to get the block or block number of when the contract was deployed. const instance = await MyContract.deployed() const contractDeploymentBlockNumber = await instance.?
2
votes
1answer
117 views

How to trace the line where a tx failed in truffle tests?

I know about 0x's sol-compiler and sol-trace. I used them before and they do exactly what I'm looking for, but these modules bring significant overhead when used with truffle. Check out this file to ...
2
votes
0answers
440 views

TypeError: Member “equal” not found or not visible after argument-dependent lookup in type(library Assert)

Truffle v5.0.8 (core: 5.0.8) Solidity v0.5.0 (solc-js) Node v10.13.0 Web3.js v1.0.0-beta.37 Assert.equal worked in Truffle 4.x. pragma solidity >=0.4.21 <0.6.0; import "truffle/Assert.sol"; ...
2
votes
1answer
1k views

How to debug transaction from truffle test on development network

I am trying to debug a failing solidity function, which I am calling from the JS test files with truffle. When I run my test, I am successfully able to get a transaction id. However, my solidity ...
2
votes
0answers
83 views

Truffle test to verify events can be queried by the address of the signing user?

I'm trying to write a test which verifies I can query a given type of events by the user/address which sign them. I would like to apply TDD (relevant to say I haven't made the implementation for this ...
2
votes
1answer
135 views

Trying to understand why my test.js fails

I have a function that is not passing my tests in JS but the function works as expected in Remix. Can you help me contract.sol function test1 () public view returns(bool){ return(true); } ...
2
votes
0answers
184 views

IntelliJ + truffle tests

I would like to run truffle tests from IntelliJ. I found a tutorial here: https://charterhouse.github.io/2017/05/12/running-truffle-unit-tests-in-intellij-idea.html Unfortunately, it does not seem ...
2
votes
0answers
257 views

evm_revert to snapshot#1 in ganache-cli automatically

I am using evm_increaseTime in my tests to move block time but in ganache-cli it shows that it is reverting to snapshot #1. I have not used evm_revert or evm_snapshot. Is it normal? what is the ...
2
votes
0answers
583 views

Truffle test - No events were emitted + TypeError: test.titlePath is not a function

1) test_initial_badge_creation > No events were emitted 2 passing (2s) 1 failing /usr/local/lib/node_modules/truffle/node_modules/mocha/lib/reporters/base.js:178 failures.forEach(...
2
votes
0answers
591 views

Unexpected behavior with `block.timestamp` in truffle test

I am doing some experiments with block.timestamp(which is now's alias). I wrote some code to see if block.timestamp really represents the timestamp of the last mined block. From the documentation: ...
1
vote
1answer
13 views

Explore transaction from truffle test file

I have create this test: const { expectEvent } = require('@openzeppelin/test-helpers'); const MyContract = artifacts.require('MyContract'); contract('MyContract', function (accounts) { const [...
1
vote
0answers
31 views

Is Truffle test useful?

Hi there I came across "Truffle test". As a developer I feel like it's better to test code on remix for unit testing rather than wasting time on writing truffle test in javascript. What do ...
1
vote
0answers
41 views

Using privateFor in truffle test

Using truffle , I am able to deploy private smart contracts using privateFor clause. However, I am not able to use in truffle test. I get the following error. Is there a way we can use privateFor ? ...
1
vote
0answers
311 views

Mocha timeout when running truffle test. Works fine on ganache, not on public networks

This is the error I get when running truffle test --network kovan: 1) "before all" hook: prepare suite Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if ...
1
vote
2answers
115 views

No events where emmited. Why?

This is not a duplicate question. The other one doesn't answer the problem in any way. Can anyone explain to me why do I get No Events where emmited when running truffle test? Ganache is listening in ...
1
vote
0answers
138 views

What is the easiest way to write truffle tests in typescript?

I read about Typechain, but the configuration is rather verbose and generally feels like a very custom solution: Everytime you change contracts you need to run yarn generate.
1
vote
1answer
494 views

Error when testing the contract

ApprovalContract.sol pragma solidity ^0.5.1; contract ApprovalContract{ address public sender; address payable public reciever; address public constant approver=...
1
vote
1answer
342 views

Debugging a VM error in solidity

I'm getting the following error while running a test in truffle: Error: Returned error: VM Exception while processing transaction: revert Now, the code is simply to big and complicated to run ...
1
vote
0answers
127 views

No events were emitted - Exchanging ERC721 Tokens

Function to exchange ERC721 Tokens between two addresses. I am implementing this on truffle and openzeppelin 2.10. Two different tokens should be exchanged between two addresses. Here's my contract ...
1
vote
1answer
56 views

How return variable from simple smart contract

Hello I'm trying to make my first and simple test for get a variable from my first contract: Truffle version: Truffle v4.1.14 Node: 8.12.0 pragma solidity ^0.4.4; contract SimpleContract { ...
1
vote
0answers
242 views

Invalid number of arguments to Solidity function

I have a function in my contract. First takes argument, the second one does not. Everything works fine until I change the name of the second one into the same one as the first one and create ...
1
vote
1answer
306 views

Truffle test case to unit test withdrawal pattern

How can I test the withdraw() function in a truffle javascript test case for the below contract? The problem is, If I use the msg.sender from the same contract, the before and after balance will be ...
0
votes
0answers
5 views

Truffle Test Error for Hello World method

I am trying a very simple test in truffle using javascript. This is the solidity method I have function helloWorld() public view returns (string memory){ return "hello world"; } And I ...
0
votes
0answers
10 views

Truffle test - doesn't send funds to msg.sender

it seems like I have a wrong gnache or truffle setup ... I already ask a simular question here: Owner of contract is set to contract address? Basicly there is some mess up with addresses on my local ...
0
votes
0answers
13 views

Truffle test is failling with transferFrom.call

When I run tests with the following code, I get the following error: Error Error: Returned error: VM Exception while processing transaction: revert Tests it('Handles delegated token transfers', () =...
0
votes
0answers
28 views

Owner of contract is set to contract address?

I just testing a contract with truffle and Im wondering why the owner of the contract is set to the contract address itself. Migrations: const contractA= artifacts.require("ContractA"); ...
0
votes
0answers
7 views

ReferenceError while running the truffle test

I am getting the ReferenceError while executing truffle test, I got it from a book: //Greeter.sol pragma solidity >=0.4.0 <0.7.0; contract Greeter{ function greet() external pure returns(...
0
votes
0answers
21 views

Truffle test doesn't seem to finish before “succeeding”, and doesn't wait for transactionHash of a sent tx!

quick problem I've been slamming my head against since last night, My truffle (v5.2.3) test file performs two (2) tests, that serially call() then actually send a transaction to make persistent ...
0
votes
1answer
21 views

Assertion Error

Solidity file pragma solidity ^0.5.0; contract Todo { struct User { uint id; string name; } User[] public users; uint public nextId = 1; function create(string memory name) public ...
0
votes
0answers
32 views

Transferring aToken(aDAI) in my truffle tests reverts with unspecific error

I'm having issues with setting up a truffle test to transfer aTokens (aDAI) to my contract. I'm using Aave v2 and running ganache with a fork from mainnnet. This is what I did so far: 1- Started a ...
0
votes
1answer
18 views

Interacting with existing Smart Contract deployed on test network like rinkeby from local test environment (truffle)

I have forked rinkeby network using ganache-cli as shown below ganache-cli -f https://rinkeby.infura.io/v3/id --account="fsdfmsadklksmdflskamf" Now, I want to test my smart contract which ...
0
votes
0answers
16 views

Set a gas limit when sending a transaction in a truffle test scenario

I am writing truffle tests for a smartcontract. I have create a truffle project with this command: truffle unbox react I have kept SimpleStorage.sol sample smartcontract. I have add some tests in ...
0
votes
0answers
41 views

Truffle test doesn't recognize estimateGas function

I'm trying to test my contracts using Truffle and Ganache, but I'm facing some problems with some functions. When I call a non view function, I'm getting the error "out of gas". Moreover, if ...
0
votes
2answers
25 views

Issue deploying a contract successfully with Truffle and ganache

Long story short my contract is not passing the deployment test using truffle, mocha, and chai. I ran the code individually in the truffle console and it was returning an address just fine but it won'...
0
votes
0answers
23 views

Wrong contract balance shown by web3.eth.getBalance

I want to test if the balance updates when I send some eths it("the balance matches the price of a person", async function(){ let instance = await People.deployed() await instance....
0
votes
1answer
51 views

Truffle Test AssertionError: error message must contain revert

I can't figure out why this error occurs Here my test js code: var YarockToken = artifacts.require("./YarockToken.sol"); contract('YarockToken', function(accounts) { var tokenInstance; ...
0
votes
0answers
1k views

Metamask RPC error -32603… {“error”:“revert”,“program_counter”:6758,“return”:“0x”}

I have a dApp that leverages ERC721 contract which allows users to upload images onto IPFS and transfer them to each other. User A can upload images fine and transfer them fine to User B. Once ...
0
votes
0answers
47 views

Truffle “test” is passing only 1 it(“”) test instead of showing “all 3 tests passed”

MyToken.sol //// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract MyToken is ERC20 { constructor(uint256 ...
0
votes
0answers
74 views

“before each” hook error while run truffle test command

I ran truffle test command on my project for testing but I got an error like this: "before each" hook for "1- should be return true Pauser Role for account[0]" why I'm getting ...
0
votes
0answers
13 views

truffle deployer - addess is still there without deploy

First Question: // Stage deploying A before B deployer.deploy(A); deployer.deploy(B); This is found on the truffle website. It says stage deploying A before B. So this must mean that deploying B ...
0
votes
0answers
42 views

Truffle Test Error Revert in Contract Factory

I'm trying to create a contract factory that creates "Oracles". Oracles have state variables that are initialized in the contract constructor, and I'm trying to use Truffle Test to verify ...
0
votes
0answers
186 views

Truffle - multiple transactions per block

i try to simulate a large transaction load and therefore want to execute multiple transactions in a truffle test. I changed the block-time to five seconds and generate the transactions, but only one ...
0
votes
0answers
14 views

Transaction Callback Function Doesn't Run

I'm running the following code as part of a truffle test: electionController = ElectionController.new(districtsNo,districtFactory.address,voteTokenFactory.address); function createVoteToken(...
0
votes
0answers
14 views

SyntaxError when setting instance of deployed contract to token variable

I'm following this tutorial: https://www.youtube.com/watch?v=044h0ZI-fDI At 22:45, the following command is run: DappToken.deployed().then(function(i){token=i;}) In the video, after this command is ...