Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [truffle-test]

The tag has no usage guidance.

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

Truffle Test Console Logging

I'm having some trouble with Truffle logging configuration. During tests, each submitted transaction and its hash is logged on the console and this one becomes full of useless messages that disturb ...
user avatar
0 votes
1 answer
25 views

Truffle default account private keys

Is there a way in truffle develop tests to access the list of private keys in the same way we can access the list of accounts? Basically, for every contract I need to test, the truffle test contract ...
user avatar
1 vote
0 answers
22 views

truffle installed but not working

I'm using node version 12.20.2 and npm version 6.14.11 and installed truffle with cmd as administrator, the truffle framework version 5.5.12 has been installed but when I run any command in the vs ...
user avatar
0 votes
0 answers
34 views

swapExactTokensForTokens() throws error when use it in my truffle test file for testing

I forked uniswapV2 contracts and tried to use them on my project. I tried to test them using truffle test file. I started with creating 2 tokens tokenA and tokenB to create a pair and add amount to ...
user avatar
0 votes
1 answer
28 views

unable to install truffle

I'm trying to install truffle on node version 8.9.0 but it shows it has been installed and when I try to do anything on that, throws this error. C:\Users\com\AppData\Roaming\nvm\v8.9.0\node_modules\...
user avatar
1 vote
0 answers
12 views

Eth-gas-reporter typeError

I am trying to understand how the eth-gas-reporter works but I keep getting TypeError: invalid reporter 'eth-gas-reporter' when I ran truffle test. Specifically the output is: Using network '...
user avatar
0 votes
0 answers
10 views

Unable to obtain lock when running Truffle tests

When I run truffle test, my tests run fine, but I obtain an error that looks like the following, consistently. NOTE: I'm using the truffle-upgrades library and deploying transparent upgradeable proxy ...
user avatar
0 votes
1 answer
15 views

Why is there a difference in ether sent and difference in balance before and after transaction?

I'm doing a simple Dapp where I register a star as an NFT, using openzeppelin ERC721 contract, and then I can put it up for sale and buy it. In truffle I'm writing a test where I create a star, put it ...
user avatar
0 votes
1 answer
28 views

Requires working strangely / truffle / tests

My contract // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.13; import '@openzeppelin/contracts/access/Ownable.sol'; contract GuessAndWin is Ownable{ string public hint; string ...
user avatar
  • 11
0 votes
0 answers
25 views

TypeError: Cannot destructure property 'toBN' of 'web3.utils' as it is undefined

i am having trouble testing a solidity smartcontract, the test was originally written in truffle i am using hardhat with its truffle plugin to run the test. this is the test file
user avatar
0 votes
0 answers
22 views

How can I use ts script from another project in truffle tests

I have a project which has 2 parts, onchain and offchain. Onchain - staking contract. Offchain - scheduled ts script for calculations. I want to write test which includes this ts script. This is how ...
user avatar
0 votes
0 answers
23 views

Issue in test-environment install

I tried to install test-environment, it throws the error. Please advice on how to solve this. npm ERR! enoent undefined ls-remote -h -t https://github.com/ethereumjs/ethereumjs-abi.git PS E:\...
user avatar
  • 623
1 vote
0 answers
42 views

Truffle test throws an error in "before each" hook

Developing a flash loan which i use truffle to test my code, david@LAPTOP-3KIH2P0K:/mnt/c/pr0/flash/FlashloanLeveragedYieldFarm$ truffle test Using network 'development'. Compiling your contracts... =...
user avatar
  • 11
1 vote
0 answers
65 views

Truffle Testing, Javascript & Solidity Testing Use Case

I’ve been studying the truffle documentation and saw how little differences were detected between the way solidity testing and javascript testing works. This confuses me as a developer, the ...
user avatar
0 votes
0 answers
23 views

Truffle test environment explanation - Clean Envronment

Hi Ethereum Community, I have a quick question regarding Truffle testing environments. As stated in their website "Truffle will use advanced snapshotting features to ensure your test files don't ...
user avatar
0 votes
1 answer
178 views

mintNewPosition function of LiquidityExamples contract (Uniswap docs - V3) get reverted when trying to add liquidity

I am trying to interact with Uniswap V3 contracts. More specifically, I am trying to add liquidity to DAI - USDC pool. I am doing this locally by forking the Mainnet using ganache. This is my contract ...
user avatar
1 vote
1 answer
32 views

Why Contract State not Persisted in Every Test Sequentially?

I have a smart contract in truffle project and want to test it. I have multiple tests sequentially which means contract's state after first test will be needed for the second test. The problem is, it ...
user avatar
0 votes
1 answer
37 views

