Questions tagged [testing]

questions regarding the testing during development of contracts and DApps

Filter by
Sorted by
Tagged with
2
votes
1answer
13 views

Check emitted event with BN

I'm currently testing events that include numeric values: const level = new BN(1); truffleAssert.eventEmitted(tx, 'EventName', {level}); As you can see, the level variable is a BN, and holds the ...
1
vote
1answer
27 views

What is the best way to deploy and test smart contracts on multiple machines?

I have recently started developement on Ethereum and the concepts are pretty much new to me. I need to test event emitting/listening on multiple machines for my contract. For the same, I have tried ...
0
votes
2answers
23 views

Create fastest possible localhost Ethereum test net

Is there an Ethereum test blockchain (similar to Ganache) which prioritises calculating transactions and creating a local blockchain 'db' as quickly as possible? Requirements: - Calculate ...
2
votes
0answers
24 views

How do I check transaction status using go-ethereum simulated back-end?

Using the go-ethereum simulated backend, I would like to: 1) Instantly commit a transaction so that it either succeeds or reverts in a given simulated blockchain. So far I'm using sim.Commit() to ...
0
votes
0answers
36 views

Unable to deposit ether from External Account to Contract

This is my first question on StackOverflow. I am having trouble sending Ether from an account to the contract. The DApp I am creating is separated into a Data & App contract, where the Data ...
0
votes
2answers
33 views

how to write a test case for msg.sender==0?

In my contract I am use the below mapping. mapping(address => uint)Drivers In the function function registerDriver(uint _perkm) public payable returns(string memory) { require(...
2
votes
1answer
24 views

Can the block number be set back in ganache?

I know about tools like ganache-time-traveler that let you advance the block number. But is it possible to go back to a lower value?
0
votes
0answers
29 views

Can't create eth accounts on wifi by using ganache-cli@v7.0.0-beta.0

I was previously getting out of gas error which was resolved by following this issue. Now i installed ganache-cli@v7.0.0-beta.0 . It creates ethereum accounts on localhost if i write the following ...
0
votes
1answer
50 views

How to validate proper implementation of ERC-1155 contract?

I want to implement an ERC-1155 contract. Using TDD we would first write a test. Which begs the question of is there a way to validate that your contract properly implements ERC-1155?
1
vote
0answers
36 views

Help hacking this contract

This is a very simple contract that I can't hack and I'm stuck, I need some help to get the concepts right. pragma solidity ^0.4.10; contract SimpleToken { mapping(address => uint) public ...
1
vote
2answers
73 views

How to test a custom fallback function using web3.js?

I am trying to implement a proxy pattern. I have a proxy contract and a lottery contract, and I would like the proxy contract to delegate calls to the lottery contract. To test that the function ...
3
votes
0answers
52 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
2answers
41 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
1answer
44 views

Assert.equals() weird behavior does not recognize (apparently) equal strings

I'm facing problems related to string comparison using Assert.equals() provided by remix_tests.sol. I made a toy contract and a related test to show what the problem is: https://gist.github.com/...
0
votes
1answer
42 views

How to get ethereum gasPrice from a transaction hash?

I need to get the gasUsed and gasPrice so that I can calculate the correct amount of gas required for a transaction. I can get the gasUsed using: var accountOneReceipt = await contractInstance....
0
votes
0answers
69 views

Error: types/values length mismatch

I'm following an Ethereum Dapp tutorial in Udemy. I seem to stumble upon an error somewhere early in the course. I was about to deploy my beginner's contract and test it with Mocha when the problem ...
-1
votes
1answer
29 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
22 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
3answers
316 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
1answer
105 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 ...
3
votes
2answers
108 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
64 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
15 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 ...
1
vote
3answers
220 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
40 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
226 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
65 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
31 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
19 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
36 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
156 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
145 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
42 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
16 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
60 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
17 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?
2
votes
1answer
164 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
89 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
470 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
21 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
172 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
25 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
27 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
238 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
16 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
33 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
137 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
239 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
82 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?