Questions tagged [truffle-test]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
0 answers
17 views

Can't pass Truffle test with an uint256 array as event property

I have this simple test in truffle: it("should emit the correct Transfer event", async function() { await this.contractNFT.multiSafeMint(accounts[0], "CID/metadata.json", 3, {...
viac92's user avatar
  • 33
0 votes
0 answers
23 views

How to transfer money inside truffle console?

When I log in to the truffle console I see there are a bunch of addresses filled with money. I need to transfer an amount to the account that I am using with Metamask. (I don't want to import the ...
Mirat Can Bayrak's user avatar
1 vote
0 answers
22 views

Deactivate clean-room environment in truffle

Everything is in the question, does anyone have a way to prevent the redeployment of the contract every time you run a test and keep using the same "contract" feature ? Edit : I've found it, ...
Raphael's user avatar
  • 41
0 votes
0 answers
32 views

Truffle migrations - it doesn't recognize the network from external file, why?

1_initial_migration.js file: const Globals = require("../globals.js"); const Migrations = artifacts.require("Migrations"); const Test = artifacts.require("Test"); ...
Radek_pl's user avatar
  • 761
1 vote
1 answer
35 views

What are the Solidity contracts that the Infura NFT SDK uses? How can one test these contracts?

I am trying to make use of the Infura NFT SDK that would work with another contract that I developed. I wanted to make some unit tests locally, however, searching on their documentation and on the ...
PensoGlide's user avatar
0 votes
0 answers
131 views

How ganache unlocks account that doesn't belong to me?

In ganache mainnet fork, I can unlock any account and make transactions on behalf of that account: npx ganache-cli -p 8545 -f https://mainnet.infura.io/v3/$WEB3_INFURA_PROJECT_ID --unlock $...
Mr.Snow's user avatar
  • 13
1 vote
1 answer
220 views

Error: *** Deployment Failed *** "Migrations" -- Returned error: no pending block

When i run "truffle test" in VS on my basic helloworld smart contract, i get the error message: "Error: *** Deployment Failed *** "Migrations" -- Returned error: no pending ...
Golanger's user avatar
0 votes
1 answer
197 views

Truffle/Ganache Gas Limit Increase [duplicate]

I had posted on the GitHub Discussion as well. I have this massive smart contract and my goal is to study the scalability of the contract. The values work for smaller sizes. However, it fails at ...
Harish Karthikeyan's user avatar
1 vote
1 answer
106 views

About try-catch error(Truffle Test)

I am learning solidity by transcribing code from "Practical Smart Contract Development with Solid and Etherium"(OREILLY). I am studying hard but struggling along the way. It is to be tested ...
kintoki's user avatar
  • 15
0 votes
1 answer
63 views

Truffle: { Error: Invalid number of parameters for "undefined". Got 0 expected 1! at module.exports

I am trying to execute the following smart contract using Truffle: pragma solidity 0.5.16; contract Phishable { address public owner; constructor (address _owner) public{ owner = ...
zak100's user avatar
  • 1,416
1 vote
1 answer
121 views

Why am I getting incorrect WBTC when swapping it with DAI using Uniswap?

Hi I created a smart contract but when I am swaping 1 Million DAI with WBTC tokens I am getting only ~3379786784 WEI (~34 WBTC) but when I am checking its value on UNISWAP website it is showing 43 ...
Vinay Kharayat's user avatar
1 vote
0 answers
55 views

Unit testing a double mapping

How to call a double mapping in unit tests? Here is an extract of our contrat: contract StackingPool { struct Staker { uint128 amount; // Amount token stake uint256 date; // Date ...
Jean's user avatar
  • 21
0 votes
1 answer
129 views

"Error: Returned error: VM Exception while processing transaction" when I run truffle test

I'm running my unit test with truffle in ganache environment. Here's my Lottery SC: pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@...
Federico's user avatar
0 votes
1 answer
111 views

"insuffiecient allowance" running my unit test

I'm developing in remix a lottery SC. I have a problem when I run buyTicket() function. On remix I fix it giving approve to SC address from erc20 function, but I don't know how to do it when I run my ...
Federico's user avatar
0 votes
1 answer
94 views

Error: No events were emitted

I am coding an ICO project. However when trying to make the token purchase I got the following error: Using network 'test'. Compiling your contracts... =========================== > Compiling .\...
Lê Văn Thành's user avatar
1 vote
1 answer
17 views

Passing an error testing suite in contract

hello how do i make a proper testing suite for error? the contract has this modifier for freeMint() fn modifier protectTier(uint256 _level) { require( _level != privateTier, &...
Dell Watson's user avatar
0 votes
1 answer
107 views

Truffle Struct Test How To Call

how to call struct properties in truffle test ? for public variables we can use .call() but i cant figure out how to do with struct properties how to access properties of struct ? with any other ...
Imaad Irshad's user avatar
0 votes
1 answer
125 views

truffle test does not run tests when test network is not specified

trying to run a test for my contract, but truffle test is just compiling the contracts and not running anything. my truffle.config does not specify a test network, which should result in truffle ...
scheherazhaad's user avatar
1 vote
0 answers
11 views

Truffle test, is it possible and useful to test types?

All is in the question : is it possible and useful and to test types ? Or don't need to test it because Solidity is a statically typed programming language (it's already done). I did many researches ...
Jean's user avatar
  • 21
0 votes
2 answers
148 views

How to use truffle-assertions to check if a constructor will revert?

Say I have a contract: contract Reverts{ constructor(param1){ require(param1); } } If param1 is false, the constructor should fail and revert state. truffle-assertions allows me to ...
Expectator's user avatar
0 votes
1 answer
52 views

Storage arrays don't store my input values

I checked other similar topics but I still can't figure out how to solve my problem, the code below is part of my contract, pragma solidity ^0.8.13; contract MyContract{ address owner; ...
Ali özdede's user avatar
0 votes
1 answer
290 views

Testing `approve` function

I would like to test a contract where I use the approve function of an ERC20 token. Is there any test suite that allows doing that? truffle? hardhat? Any suggestion would be highly appreciated!
Abramodj's user avatar
  • 101
1 vote
1 answer
113 views

How to write the javascript test code on whether a smart contract function is successfully executed or not?

I wrote a lottery smart contract and gonna to test an "enter" functionality of the smart contract. The below code is javascript test code for the "enter" function of the smart ...
enthusiastic's user avatar
1 vote
1 answer
2k views

why vs code not recognizing the node version

when I install a "truffle for vs code" extension in vs code and try to create a new solidity project then nodejs version is not recognized but I have installed nodejs's correct version.
Hitesh's user avatar
  • 21
0 votes
1 answer
437 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 ...
RodrigoR's user avatar
0 votes
1 answer
309 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 ...
Alberto Molina's user avatar
1 vote
1 answer
297 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 ...
Prabhat Dongare's user avatar
0 votes
1 answer
94 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\...
Prabhat Dongare's user avatar
2 votes
0 answers
82 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 '...
null_user's user avatar
0 votes
1 answer
43 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 ...
Rodrigo Pina's user avatar
0 votes
1 answer
66 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 ...
Adam k's user avatar
  • 11
0 votes
0 answers
46 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:\...
iappmaker's user avatar
  • 813
1 vote
0 answers
95 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... =...
Soyaya's user avatar
  • 31
1 vote
0 answers
104 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 ...
Munkh-Od Ganzorigt's user avatar
0 votes
1 answer
823 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 ...
dkni8mare's user avatar
1 vote
1 answer
68 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 ...
fahadh4ilyas's user avatar
0 votes
1 answer
81 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 ...
jvinai's user avatar
  • 1
0 votes
2 answers
1k 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 ...
Zachary Denham's user avatar
0 votes
1 answer
414 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() ...
BlockChain Learner's user avatar
0 votes
1 answer
101 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 ...
brt88's user avatar
  • 1
1 vote
1 answer
117 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) { ...
Xstahef's user avatar
  • 157
0 votes
1 answer
16 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. ...
Luis Masuelli's user avatar
1 vote
1 answer
743 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 ...
G.G.'s user avatar
  • 133
0 votes
1 answer
293 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(...
israel.sincro's user avatar
3 votes
1 answer
590 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; ...
Leo_95's user avatar
  • 33
1 vote
1 answer
762 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 . . ├──...
blnks's user avatar
  • 165
1 vote
1 answer
898 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 ...
armen.shimoon's user avatar
0 votes
0 answers
81 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 ...
zak100's user avatar
  • 1,416
0 votes
1 answer
406 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 ...
zak100's user avatar
  • 1,416
1 vote
2 answers
3k 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 useful as I'm in the development of useful tests. As mentioned it is about ...
Ndrslmpk's user avatar
  • 112

1
2 3 4 5 6