Truffle Test: Using a contract instance as function parameter

I'm having a function IN A LIB that require a contract as parameter. function createCalendarEntry(uint256 releaseTime, SPToken token) public pure returns (CalendarEntry memory) { return ...
user avatar
  • 1
0 votes
1 answer
151 views

How to Automate End to End Testing For Etherium Dapps With Metamask?

I'm wondering what the best way to test the entire stack of a dapp is? From UI -> to wallet connection -> web3.js and interacting with the smart contract? In web2 we could just use something ...
user avatar
0 votes
1 answer
31 views

toNumber is not a function while writing tests

I am trying to write a simple test to validate a condition, however it fails saying 'toNumber is not a function' Here is the test condition const quorum = await wallet.quorum; assert(quorum.toNumber() ...
user avatar
0 votes
1 answer
40 views

Javascript testing vs remix

So what would be the benefit of testing the smart contracts using javascript with truffle instead of remix? I just feel is really tedious. I'm guessing there is a reason, but I don't see it, so should ...
user avatar
  • 1
1 vote
1 answer
22 views

How test uint from smartcontract with chai?

In my solidity smartcontract, I have a function to return a uint value : function getUserBalance(address userAddress, address tokenAddress) public view returns (uint256) { ...
user avatar
  • 157
0 votes
1 answer
9 views

How do I assert this properly?

Say I want to make a test for this sample contract: // assume we import OpenZeppelin's Ownable contract Metaverse extends Ownable, ... { ... // Assume this is just to experiment and learn. ...
user avatar
0 votes
0 answers
118 views

Error: Returned error: VM Exception while processing transaction: revert Transaction failed -- Reason given: Transaction failed

I am following a youtube tutorial for coding a smart contract for a MultiSigWallet. The code is working fine in Remix. All the functions, submitTransaction, confirmTransaction and executetTransaction ...
user avatar
0 votes
0 answers
16 views

Should I test the flattened ERC20 contract in truffle?

I have an ERC-20 contract that I have deployed successfully on the Rinkeby testnet. I have also successfully verified the contract so that I can interact with it on Etherscan. I am learning Truffle ...
user avatar
  • 21
1 vote
1 answer
172 views

Signing messages in Truffle tests

I use Truffle to develop locally and run tests with truffle test (letting it create a temporary local blockchain). In one of my tests I need to sign a message and for that I need the test wallet's ...
user avatar
  • 133
0 votes
0 answers
59 views

Truffle test: How to Calculate transfer Gas cost to be 2300 wei?

I am using gasleft() function. I am storing the gasleft() before transfer and gasLeft() after transfer, and then finding the difference. But I am getting wrong result maybe 7554. Somebody please guide ...
user avatar
  • 1,205
0 votes
1 answer
147 views

withdraw function for withdraw ethereum token from a contract is behaving weird

I copy a withdrawal function from the solidity documentation and added it to my contract function withdraw() public onlyOwner { uint256 ownerBalance = address(this).balance; require(...
user avatar
0 votes
1 answer
101 views

Cannot retrieve uint Array from Struct in Solidity

I have the following struct in my contract struct Transaction { TransactionType transactionType; uint256 id; uint256 productId; uint256 timestamp; address from; address to; ...
user avatar
  • 3
0 votes
0 answers
5 views

Is there a way to debug "Error: while migrating ... Returned error: base fee exceeds gas limit"?

I have got this error before when I wrongly typed a variabe. I managed to debug the issue by commenting out regions of code. Is there a better way? The stack trace is not helpful: at /home/christian/....
user avatar
1 vote
1 answer
158 views

Error: Could not find artifacts for contract

I'm new to ethereum development and trying to test SimpleStorage contract using truffle: I created file structure using turffle init and here is the files sturctur: ~/Desktop/truffle-test$ tree . . ├──...
user avatar
  • 125
0 votes
1 answer
327 views

How to increase block.number in a truffle solidity test?

Is there any way to increase the block.number (e.g. mine a block) in a solidity based truffle test? I am able to do this just fine with a javascript based test by making an RPC call to the evm, but I ...
user avatar
0 votes
0 answers
37 views

Truffle Test: Again (Error: Returned error: VM Exception while processing transaction: revert) with different SC

I posted a similar problem at: similar with different SC but sorry no solution yet Following are my smart contracts (SCs) == SC F1 pragma solidity 0.5.16; contract F1{ address public owner; uint ...
user avatar
  • 1,205
0 votes
0 answers
153 views

TypeError:Exactly one argument expected for explicit type conversion: Should I use 'new' keyword or not?

I have got following contracts: Sender: pragma solidity ^0.5.8; contract sender{ address owner; constructor () public{ owner = msg.sender; } function transferTo(address to, uint amount) public{ ...
user avatar
  • 1,205
0 votes
0 answers
101 views

How to solve: VM Exception while processing transaction revert: maybe because my sender does not have any Ether?

I have two smart contracts (SCs): sender and receiver and a tester. I am using truffle test. I don't know how to send Ether to a SC using truffle test. The sender has no Ether balance. Maybe this is ...
user avatar
  • 1,205
0 votes
1 answer
174 views

How to access mapping array and address of contract in truffle test

I have 3 contracts: sender, receiver and transferTest. I am getting error in transferTest due to an address array declared in the reciver contract: receiver.sol: pragma solidity ^0.5.8; contract ...
user avatar
  • 1,205
0 votes
1 answer
539 views

truffle test - Error: Contract has not been deployed to detected network (network/artifact mismatch)

As I excessively read all posts given and none solved my problem I'm opening this thread. Please don't consider every test for useful as I'm in the development of useful tests. As mentioned it is ...
user avatar
1 vote
2 answers
997 views

How do I actually test a mint function using Truffle and the payable modifier in Solidity

I'm creating a smart contract and trying to test it using Truffle. I'm a little stuck on how to call the mint function ( how to actually execute the transaction from the test function ). I know Im ...
user avatar
0 votes
0 answers
171 views

Error in testing contract with javascript on truffle

I'm trying to test a contract multiple times on truffle using javascript. The first test runs just fine, but the second gives me error no matter what's inside of it. Here is my full testing code: ...
user avatar
  • 111
0 votes
1 answer
16 views

Nothing Happens When Run "truffle test" in terminal

When I try to run "truffle test" on any contract, nothing happens in the terminal, it just waits as if it's loading or something. I have tried this on the simplest of contracts. Any ideas?
user avatar
1 vote
1 answer
327 views

How can I mock ERC20 in build-in truffle test suite?

I want to test my contract using truffle test which required a mock ERC20. I've found this example in Github and also this thread. const ERC20 = artifacts.require("ERC20"); I've tried but ...
user avatar
  • 133
1 vote
0 answers
69 views

Sign Transaction with Zero Address

I am writing and testing a smart contract. Using web3, I could not send a transaction from a Zero Address (0x0). I was wondering if it is ever possible to sign and send a transaction using the zero ...
user avatar
0 votes
0 answers
247 views

How to test with existing ERC20 tokens on local tests

I have a Solidity smart contract for NFTs that I need to test using Truffle Suite. While deploying the contract on Rinkeby, I provide it with an existing ERC20 token contract address that I use for ...
user avatar
0 votes
0 answers
77 views

Error: "This method only supports Buffer but input was..." when trying to test my solidity contract [duplicate]

Running the test suite will cause an error. The Error: Compilation finished successfully An unexpected error occurred: Error: This method only supports Buffer but input was: ...
user avatar
0 votes
1 answer
18 views

Issue running approve test

I need some assistance running the approving test. Currently running one of the basic test script to approve the token from exchange. I am getting the below attached err in WSL. Also, i believe the ...
user avatar
0 votes
1 answer
161 views

smart contract how link libraries to child contract under factory pattern

I am trying to create a factory and I can not find a way to link libraries to the child contract. I am trying to create a contract factory that create child contracts. the problem is that the child ...
user avatar
0 votes
0 answers
52 views

Testing state variables with Truffle (javascript)

I have a contract that defines a struct and has an internal function to create it such as struct Tokemon { string name; uint256 id; uint256 dna; uint32 level; uint8 rarity; ...
user avatar
0 votes
1 answer
281 views

How to test sending transaction from zero address in truffle

I have some smart contract which has this function: function someFunction() external returns (uint256) { require(msg.sender != address(0), "zero address"); //some code.... ...
user avatar
1 vote
1 answer
37 views

Testing address(this) generates exception, how to obtain the correct value for address(this)

I have modified the following code from a michalzalecki website https://michalzalecki.com/ethereum-test-driven-introduction-to-solidity/ to test address(this): pragma solidity 0.5.16; import "...
user avatar
  • 1,205
1 vote
1 answer
217 views

Private keys & not buffer being passed to test file

I'm running a test on a very simple pool contract. I am using Mocha to write the tests, but Hardhat's network to run them. After firing up my Hardhat node I get the 10 test accounts per usual with ...
user avatar
  • 45

1
2 3 4 5 6