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.

2
votes
1answer
30 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
20 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 ...
0
votes
1answer
20 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
26 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
14 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
18 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
38 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
23 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
20 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
18 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
22 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
66 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
23 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
38 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
35 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
14 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
50 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
32 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
92 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
20 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
23 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
69 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
51 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
62 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
54 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 ...
1
vote
1answer
71 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
32 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
20 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
21 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....
3
votes
1answer
151 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
45 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
127 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"; ...
2
votes
2answers
359 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
48 views

How to properly test bytes32 in Javascript testing

How do i address the bytes32 testing issue below? From the code below: coinState = await NewCoin.at(newCoinAddress).getAuthorization(web3.fromAscii("1A2B3C4D5E6F7G8H9I0J")); console.log(coinState);...
0
votes
1answer
82 views

Testing balance of a contract

I'm trying to test the balance of the contract with truffle, but I'm obviously doing something wrong as the test passes. it("should check balance", function() { Lottery.deployed().then(function(...
0
votes
1answer
82 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
51 views

How to check expected exception using .then synchronous calls in web3js-based Truffle tests?

test.js var Test=artifacts.require("./Test.sol"); contract('Test', function(accounts) { it("test case-1 working", function(){ var admin_address=accounts[0]; //admin account initialized ...
0
votes
1answer
102 views

JS Testing and Web3 referencing contract at deployed address

I have a Contract Factory and a sub contract, and now i want to test the newly created sub contract. This one should be pretty simple, I hope. it("test CoinNewCoin - Test Created Coin ", function (){...
0
votes
2answers
88 views

Contract state won't change during Truffle tests

I am trying to test my contracts using the Truffle suite, along with Ganache. Up until now, I have been testing contract functions which are restricted to view only. Now, when I attempt to make ...
3
votes
0answers
46 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
2answers
110 views

Error when running Truffle Test in Terminal

I am trying to use truffle to test my smart contracts and have written some test files. I am getting an error on the terminal trying to run the test and am unsure what the reason is. I access my ...
0
votes
2answers
308 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....
2
votes
2answers
241 views

recipient address is not a contract address

Well, I have a smart contract called Register. The test script is quite straightforward: const Register = artifacts.require("Register") contract('Register', (accounts) => { let register; ...
0
votes
1answer
48 views

Smart Contract Testing

I am writing test driven smart contracts. There is one smart contract with parameterized constructor. And I am using the require statement in the constructor. I want to catch the error in my test ...
0
votes
0answers
130 views

External js file not getting load in Truffle test

I'm writing up test cases for my smart contract. Here is the folder structure: - bin - build - contracts - mytestfile.sol - modules - mymodule.js - test - mytestfile.js truffle.js I want ...
0
votes
1answer
69 views

Revert not throwing error when running truffle test

I have set up a local geth on ubuntu and I'm running my project on it. While writing test cases, I saw that the test cases which were working fine in testrpc environment started facing issues when ...
3
votes
1answer
75 views

3_deploy_contracts.js question

What is a good way to solve my deployment issue: (furtherance of issue: truffle testing problem, migration successful, testing runs out of gas with addition of testing file) When i add the ...
0
votes
1answer
55 views

Error using web3.js from OpenZeppelin

Please, i need help. I am using truffle to test a smart contract. I run "truffle develop", then "migrate". The contract has been stored in the network. Then I run the command "test". An error occurred:...
0
votes
1answer
537 views

“Error: sender account not recognized” when calling transferFrom() on an ERC721 contract

I am having an issue transferring ownership of an ERC721 token to a deployed Holding contract. The error I’m getting when running truffle test is the following - Error: sender account not recognized ...
0
votes
1answer
113 views

Pass parameters into Solidity Constructor from Truffle CONSOLE

How do we pass in constructor parameters to a contract that we want to test? I understand that the initial contract deployment occurs in the migrations file, but if, for testing/debugging purposes, we ...