Questions tagged [testing]

questions regarding the testing during development of contracts and DApps

-1
votes
1answer
11 views

Truffle ganache error

I have this error~! Contract has not been deployed to detected network (network/artifact mismatch) Can you help me thank you!
0
votes
1answer
13 views

remix test inside a ubuntu environment

Im trying to make some test using the remix test library. I create a VM with a Ubuntu Server 18.04 I update the system to latest version and I install npm and node. I generate a folder with the ...
1
vote
2answers
32 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('...
0
votes
0answers
30 views

Timeout w/ Mocha on deploying a contract

Starting to build the following test suite for a contract. It deploys fine on Remix. I get the following error message. 1) "before each" hook for "deploys a contract": Error: Timeout of 20000ms ...
1
vote
1answer
27 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, '...
0
votes
0answers
31 views

Is it possible to access MetaMask functionality for integration testing?

I'd like to be able to access MetaMask to test potential user actions. I doubt it's possible to directly simulate sending transactions, but what I hope I can at least confirm is that transactions are ...
0
votes
0answers
12 views

Testing a Smart Contract on two different devices at the same time

So the goal is to have two computers each owning one account or just different addresses on MetaMask for example and connecting them to the same Smart Contract that is deployed on Rinkeby. Now how ...
0
votes
2answers
60 views

Increase block number on Ganache

How can we increase block.number on Ganache for testing purpose ? If not possible do you know an alternative like passing X fake transactions to artificially increase block.number. Or if we have to ...
0
votes
0answers
27 views

Building Prysm on Windows

I'm currently following the steps to build Prysm from the instructions on Github: https://github.com/prysmaticlabs/prysm At the step for building the beacon chain I ran this command: bazel build //...
1
vote
1answer
50 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
1answer
38 views

.transfer fails

Trying to call .transfer() within a function makes it fail. I am aware that the difference between .send() and .transfer() is that .send dont throw. The function works properly when using .send(), but ...
1
vote
1answer
20 views

Notation in npm solidity-coverage tests

I had been using the npm package solidity-coverage and while reading the coverage reports I came up with this E symbol. I am not sure what it means and there is no explanation in the documentation as ...
0
votes
0answers
18 views

I am looking for testing framework which is capable of creating test scripts for smart contracts(solidity) automatically [duplicate]

Is there any testing tool which is capable of handling smart contracts and can generate test scripts for given contracts based on function present in that contract? End user only need to provide ...
0
votes
1answer
31 views

Accessing one smart contract contained in another smart contract from javascript

I'm cross-posting this from Stack Overflow, since there seems to be more activity here. I am trying to develop a dApp with Truffle and want to test my smart contract. The contract contains a second ...
1
vote
1answer
72 views

Deploy new contract through another contract function in Truffle

