The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [truffle-test]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
16 views

Call functions from another account by default in web3

In my truffle tests, I am trying to call a function from an account other than the default account, so not accounts[0] from the below result. web3.eth.defaultAccount doesn't seem to work. web3.eth....
0
votes
0answers
22 views

Truffle test including mainnet contract - Error: Cannot create instance of Whitelist; no code at address

Problem with the error Error: Cannot create instance of Whitelist; no code at address 0x6198149b79AFE8114dc07b46A01d94a6af304ED9 How do I have to setup truffle so that I can run a test which includes ...
0
votes
0answers
31 views

Truffle how to test with reference to mainnet smart contract - Error: while migrating VM Exception while processing transaction: revert

I would like to run a truffle test on a smart contract that includes a smart contract address deployed on mainnet. However, this results in the following error Error: Error: Error: while migrating ...
3
votes
0answers
33 views

`eth_getTransactionReceipt` returns the transaction hash not the receipt

I use sol-coverage in a truffle project. Ganache is my development blockchain. I have a lot of tests which end up doing more than a few thousand JSON RPC calls. Due to unbeknownst reasons, the ...
1
vote
1answer
122 views

Simple Truffle tests timeout “before all” hook: prepare suite

I'm trying to write my first tests for truffle, but I run in a timeout each time I want to execute the tests. Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is ...
1
vote
2answers
25 views

How do I specify the network ID in the config file when migrating/testing contracts on my local ganache?

So my issue is when I run the compile and then migrate commands everything goes smooth, then I try to test by running the truffle test command and it gives me an error saying 'Error: The network id ...
1
vote
0answers
46 views

What is the easiest way to write truffle tests in typescript?

I read about Typechain, but the configuration is rather verbose and generally feels like a very custom solution: Everytime you change contracts you need to run yarn generate.
2
votes
1answer
43 views

How to trace the line where a tx failed in truffle tests?

I know about 0x's sol-compiler and sol-trace. I used them before and they do exactly what I'm looking for, but these modules bring significant overhead when used with truffle. Check out this file to ...
-1
votes
2answers
86 views

Truffle uint test script not updating storage variable, and strange behaviour

while testing I got a strange behavior of truffle, please see the subject smart contract code first uint256 public burningRatePercent = 50; function onlyOwnerSetBurningRate(uint256 ...
1
vote
1answer
17 views

Does truffle test mimic the exact network state of an actual migration?

I've defined a truffle migration step as follows: Deploy my 'main' smart contract, nothing out of the ordinary: var UniversityVoting = artifacts.require('./UniversityVoting.sol'); module....
0
votes
1answer
30 views

How does a transaction verified with Truffle test?

I'm a new to Ethereum and Solidity, and I don't understand how Truffle executes transaction calls. From what I learned and understood, if I try to use a contract method which changes the contract's ...
1
vote
1answer
99 views

Error when testing the contract

ApprovalContract.sol pragma solidity ^0.5.1; contract ApprovalContract{ address public sender; address payable public reciever; address public constant approver=...
0
votes
1answer
46 views

totalSupply doesn't pass test

I'm starting programming. I wanted to do my first contract and I assigned totalSupply to 1000000. pragma solidity ^0.5.8; /** * The DappToken contract Constructor Set the total number of tokens ...
1
vote
2answers
35 views

Contract.deployed() does not work as expected

I use Truffle to test a contract. When i use Contract.deployed() and i fetch address, for example : In a first test, the contract's address is 0x07D899846146b3503dE9D9Dc36B94C2e428eA434 In a second ...
1
vote
3answers
173 views

Testing sha256(abi.encodePacked(_argument))

When trying to test a smart contract that uses sha256(abi.encodePacked(_myargument)) I don't get the same hash on truffle ! I tried both web3.utils.keccak256('_myargument') web3.utils.sha3('...
3
votes
2answers
80 views

How to test events that were sent by inner transaction / delegate call?

Usually, using truffle I can check for events like this: let { logs } = await myContract.doSomethingImportant( xxx ); // 1500 tokens are expected to get expectEvent.inLogs(logs, '...
1
vote
1answer
27 views

ERC20 RefundableCrowdsale

I have a crowdsale contract that inherits RefundableCrowdsale.sol from OpenZeppelin. I was using their v1.10.0 initially, but now revamping it using v1.12.0. contract TestTokenCrowdsale is Crowdsale,...
0
votes
1answer
25 views

truffle won't run tests while initializing a global contract instance

I am testing my smart contract in truffle. I need to declare some global variables hence I did so outside 'it'. I also tried declaring a global contract instance that I can use in all test cases. ...
0
votes
1answer
43 views

truffle testing enum

I am trying to test an enum value from a test. This is simplified version of the contract: pragma solidity >=0.5.0 <0.7.0; contract Foo { enum State { StateA, StateB } State ...
1
vote
1answer
42 views

Event declaration which fix my tests

I'm going to try to put this in simple. This is the code of my contract: pragma solidity ^0.5.0; contract Lottery { address public manager; address[] public players; event Deposit(...
1
vote
3answers
91 views

A single exception in Truffle test causes every other test cases to fail

I'm making test script for my contract and it looks likes contract('...', async () => { let token = null; before('deploy', async () => { token = await MyContract.new(...); })...
1
vote
1answer
184 views

Which network does truffle use for testing?

I have a network 'foo' that is configured inside truffle.js. Running my tests works just fine truffle test --network foo ./test/*.js then I realized I forgot to start 'foo'. To confirm this running ...
0
votes
2answers
264 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' ------...
1
vote
1answer
254 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
15 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
176 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
93 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
133 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
77 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
109 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
188 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
27 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
51 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
168 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
58 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
70 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 ...
2
votes
1answer
146 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
105 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
81 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
307 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
415 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
2answers
226 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
62 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
127 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
31 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
168 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
2answers
293 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
62 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
66 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
52 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); } ...