Questions tagged [truffle-test]

The tag has no usage guidance.

66 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
0answers
230 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 ...
4
votes
1answer
432 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 ...
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
31 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
1answer
100 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
1answer
851 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
77 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
89 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
126 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
202 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
2answers
1k views

Truffle cannot find Ethereum client when running tests

By default this is the content of the file truffle.js: module.exports = { // See <http://truffleframework.com/docs/advanced/configuration> // to customize your Truffle configuration! }; ...
2
votes
0answers
539 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
424 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
0answers
103 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 '...
1
vote
0answers
68 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.?
1
vote
0answers
28 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
34 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
207 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
51 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
117 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
333 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
0answers
335 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"; ...
1
vote
1answer
235 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
95 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
53 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
266 views

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

Trying to test my Solidity contract for errors using Truffle test. TestSafeMath.sol function test_add_10_and_max_should_return_err() { uint256 max = 2**256 - 1; Assert.error(SafeMathExt....
1
vote
0answers
238 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
265 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
19 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
36 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
13 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 ...
0
votes
0answers
20 views

truffle solidity unit test modifiers: How do you test modifiers dependent on the sender account?

QUESTION: How do you write unit test code that would test that a non-owner can't execute a function modified by a requirement that they be the owner using in solidity and truffle? I am trying to write ...
0
votes
0answers
39 views

Testing using Truffle unbox: Assert.equal error

I ran the pet shop project. It uses "truffle unbox". The petshop project at: Petshop project using Assert.equal without any error is able to execute Assert.equal command but when I am using ...
0
votes
0answers
42 views

Problem with Assert.equal

I am compiling the code available at using "truffle test": https://michalzalecki.com/ethereum-test-driven-introduction-to-solidity/ pragma solidity 0.5.16; import "truffle/Assert.sol&...
0
votes
0answers
57 views

Truffle test stuck when testing with geth endpoint

I tried to test the truffle suite official metacoin example using truffle test. I opened a local private chain using geth with http rpc service open at localhost:8545. My truffle-config.js file is ...
0
votes
0answers
34 views

truffle test is showing error after running on truffle(develop) console

I am using truffle in windows and everything went well. I've successfully set up development network. But when I try to run test from the truffle(develop) console this error shows - TypeError [...
0
votes
1answer
50 views

How to use truffle-assertions to verify parameters of an emit?

I have not been able to find any resources with usage instruction besides github and blog post by the author On github an example is show as such: truffleAssert.eventEmitted(result, 'TestEvent', (...
0
votes
0answers
69 views

Truffle Error: invalid argument 0: hex string without 0x prefix

I'm trying to deploy and test the smart contracts on the Goerli network using Truffle. While migrating getting below error. Contract: Simple Storage Test suite Simple Storage Set ...
0
votes
2answers
92 views

How to specify custom test directory path in truffle-config.js

How do I specify a custom test directory path in truffle-config.js? My test directory is not present at the same level as truffle-config.js, it is residing in a different directory. Truffle has ...
0
votes
1answer
61 views

How can I make sense of solidity-coverage reports

I'm trying to check the coverage of an entire ERC20 set of openzeppelin tests. I'm using openzeppelin/test-environment and solidity-coverage v0.7.4 as plugins in truffle. The tests went fine but I get ...
0
votes
0answers
31 views

How can I test the placeBet() and settleBet() in ethereum hashdice contracts?

I would like to test the smart contract of hashdice using remix IDE, and using truffle. I wonder how to give the arguments for testing. function placeBet(uint _betMask, uint _modulo, uint _commit, ...
0
votes
1answer
58 views

Solidity test fails when testing onlyOwner functions

I have a contract where some functions can be called only by the owner of the contract and I want to test it with a solidity test in truffle. The contract looks like this: contract owned { ...
0
votes
0answers
99 views

truffle test fails with `Error: Callback was already called.`

I have a single .sol contract that includes 2 libraries, 1 interface and 3 contracts A, B and C such that B is A and C is A, B. The contract C is the one I am interested in as it includes all the ...
0
votes
0answers
19 views

I got the error when I do 'truffle test' in Truffle tutorial that pet-shop-tutorial

I'm doing truffle tutorial the pet-shop-tutorial but when I typed truffle test in cmd, I got the error. Here is the error message. I have no idea how I can fix it and where should I check. Please ...
0
votes
1answer
63 views

Unable to filter events with specific values of indexed parameters

I am currently trying to test a smart contract using the truffle suit ( with 'truffle test'). My contract is of a simple ERC20 token which includes the standard Transfer event: event Transfer(address ...
0
votes
0answers
26 views

How to assign event output to variable when testing?

I'm using Truffle test(chai/mocha) and openzeppelin-test-helpers. Can anyone help me about how to assign values from event to variables in the above testing environment?
0
votes
1answer
346 views

TypeError: balance.toNumber is not a function

I need check that token has no balance when selfDestruct was called, but shows an error that balance.toNumber is not a function in the test file. DappTokenSale.sol function endSale() public { //...
0
votes
2answers
89 views

Assertion error running truffle test

I can't seem to understand where this error comes from. Maybe someone can help My token solidity file : pragma solidity >=0.4.2 <0.6.0; contract LairToken { //Name string public ...
0
votes
1answer
118 views

Nothing happens whe I run truffle test

I am new to solidity. Maybe I am missing something obvious in the setup. But when I run truffle test, I get nothing, the terminal just stays there forever. $ truffle test ... and I don't know why, ...