Questions tagged [truffle-test]

The tag has no usage guidance.

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

Assertion Error

Solidity file pragma solidity ^0.5.0; contract Todo { struct User { uint id; string name; } User[] public users; uint public nextId = 1; function create(string memory name) public ...
0
votes
1answer
19 views

ERC721 testing transferFrom()

How can I test (truffle test or development console) the following: await nft.transferFrom(accounts[0], accounts[1], 1); await nft.transferFrom(accounts[1], accounts[0],1); The second line throws ...
0
votes
1answer
18 views

How can I test my purchase function on the truffle with chai?

I'm trying to test my token buying function but I encounter an error, o facilitate understanding I will show the code "Error: Returned error: VM Exception while processing transaction: revert&...
0
votes
1answer
18 views

Setting token balances in js test

I want to be able to set the token balance for Alice to 500 DAI & 500 USDT, however I have no clue how I am going to do that. Is there a way you can set an account's balance before a test without ...
0
votes
0answers
18 views

Transferring aToken(aDAI) in my truffle tests reverts with unspecific error

I'm having issues with setting up a truffle test to transfer aTokens (aDAI) to my contract. I'm using Aave v2 and running ganache with a fork from mainnnet. This is what I did so far: 1- Started a ...
0
votes
1answer
11 views

Interacting with existing Smart Contract deployed on test network like rinkeby from local test environment (truffle)

I have forked rinkeby network using ganache-cli as shown below ganache-cli -f https://rinkeby.infura.io/v3/id --account="fsdfmsadklksmdflskamf" Now, I want to test my smart contract which ...
0
votes
1answer
12 views

Use smartcontract's ENUM in test scenarios in truffle

I have create a truffle project with this command: truffle unbox react Here is my smartcontract contracts/SimpleStorage.sol : contract SimpleStorage { enum MyEnum { step1, step2, ...
0
votes
1answer
20 views

Big numbers in truffle test assertion

Here is what i've done: I have create a project this way: truffle unbox react npm install @openzeppelin/test-helpers I have keep SimpleStorage.sol sample contract and here is my test file: const { BN,...
0
votes
0answers
15 views

Set a gas limit when sending a transaction in a truffle test scenario

I am writing truffle tests for a smartcontract. I have create a truffle project with this command: truffle unbox react I have kept SimpleStorage.sol sample smartcontract. I have add some tests in ...
0
votes
1answer
17 views

Difference between contract.new and contract.deployed functions

I have create a basic truffle project and i am writing automated tests. There is 2 ways to instantiate the smartcontract to test and i want to understand the difference between this 2 ways: const ...
-1
votes
1answer
15 views

sync function syntax [closed]

What is the difference between this syntax: beforeEach( async () => { ... }); and this one: beforeEach(async function() { ... }); Thanks
0
votes
1answer
25 views

Truffle test: could not find local build/contracts

I have create a truffle project with this command: truffle unbox react I have run this commands: npm install @openzeppelin/contracts npm install @openzeppelin/test-helpers npm install @openzeppelin/...
2
votes
1answer
34 views

Why do my truffle tests get much slower as I run more of them?

So I am currently building up a test suite for a project, and I have quite a few tests at this point. I am running into a problem however that truffle seems to run tests later in its execution much ...
0
votes
1answer
16 views

Truffle test: Problem with understanding the test

I am trying to understand the test provided at: Tutorial ("Test balance after deposit", function() { return SimpleBank.deployed().then(function(instance) { sb = instance; ...
0
votes
0answers
24 views

Truffle test doesn't recognize estimateGas function

I'm trying to test my contracts using Truffle and Ganache, but I'm facing some problems with some functions. When I call a non view function, I'm getting the error "out of gas". Moreover, if ...
0
votes
2answers
14 views

Issue deploying a contract successfully with Truffle and ganache

Long story short my contract is not passing the deployment test using truffle, mocha, and chai. I ran the code individually in the truffle console and it was returning an address just fine but it won'...
0
votes
0answers
19 views

Wrong contract balance shown by web3.eth.getBalance

I want to test if the balance updates when I send some eths it("the balance matches the price of a person", async function(){ let instance = await People.deployed() await instance....
0
votes
1answer
26 views

Truffle Test AssertionError: error message must contain revert

I can't figure out why this error occurs Here my test js code: var YarockToken = artifacts.require("./YarockToken.sol"); contract('YarockToken', function(accounts) { var tokenInstance; ...
0
votes
0answers
298 views

Metamask RPC error -32603… {“error”:“revert”,“program_counter”:6758,“return”:“0x”}

I have a dApp that leverages ERC721 contract which allows users to upload images onto IPFS and transfer them to each other. User A can upload images fine and transfer them fine to User B. Once ...
1
vote
1answer
19 views

How to resolve the issue while trying to test my contract

I'm new to blockchain development and can't figure out what I have done wrong. This is my smart contract Election : pragma solidity ^0.5.0; contract Election { struct Candidate { uint ...
0
votes
0answers
30 views

Truffle “test” is passing only 1 it(“”) test instead of showing “all 3 tests passed”

MyToken.sol //// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract MyToken is ERC20 { constructor(uint256 ...
0
votes
0answers
23 views

“before each” hook error while run truffle test command

I ran truffle test command on my project for testing but I got an error like this: "before each" hook for "1- should be return true Pauser Role for account[0]" why I'm getting ...
2
votes
2answers
27 views

Importing openzeppelin-test-helpers

Somethings I need BN library for correct balanceOf assertion with 1e18 decimals, somettimes expectRevert. I see the different projects use it differently: const { constants, time, ether, expectRevert }...
0
votes
0answers
10 views

truffle deployer - addess is still there without deploy

First Question: // Stage deploying A before B deployer.deploy(A); deployer.deploy(B); This is found on the truffle website. It says stage deploying A before B. So this must mean that deploying B ...
0
votes
1answer
64 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
19 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
24 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
35 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
113 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 ...
2
votes
0answers
199 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
22 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
1answer
132 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
54 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
30 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
52 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
56 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
95 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
43 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
138 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
55 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
37 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
68 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
50 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 ...
2
votes
1answer
268 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
354 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
107 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
249 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
80 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 ...

1
2 3 4 5