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.

0
votes
1answer
20 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
12 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
15 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....
1
vote
1answer
14 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
11 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
23 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
0answers
16 views

Error in test file in vscode file not found

With truffle 4.0.5 on windows, test files fail to "import" with error: Error ParserError: Source "truffle/Assert.sol" not found: File not supplied initially. import "truffle/Assert.sol"; ParserError:...
0
votes
1answer
17 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
55 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"; ...
1
vote
2answers
37 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
17 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
29 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
43 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
41 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
23 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
19 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
41 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
38 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
116 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
129 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
31 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
55 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
45 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
65 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
0answers
31 views

Error using web3.js from OpenZeppelin

Please, i need hepl. I use truffle to test 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
149 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
55 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
111 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
50 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
1answer
51 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
85 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
27 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
45 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
15 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
43 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
33 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 ...
3
votes
1answer
201 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
24 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?
1
vote
1answer
147 views

How to get require message in a test case? Truffle test

For instance I'm running testcase for a smart contract and it's test function has required validation. function test(uint _id) public pure returns(bool){ require(_id == 0 ,"not valid!"); ...
0
votes
2answers
58 views

Mocha test at kill() function

How to test with Mocha and Chai that a call at the kill() function of a Smart Contract (i.e., which does the selfdestruct) has gone right?
0
votes
1answer
226 views

Error: VM Exception while processing transaction: out of gas - Truffle

I'm facing some issue with test cases, I wrote some simple function in my smart contract as following: function Create ( bytes32 _a, address _b, string _c, address[] _d, uint256[]...
0
votes
0answers
107 views

Error: Transaction:exited with an error (status 0) after consuming all gas

New to Ethereum and learning unit testing with Truffle. Here in smart contract function; function createAgreement( bytes32 _id, address _owner, string _fileHash, ...
0
votes
1answer
36 views

Truffle Test: How to Run n times the same function

Since I have to study the variation of the gasUsed of a function, using Truffle Test is it possible to do a test that runs n times the same function without going out of gas or exceding the block gas ...
0
votes
0answers
62 views

Error: VM Exception while processing transaction

I've got an errors while purchasing token with my test network, and the message is rpc error with payload, and an VM Exception while processing transaction. Is my contract wrong or my function wrong? ...
0
votes
1answer
363 views

Truffle test: How to test Ether transfer? Balance of specific account?

How is it possible to test if my contract actually transfers money to a specific account? function _transfer(address receiver_, uint256 payout) internal{ receiver_.transfer(payout); } Testing in ...
1
vote
2answers
56 views

How to get a transaction fee in a Truffle test

I would like to test a Solidity function that looks like this and check if a correct amount of ether was sent to a sender: function withdraw() public { uint contributed = amounts[msg.sender]; ...
1
vote
1answer
98 views

Better ways to test bytes32 type using truffle testing framework

small quick question, when I store a bytes32 and retrieve it from truffle console, why is it showing in 64 bits? Ex: 0x74657374737472696e6700000000000000000000000000000000000000000000 because this ...
0
votes
0answers
76 views

How to write balance of test-case in Truffle

I'm learning Truffle framework. I have created one sample contract MyToken pragma solidity ^0.4.17; contract MyToken{ mapping(address => uint) balanceOf; event valueLogger(uint); ...
0
votes
1answer
103 views

Truffle Test: How to send ether to a contract from a contract?

Would like to test the modifier below modifier isNotAContract(){ require (msg.sender == tx.origin, 'Contracts are not allowed to interact.'); _; } How can I invoke a function using this ...
2
votes
1answer
49 views

Interacting with a Custom Token Contract

I seem to be having problems interacting with a custom token contract. I am using truffle and ganache for my testing. I am trying to interact with the custom token contract so MyContract can ...