Questions tagged [truffle-test]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
0answers
8 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
1answer
131 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
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 ...
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
2answers
213 views

Having trouble figuring out Truffle testing with Javascript

I've started unit testing my contracts with Truffle (using Javascript). I'm fairly new to Truffle and Mocha both, and while I've tried to follow the tutorials, I'm struggling to follow exactly what's ...
0
votes
1answer
42 views

Truffle test doesn't connect to Ganache

I'm using Truffle and Ganache for my development environment. Using the truffle console or truffle external scripts everything works fine, but truffle test does not seem to be connected to Ganache: ...
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 ...
2
votes
1answer
115 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 ...
0
votes
0answers
10 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', () =...
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 [...
0
votes
0answers
27 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
1answer
13 views

Get The Address Of the Deployer Of Contract In Truffle Test

How can I get the address in Truffle that calls functions of the contract by default(When we don't use the {from: accounts[i]} statement)?
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(...
1
vote
1answer
55 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
1answer
479 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
327 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 ...
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
31 views

Truffle test failing with “Error: Returned error: VM Exception while processing transaction: revert” - how can I debug it?

I'm using truffle, the ganache AppImage to run a personal blockchain, and have 2 solidity smart contracts Migrations.sol and PassportManager.sol I'm running a truffle test and getting Error: Returned ...
0
votes
2answers
267 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
2answers
358 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
143 views

Transaction reverted when testing requires/asserts in non void functions

im trying to test the requires of a Smart Contract using just solidity according to this article: http://truffleframework.com/tutorials/testing-for-throws-in-solidity-tests This is the contract, the ...
0
votes
1answer
20 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
1answer
54 views

ERC721 testing transferFrom()

How can I test (truffle test or development console) the following: await nft.transferFrom(accounts[0], accounts[1], 1); await nft.transferFrom(accounts[1], accounts[0],1); The second line throws ...
0
votes
1answer
28 views

How can I test my purchase function on the truffle with chai?

I'm trying to test my token buying function but I encounter an error, o facilitate understanding I will show the code "Error: Returned error: VM Exception while processing transaction: revert&...
2
votes
3answers
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! }; ...
0
votes
1answer
185 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, ...
0
votes
1answer
19 views

Setting token balances in js test

I want to be able to set the token balance for Alice to 500 DAI & 500 USDT, however I have no clue how I am going to do that. Is there a way you can set an account's balance before a test without ...
0
votes
1answer
217 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', (...
2
votes
1answer
224 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.?
0
votes
1answer
319 views

Vyper: Truffle test read mapping value inside struct

I have the following struct inside my vyper file: races: public({ start: timestamp, end: timestamp, racersBetHash: bytes32[address], racersBetAmount: wei_value[address] }[int128]) Then I ...
0
votes
2answers
393 views

Truffle Test Error

I want to create a decentralise application where I sell my tokens.So,In this scenario.I create a function to end my selling tokens.So,I create a function below. The solidity code is here:- function ...
0
votes
0answers
26 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
1answer
111 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
1answer
34 views

Truffle test: could not find local build/contracts

I have create a truffle project with this command: truffle unbox react I have run this commands: npm install @openzeppelin/contracts npm install @openzeppelin/test-helpers npm install @openzeppelin/...
-1
votes
1answer
15 views

sync function syntax [closed]

What is the difference between this syntax: beforeEach( async () => { ... }); and this one: beforeEach(async function() { ... }); Thanks
0
votes
1answer
16 views

Use smartcontract's ENUM in test scenarios in truffle

I have create a truffle project with this command: truffle unbox react Here is my smartcontract contracts/SimpleStorage.sol : contract SimpleStorage { enum MyEnum { step1, step2, ...
0
votes
1answer
33 views

Big numbers in truffle test assertion

Here is what i've done: I have create a project this way: truffle unbox react npm install @openzeppelin/test-helpers I have keep SimpleStorage.sol sample contract and here is my test file: const { BN,...
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
1answer
18 views

Difference between contract.new and contract.deployed functions

I have create a basic truffle project and i am writing automated tests. There is 2 ways to instantiate the smartcontract to test and i want to understand the difference between this 2 ways: const ...
2
votes
1answer
84 views

Why do my truffle tests get much slower as I run more of them?

So I am currently building up a test suite for a project, and I have quite a few tests at this point. I am running into a problem however that truffle seems to run tests later in its execution much ...
5
votes
1answer
494 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 ...
0
votes
1answer
528 views

Deploying new contract inside truffle test case

I was trying to transact between two contracts inside my truffle test case. But not been able to do it. The second contract instance comes back undefined always. As per the truffle documentation, ...
1
vote
1answer
304 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
1answer
98 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
1answer
27 views

Truffle test: Problem with understanding the test

I am trying to understand the test provided at: Tutorial ("Test balance after deposit", function() { return SimpleBank.deployed().then(function(instance) { sb = instance; ...
-1
votes
2answers
63 views

Help a noob testing: it ' should deposit 1 Ether'

I wanted to revive or refactor this old smart contract as an exercise to learn solidity and js coding. Truffle compiled it and migrated it and it passed the first test (Although I'm not sure if it ...
1
vote
2answers
110 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 ...
0
votes
2answers
1k views

How to test contract with multiple accounts / addresses in truffle?

I want to test my truffle contract with multiple msg.sender addresses. Like "the first user sell token, the second user buys this token". For one address I simply write something like contract.buy....
0
votes
1answer
108 views

truffle won't run tests while initializing a global contract instance

I am testing my smart contract in truffle. I need to declare some global variables hence I did so outside 'it'. I also tried declaring a global contract instance that I can use in all test cases. ...

1
2 3 4 5