Questions tagged [truffle-test]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
8 views

Trying to run a truffle test after successful compile I have this Error: Invalid number of parameters for “undefined”. Got 0 expected 1!

Here is my deploy hello js file const hello = artifacts.require('./HelloWorld'); module.exports = function(deployer){ deployer.deploy(hello); }; And here is the contract code pragma solidity^0.5....
0
votes
1answer
17 views

Synchronizing test and web3 enabled nodejs service

I have a test suite running in truffle, and an external web3 connected node service running - both connected to a ganache-cli network. My problem is: my tests are supposed to pick up an event ...
0
votes
0answers
18 views

Truffle Test Error Revert in Contract Factory

I'm trying to create a contract factory that creates "Oracles". Oracles have state variables that are initialized in the contract constructor, and I'm trying to use Truffle Test to verify ...
2
votes
0answers
29 views

How to simulate time increase in Remix IDE?

In my JavaScript tests: module.exports = { increaseTime: (duration) => { const id = Date.now(); return new Promise((resolve, reject) => { web3.currentProvider.send({ ...
0
votes
0answers
23 views

Truffle - multiple transactions per block

i try to simulate a large transaction load and therefore want to execute multiple transactions in a truffle test. I changed the block-time to five seconds and generate the transactions, but only one ...
0
votes
0answers
13 views

Transaction Callback Function Doesn't Run

I'm running the following code as part of a truffle test: electionController = ElectionController.new(districtsNo,districtFactory.address,voteTokenFactory.address); function createVoteToken(...
0
votes
0answers
14 views

SyntaxError when setting instance of deployed contract to token variable

I'm following this tutorial: https://www.youtube.com/watch?v=044h0ZI-fDI At 22:45, the following command is run: DappToken.deployed().then(function(i){token=i;}) In the video, after this command is ...
1
vote
0answers
74 views

Conflicting solc versions on Truffle-test

I'm developing some smart contracts sing solc 0.7.0. I'm able to successfully compile and deploy the contracts, but when I try to run $truffle test I get the following error: Using network '...
0
votes
1answer
21 views

Truffle test. Convert '0x0000000000000000' to zero. Assert it doesn't exist [duplicate]

I am writing a truffle javascript test and I need to test if a key in a mapping was deleted. After deleting it, its values are equal to '0x0000000...' . How can I test in a truffle javascript test ...
1
vote
0answers
62 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
0answers
20 views

truffle solidity unit test modifiers: How do you test modifiers dependent on the sender account?

QUESTION: How do you write unit test code that would test that a non-owner can't execute a function modified by a requirement that they be the owner using in solidity and truffle? I am trying to write ...
1
vote
0answers
27 views

Is Truffle test useful?

Hi there I came across "Truffle test". As a developer I feel like it's better to test code on remix for unit testing rather than wasting time on writing truffle test in javascript. What do ...
0
votes
0answers
38 views

Testing using Truffle unbox: Assert.equal error

I ran the pet shop project. It uses "truffle unbox". The petshop project at: Petshop project using Assert.equal without any error is able to execute Assert.equal command but when I am using ...
0
votes
0answers
37 views

Problem with Assert.equal

I am compiling the code available at using "truffle test": https://michalzalecki.com/ethereum-test-driven-introduction-to-solidity/ pragma solidity 0.5.16; import "truffle/Assert.sol&...
0
votes
0answers
49 views

Truffle test stuck when testing with geth endpoint

I tried to test the truffle suite official metacoin example using truffle test. I opened a local private chain using geth with http rpc service open at localhost:8545. My truffle-config.js file is ...
0
votes
0answers
32 views

truffle test is showing error after running on truffle(develop) console

I am using truffle in windows and everything went well. I've successfully set up development network. But when I try to run test from the truffle(develop) console this error shows - TypeError [...
0
votes
1answer
35 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', (...
0
votes
2answers
45 views

Signature test failed at Truffle js

I'm trying to test validAddress function from my contract ValidationUser, using truffle and test with JS. I checked the V value from the signature and its 27,28 so it is not the problem. Also, I have ...
1
vote
0answers
32 views

Using privateFor in truffle test

Using truffle , I am able to deploy private smart contracts using privateFor clause. However, I am not able to use in truffle test. I get the following error. Is there a way we can use privateFor ? ...
1
vote
1answer
44 views

How to call an overloaded function in Truffle with ABIEncoderV2?

How do you call an overloaded function in Truffle when passing a struct using pragma experimental ABIEncoderV2;? contract MyContract { struct MyStruct { address param1; address param2; ...
0
votes
1answer
37 views

address(this) in solidity is returning wrong contract address

This is my cantract code which I was using in truffle pragma solidity 0.5.16; contract Test { function getAdd() public view returns(address){ address add = address(this); return ...
1
vote
1answer
89 views

Sending transaction from different addresses in truffle test case

I am having an admin in my contract who can do certain things. Here is the contract function changeAdmin(address admin_) public { if (msg.sender != admin) revert(); potentialAdmin = admin_; }...
0
votes
1answer
107 views

What are the accounts generated by Truffle and Ganache? How is the Truffle migration done eactly?

I have a few question regarding Truffle, Ganache, and testing: When I execute truffle develop and get 10 accounts and 10 private keys, do those represent my accounts in my wallet or other users? For ...
0
votes
0answers
59 views

Truffle Error: invalid argument 0: hex string without 0x prefix

I'm trying to deploy and test the smart contracts on the Goerli network using Truffle. While migrating getting below error. Contract: Simple Storage Test suite Simple Storage Set ...
0
votes
2answers
72 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
56 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
0answers
29 views

How can I test the placeBet() and settleBet() in ethereum hashdice contracts?

I would like to test the smart contract of hashdice using remix IDE, and using truffle. I wonder how to give the arguments for testing. function placeBet(uint _betMask, uint _modulo, uint _commit, ...
0
votes
1answer
56 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
0answers
90 views

truffle test fails with `Error: Callback was already called.`

I have a single .sol contract that includes 2 libraries, 1 interface and 3 contracts A, B and C such that B is A and C is A, B. The contract C is the one I am interested in as it includes all the ...
0
votes
1answer
61 views

Truffle Test: Setting blockTime

I'm using Truffle and I want to increase the blocktime to mimic that of the mainnet when i run my tests. As i understand it, Truffle has already instantiated a web3 instance that's ready to use so i ...
1
vote
1answer
56 views

TypeError: tests is not a function Error in Truffle

I am following an online tutorial, doing almost exactly like the instructor. I have the following error every time I try to run 'truffle test' my truffle-config file: module.exports = { // See &...
1
vote
1answer
61 views

Testing solidity transfer method not transferring tokens

I have this solidity contract: contract Token { mapping(address => uint256) public balanceOf; event Transfer( address indexed _from, address indexed _to, uint256 _value ); ...
4
votes
2answers
192 views

How to enhance list of accounts for the Truffle tests to run against Ropsten testnet

I am working on the my contracts testing scripts. But I want to run tests not on the local TestRPC or Ganache but in the Ropsten testnet. How can I predefine a list of accounts (private keys and ...
0
votes
1answer
298 views

Error : Number can only safely store up to 53 bits

Hi I am trying to run the following tests var chai = require("chai"); var chaiAsPromised = require("chai-as-promised"); chai.use(chaiAsPromised); var expect = chai.expect; var Bet = artifacts....
1
vote
1answer
47 views

How to use solidity library with truffle

I'm using truffle V5.1.13 and when I run truffle test the res variable contains a transaction receipt rather than the expected 2. I notice if I remove everything that has to do with the library things ...
0
votes
0answers
18 views

I got the error when I do 'truffle test' in Truffle tutorial that pet-shop-tutorial

I'm doing truffle tutorial the pet-shop-tutorial but when I typed truffle test in cmd, I got the error. Here is the error message. I have no idea how I can fix it and where should I check. Please ...
0
votes
1answer
119 views

Cannot create contract from another contract - truffle and ganache

I'm trying to write a test with ganache and truffle to create a contract instance from another contract. Everything works in Remix but it doesn't in ganache. This is the code const assert = require('...
0
votes
1answer
59 views

Unable to filter events with specific values of indexed parameters

I am currently trying to test a smart contract using the truffle suit ( with 'truffle test'). My contract is of a simple ERC20 token which includes the standard Transfer event: event Transfer(address ...
0
votes
0answers
26 views

How to assign event output to variable when testing?

I'm using Truffle test(chai/mocha) and openzeppelin-test-helpers. Can anyone help me about how to assign values from event to variables in the above testing environment?
0
votes
1answer
35 views

Truffle test: “Cannot read property 'gasUsed' of null” error. Truffle migrate works fine

Whenever I try and do truffle test I get the error Cannot read property 'gasUsed' of null But truffle migrate --reset works fine More confusingly, to rule out something in one of my tests that is ...
1
vote
3answers
248 views

Test using async/await in truffle not working

I am using node v12.13.1, truffle@5.1.8 and ubuntu 18.04 and running the test using documentation of async/await. https://www.trufflesuite.com/docs/truffle/testing/writing-tests-in-javascript#using-...
0
votes
1answer
294 views

TypeError: balance.toNumber is not a function

I need check that token has no balance when selfDestruct was called, but shows an error that balance.toNumber is not a function in the test file. DappTokenSale.sol function endSale() public { //...
0
votes
0answers
194 views

Mocha timeout when running truffle test. Works fine on ganache, not on public networks

This is the error I get when running truffle test --network kovan: 1) "before all" hook: prepare suite Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if ...
4
votes
3answers
88 views

I got this error during migration in truffle. : ParserError: Expected '(' but got identifier

This is my smartcontract code pragma solidity ^0.5.0; contract DappToken{ uint256 public totalSupply; constructor DappToken() public{ totalSupply = 10000; } } This is code for ...
2
votes
1answer
53 views

Check emitted event with BN

I'm currently testing events that include numeric values: const level = new BN(1); truffleAssert.eventEmitted(tx, 'EventName', {level}); As you can see, the level variable is a BN, and holds the ...
1
vote
1answer
71 views

How do I pass a function pointer to a contract method from a unit test?

I'm getting this error: Error: invalid type (arg="type", value="function") when trying to call this method on the contract IntOption: function create( address target, string memory name, ...
1
vote
2answers
50 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
1answer
227 views

Truffle js test a call with arguments

I am trying to testa a smart contract function that receives an arg. I'm using truffle javascript tests, this is the smart contract function, very simple: function addExam(string memory hash) public ...
0
votes
1answer
98 views

Truffle. Test .call() args . Error: invalid string value (…) at PromiEvent

I have a js truffle test: it("should add an exam to the exams list", async () => { // This should test the complete functionality let hash_test = "fB03aA5E2E71De1470ae2"; let instance =...
1
vote
1answer
57 views

Solidity. Truffle test not passing “expected { _events: {},…” to equal

I can't get a test to pass, for me it is very clear but I am missing something obvious: This is the smart contract: function getContractOwner() public pure returns (string memory ...

1
2 3 4 5