Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [truffle-test]

The tag has no usage guidance.

0
votes
1answer
18 views

invalid number value (arg=“_goal”, coderType=“uint256”, value=2000000000000000000)

i am following a tutorial from here. And upon running truffle test. It produces following error. 2_HashnodeCrowdsale.js ====================== Deploying 'HashnodeCrowdsale' ------...
0
votes
0answers
30 views

“Callback was already called” during truffle test using a solidity testfile

I'm creating a contract/token which extends the openzeppelin ERC20.sol and Ownable.sol. My contract has no own logic yet and looks like this: pragma solidity ^0.5.2; import "../node_modules/...
0
votes
0answers
8 views

Solidity: (why) is it considered an anti-pattern to inherit a contract in a truffle test?

There are some functions I'd like to expose on my contract but only for testing purposes. It seems reasonable to specify them with a visibility modifier of internal and have the test contract inherit ...
0
votes
0answers
16 views

Truffle.js file is not created with truffle init command

I have run the truffle init command successfully with creating the following directories and files such as contracts, migrations, test, and truffle-config.js but the one file is missing as truffle.js? ...
1
vote
2answers
26 views

How use Truffle Framework [closed]

Anyone please help me to understand what is exactly Truffle & Ganache ? How to install & use Truffle ? Please reply who are know this.
0
votes
0answers
34 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"; ...
0
votes
1answer
29 views

How to test kill function including selfdestruct()?

there. I'm coding kill function below: function kill() public onlyOwner returns (bool) { selfdestruct(msg.sender); return true; } and my unit test code: function testOwnerCanKillContract()...
0
votes
1answer
17 views

Truffle, getPastEvents synchronously

I try to check that a total of 4 events have been emitted by my contract instance. Next code will fail in the assert.equal line since getPastEvents will process the events in a callback and so the ...
3
votes
2answers
83 views

Truffle Test Issue With `address payable` and Compiler Version

I am trying to run truffle test on an old contract which was written using pragma solidity 0.4.24;. While I am able to deploy the contracts using truffle migrate, I get the following error when ...
0
votes
1answer
15 views

Cannot retrieve data from smartcontract during tests

I am writing truffle tests for my smart contract solidity version 0.4.24. The tests are emitting events to write data to memory through smart contract. But I am unable to retrieve data from functions. ...
0
votes
0answers
15 views

TypeError and ReferenceError in truffle test

Im newbie and doing an exercise Im having this errors at truffle testing: Compiling your contracts... =========================== > Everything is up to date, there is nothing to compile. ...
0
votes
1answer
58 views

truffle test: SyntaxError: missing ) after argument list [closed]

truffle test Using network 'development'. Compiling your contracts... =========================== > Everything is up to date, there is nothing to compile. /home/ubuntutest/proyectoico/test/...
1
vote
2answers
44 views

Trying to test the contracts fully