I have a function in my contract minter.sol that creates another contract etnX.sol: function createNewContract(string memory name, string memory symbol, uint256 _maxSupply) public onlyOwner { ...
0
votes
2answers
79 views

Can I automate the truffle (smart contracts) test scripts?

As we all aware about smart contract testing using truffle framework. Currently, we are writing the test scripts either in solidity or in java-script manually. Is there any way so that I can auto ...
2
votes
1answer
33 views

How can you deploy a contract using the non-interactive mode?

I have a contract written in remix, but I am trying to deploy it using Geth's non-interactive mode using geth attach ipc:<path> -exec "<contract deploy info>". When I am in interactive ...
0
votes
0answers
20 views

Not storing Item in variable

I am working on making a game where users can collect items. I have chosen to store the ERC721 tokens that represent the items in this way: Item struct: User struct and map that maps account-...
0
votes
0answers
12 views

Metamask browser apps reusing Truffle tests?

After reading the documentation about metamask (https://github.com/trufflesuite/trufflesuite.com/blob/master/src/docs/truffle/getting-started/truffle-with-metamask.md) is not clear to me whether it's ...
1
vote
2answers
52 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 ('...
1
vote
0answers
16 views

Is there a way to launch an in-memory Parity private chain?

Is there a way to launch a all-in-memory Parity private chain for purpose of, for example, unit testing?
1
vote
1answer
84 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[...
2
votes
1answer
51 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
209 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....
0
votes
1answer
18 views

Javascript Read Message Value Received

In my smart contract, I have a function that sends ether to the caller using the msg.sender.send() function. I need to check that the value being returned by the function is correct (i.e. the amount ...
2
votes
1answer
127 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
0answers
20 views

Contract Testing: Modifying State variable and using arguments

I tested the following contract on an online tool: pragma solidity ^0.4.24; contract Calculator{ int private lastValue =0; function Add(int a, int b) public returns (int){ lastValue = a+ ...
1
vote
1answer
24 views

Can anyone please help me how can I start with blockchain testing,Deploy application and testing app [closed]

I am completely new to blockchain testing.Can someone please help me with how can I start with blockchain testing and procedure from where I should start and material for the same if possible.
0
votes
1answer
136 views

Unable to test the value from contract using truffle test

block builders! I have trouble testing the return value from my contract, because the return uint value is always a "transaction" object (I actually don't really know what that mean) Here is the ...
0
votes
0answers
15 views

Maian: Concrete validator

I am reading an article related to Maian which is a tool for testing ethereum smart contracts. It says that: Maian, the first tool for specifying and reasoning about trace properties, which ...
0
votes
1answer
26 views

SC Truffle Testing: Domain Object Returned?

Working through some tests in Truffle to become more acquainted with the environment but am running into an issue. What I am trying to do Test a smart contract with, among others, the following ...
3
votes
0answers
104 views

Truffle test of two transactions during the same block

I'm trying to test a solidity function that only allows it to be called once per block. E.g. (my desired functionality): Tx1 calls Fn during block #100, and when successful sets a boolean flag for ...
0
votes
1answer
155 views

Solidity test file reaches gas limit due to imports

I have a sol contract X.sol and a sol test file TestX.sol. X.sol is large: ~4m Gas after optimisation TextX.sol compiles, migrates and executes tests fine when just executing a single test - testY, ...
2
votes
1answer
62 views

Ethereum performance using whiteblock

I have recently heard about whiteblock testing platform, however, there is no details on how to build your own test. Do you have any idea about how to use it and how powerful the platform is?
3
votes
1answer
219 views

Evaluate the performance of a smart contract [closed]

What is the best way and tools to evaluate the performance of a smart contract. More specifically, I want to test my contract for large scale deployment by making a script that emulate real world ...
1
vote
1answer
29 views

Where goes eth cost in private chain

I have a private test blockchain with ganache. I deploy one contract and make a couple transactions. Looking at the ganache UI I realized that the first account haves a ether consume to make the ...
1
vote
1answer
49 views

Simple Debug during tests

I'm new in solidity and I'd like to have a little bit of debug. this is my simple example (I'm using web3 1.0) I have a simple function in my contract function bar(address _address_usr) public { ...
1
vote
1answer
40 views

How to test time-dependent contracts on the mainnet?

In Ganache, I use evm_mine to simulate the passage of time. Assuming block times are accurate enough, what are the best practices to test some contracts on the mainnet or a testnet which depend on ...
1
vote
2answers
362 views

Truffle Tests Events via JavaScript

I am testing my contract via the chai and truffle-assertions libraries from a JavaScript file and am testing if events return the correct values. I have an event called Message. In my function, the ...
1
vote
3answers
311 views

Choosing between Javascript and Solidity for testing smart contracts

Truffle offers two ways to test smart contracts: either using test files written as Solidity contracts, or Javascript/Mocha. https://truffleframework.com/docs/truffle/testing/writing-tests-in-...
1
vote
0answers
50 views

is not contract address during truffle test

I have a stupid smart contract like this: pragma solidity ^0.4.24; contract ProdottoFactory { function foo() view returns(string nome){ return "foo"; } } And I want to test it ...
3
votes
2answers
495 views

Truffle test, logs do not include an emitted event

I am calling a contract function which emits an event in a transaction. This transaction should include the event and is typically visible via: const receipt = await contractInstance.someFunction() ...
0
votes
1answer
198 views

Mocking msg.sender during unit test [duplicate]

I am currently trying to push my unit testing far in order to achieve a complete coverage over my code. I am using Open Zepplin's Ownable.sol contract and I cannot find in the documentation something ...
0
votes
2answers
58 views

promise chaining in test.js file

it("should throw an exception if you try to buy an article that does not exist", function() { return ChainList.deployed().then(function(instance) { chainListInstance = instance; ...
1
vote
1answer
158 views

Unit test in truffle fails

pragma solidity ^0.4.23; contract adding{ uint256 public total; function add(uint256 val1,uint256 val2) public returns(uint256){ total = val1+val2; return total; } } The above code ...
0
votes
2answers
389 views

Running solidity-coverage with truffle gives error: can not find 'coverageEnv/migrations'

Running solidity-coverage gives the following error: $npm run coverage ... Writing artifacts to ./build/contracts Launched testrpc on port 8555 Running: node --max-old-space-size=4096 ../...
1
vote
1answer
50 views

fromAccount and web3.js

This is my function in solidity function transferForm(address _from, address _to, uint256 _value) public returns (bool success) { } Now i am calling the same function in test file for testing my ...
0
votes
1answer
179 views

Accessing Contract Variables from JS Unit Tests

I am having trouble unit testing my contracts: I am using Mocha, Chai and calling truffle test I am testing LoanRecord.sol contract LoanRecord { public bool on; ... constructor(...){ ... ...
0
votes
1answer
55 views

Truffle beta Contract.at is supposed to be a promise

I'm trying to test a contract with Truffle beta (because of the new web3 1.0.0 support). When i try to create the contract object by using Contract = artifacts.require("Contract"); contract = ...
0
votes
1answer
103 views

Vyper: Truffle test read mapping value inside struct

I have the following struct inside my vyper file: races: public({ start: timestamp, end: timestamp, racersBetHash: bytes32[address], racersBetAmount: wei_value[address] }[int128]) Then I ...