Stack Exchange Network

Stack Exchange network consists of 174 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.

1
vote
1answer
22 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
23 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
41 views

Evaluate the performance of a smart contract [on hold]

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
14 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
17 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
0answers
29 views

Truffle Solidy based testing fails

I am new to testing the smart contract in solidity. Just for my understanding I have used Assert.notEqual in 1 test and Assert.equal in another test. I guess both are failing. I also have a question ...
0
votes
1answer
13 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
0answers
29 views

function assigning wrong variable

I have a function to set an address variable to a contract address to only accept payments from. When the function is called truffle is showing that the variable is staying at null and ever weirder a ...
0
votes
1answer
27 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
30 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
28 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
38 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
0answers
22 views

Testing on Truffle: call back was already called

I am trying to test a contract using truffle. My contract code is: pragma solidity ^0.4.22; contract MyContract5{ uint public mynumber; constructor ( ) public { mynumber = 24; } ...
0
votes
1answer
29 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
18 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
20 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....
2
votes
1answer
58 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
0answers
19 views

not able to test smart contract

I am getting this error when testing my smart contract. sometimes I am getting this error and sometimes its working fine "before all" hook: prepare suite: Uncaught Error: VM Exception while ...
0
votes
0answers
41 views

Error: VM Exception while processing transaction: revert (in the context of a test contract)

I am trying to execute a test given at: assert, require and revert I am getting following message and exception: truffle(development)> test Using network 'development'. Compiling .\contracts\...
0
votes
1answer
27 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
75 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
128 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
25 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
39 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
66 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
43 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
40 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
38 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
43 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, ...
1
vote
1answer
76 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
200 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
212 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
39 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
88 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
60 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
68 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
49 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
314 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
84 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 ...
0
votes
1answer
127 views

onlyOwner and testing question

I'm struggling with this modifier as well as one I'd like to use for some other contracts. I figure if I understand why this is a problem I can probably get the rest right. I can compile, migrate (...
0
votes
2answers
77 views

Contract is not defined in truffle tests

I am trying to test one of my contracts, but truffle complains that it is not defined. I can see that the test compiles to the build folder, and I have imported it the same way as other contracts, I ...
2
votes
2answers
64 views

Error: Invalid number of arguments to Solidity function - I'm pretty sure the number of arguments is correct?

General problem: Using double linked list. Because of block gas limits, I call a function off-chain to find the exact insertion point. https://github.com/genesisdotre/ethereum-auction Branch: no-...
0
votes
2answers
131 views

How to pass msg.sender and constructor params in truffle tests?

I have the following constructor: constructor(address _payee) public { payer = msg.sender; payee = _payee; } And this function in my JavaScript tests: beforeEach(async () => { ...
1
vote
0answers
32 views

Truffle test onlyOwner contract methode [duplicate]

I'm trying to write a truffle test which checks if the transfer of the ownership for a contract works correctly. So after I transfered the ownership I call a contract methode again with the account ...
1
vote
1answer
68 views

Specify address for transaction in truffle test

I want to specify the address I perform a transaction with in my truffle test. My test looks approximately like this: contract('Test contract', async (accounts) => { let contract; ...
1
vote
1answer
18 views

Truffle test failing due to different data type than expected

I am using truffle and ganache to make a token demo for myself. I'm following this guide then making my own changes according to my project. When I try running tests to verify that my contract is ...
0
votes
0answers
70 views

Truffle test: passing an uint256 causing incorrect result

To simplify my question, let's say I have a Test.sol with this function: function testFunc(uint256 value) public pure returns (uint256) { return value; } Now I want to test it in truffle it('...
1
vote
2answers
40 views

Returning dynamic arrays: out of gas

I'm trying to return a dynamic array of structures from a Solidity function to a client. Since I need to build the result, I'm declaring a storage variable and add elements to it: function ...
4
votes
1answer
298 views

Contract factory function running out of gas during Truffle test

Using openzeppelin library and truffle I am trying to make a Contract Factory that creates ERC20 tokens. I prefer to test it with Truffle using solidity and not javascript. Here is the code from the ...
0
votes
0answers
28 views

Get performance measures from my private blockchain

I would like to get the performance of my private blockchain and I am not sure how to get the measures (as latency or the time of execution of a contract). Is it possible through Truffle or Geth?