truffle(develop)> version Truffle v5.0.5 (core: 5.0.5) Solidity v0.5.0 (solc-js) Node v10.15.1 const ApprovalContracts = artifacts.require('../../contracts/ApprovalContracts.sol'); contract ('...
0
votes
1answer
27 views

Truffle - how to share variables and functions between test files? [closed]

I have files in Test directory, each one performs different test but all of them contain at least exactly the same functions "register" and "vote", also few arrays like votings = [], groups = [] and ...
1
vote
1answer
47 views

how to test overloaded function in truffle?

I recently upgraded truffle to the newest version. Now it does not automatically detect overloaded functions anymore. Before, I could just do the following: await contract.function({ from: accounts[...
0
votes
1answer
40 views

As in truffle tests pass the check by block.timestamp?

I have 2 functions function startBuilding () public { uint[8] memory _buildingInfo; _buildingInfo[1] = uint32(block.timestamp) + 2 minutes; addBuilding(...
2
votes
1answer
32 views

Truffle .call() returns values with array index instead of keys

I am currently writing tests for solidity contract using truffle. When I invoke a function from the contract with .call(), the object that is being returned to me has the values included twice, once ...
2
votes
1answer
75 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
1answer
86 views

Returns TX Object instead result in Truffle test

I'm getting AssertionError: expected { Object (tx, receipt, ...) } to be true Here is my testing code let apprOrOwnr = await this.erc721.isApprovedOrOwner(owner, tokenId); expect(apprOrOwnr).to....
1
vote
1answer
52 views

Truffle test, how to get address(0)?

This is going to be short question and may be silly, but I'm literally stuck with a problem, where I need to pass address(0) to function in Truffle Test in JS and don't really know how to do it. In ...
1
vote
1answer
30 views

Truffle test failing

i am learning solidity contracts and ethereum dapps. I have created a smart contract for creating a ERC20 token on using truffle dev environment. pragma solidity ^0.5.0; contract LearnTokens { ...
1
vote
1answer
58 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
1answer
24 views

Issue with Contract function return value data type

I am using a simple contract Contract code contract Bank { address public owner; mapping(address => uint) private customerBalance; event fallbackCalled(address, uint256); event ...
2
votes
1answer
70 views

Contract Not Deploying In Truffle Tests

I am trying to do a simple test on Truffle, but it seems that the deployed() promise is never being executed. var MyContract = artifacts.require('MyContract') contract('MyContract', function(...
0
votes
1answer
88 views

How to access in JavaScript multiple return values returned from a solidity function

My contract function returns two values. How to access the multiple return values in JavaScript from a mocha testcase? contract X { function a() pure public returns(uint,uint) { uint p=10; ...
2
votes
0answers
37 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 ...
0
votes
0answers
45 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 ...
2
votes
1answer
28 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); } ...
1
vote
1answer
33 views

Truffle - a proper way to execute a chunk of code

Let's say I have a complex operation to execute, for example deploying 6 contracts and calling functions to each one, passing addreses to few of them and executing some extra more functions. I can, of ...
0
votes
1answer
128 views

Error: Please pass numbers as strings or BigNumber objects to avoid precision errors

let result = await instance.joinQuiz({ from: accounts[1], value: web3.utils.toWei(10, "wei") });
0
votes
1answer
44 views

How to test contract interaction with mainnet contract via Truffle

I'm writing a contract via Truffle and my understanding is that running truffle test will run my tests in a clean-room environment. E.g. a fresh deployment blockchain run on my local machine How can ...
0
votes
1answer
86 views

Unable to test the value from contract using truffle test

block builders! I have trouble testing the return value from my contract, because the return uint value is always a "transaction" object (I actually don't really know what that mean) Here is the ...
-2
votes
1answer
75 views

ParserError compiling Smart Contract, what's wrong?

I'm getting this error when trying to compile a contract using cmd on windows: Error parsing C:/Users/alexa/Desktop/contracts/contracts/ApprovalContract.sol: ParsedContract.sol:6:37: ParserError: ...
2
votes
0answers
23 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 ...
1
vote
1answer
90 views

Using the Truffle command line debugger

I'm writing a contract in solidity, in which a test case fails. I want to step through the code to find what's going wrong. I'm using truffle for development. This is what I do after making changes to ...
0
votes
1answer
40 views

Testing a function in Solidity

and am trying to write some test for a payable function in Solidity but i don't know how to go about it any help will be appreciated . I want to test for the case where the buyer send an amount less ...
3
votes
1answer
146 views

Evaluate the performance of a smart contract [closed]

What is the best way and tools to evaluate the performance of a smart contract. More specifically, I want to test my contract for large scale deployment by making a script that emulate real world ...
0
votes
1answer
25 views

What are the best Practices for writing truffle Tests for a Smart Contract ?

I am currently having a project where a banking system is to be made, what is the approach to get into it. Its suggested to write the tests first and then proceed with the smart contract. What are the ...
0
votes
2answers
25 views

What can i do if truffle doesn't execute commands?

First of all i can´t execute truffle writing truffle console. Instead of that I have to write truffle.cmd console. When im in the truffle console and I try to execute test over my contracts I get ...
0
votes
1answer
110 views

“truffle test” says “assert.rejects” is not a function even it is Node 10

As per the official documentation, assert.rejects was added since Node v10.0.0. Also, the node console confirms that: even though, truffle test throws this error: TypeError: assert.rejects is ...
0
votes
1answer
96 views

How to define a function inside a truffle contract test [closed]

Is that possible to define a function inside a truffle contract test? There is a repetitive yet complicated step in truffle test scenario I am working on and wondering would it be possible to ...
1
vote
0answers
87 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. I am attaching screenshot of it....
0
votes
2answers
78 views

How to debug mappings of structs in truffle tests

This is my test file: pragma solidity ^0.4.24; import "truffle/Assert.sol"; import "truffle/DeployedAddresses.sol"; import "../contracts/Salaries.sol"; contract TestSalaries { function ...
3
votes
1answer
90 views

Is there a way to test an onlyOwner function from a Truffle/Solidity unit test?

I have a contract with a function marked as onlyOwner (from OpenZeppelin, so only the address that deployed the contract can call it). pragma solidity ^0.4.17; import "./Ownable.sol"; contract ...
0
votes
1answer
37 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 { ...
0
votes
1answer
24 views

Truffle test error: deducts the amount from the allowance

What i did first was watching at Dapp university tutorials, I manage to watch all 14 videos and run it with Ganache. But since everything is doing good at local, I created my own private network. Then....
1
vote
1answer
24 views

AssertionError: cannot transfer value larger than approved amount

I have followed the tutorials of Dapp University. Using Ganache and Metamask 127.0.0.1:7545 and did a truffle test or migrate it works perfectly. Result: Then, I change my network this is my truffle....
4
votes
1answer
229 views

AssertionError: error message must contain revert

I have tried a lot of research. I still somehow can't find and understand why this error occurs when im in private network. But if in 127.0.0.1:7545 which ganache, everything seems to be working, all ...
0
votes
1answer
56 views

Testing promise in solidity [closed]

}).then(assert.fail).catch (function(error){ assert(error.message.indexOf('revert') >= 0,'msg.value must be less than tokens tokenAvaliable') }) I have the following code in the test ...
0
votes
1answer
188 views

Testing transfer of tokens with truffle

I Have a Token contract: pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol"; contract MyToken is StandardToken{ string public name = "MyToken"; ...