Questions tagged [testing]

questions regarding the testing during development of contracts and DApps

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

Getting a, “ReferenceError: artificats is not defined” - Error running a simple “approver” test

(Working from the Lynda Ethereum course) Running the test code below I get the following error: truffle tests Warning: Both truffle-config.js and truffle.js were found. Using truffle-config.js. ...
1
vote
1answer
20 views

Testing solidity transfer method not transferring tokens

I have this solidity contract: contract Token { mapping(address => uint256) public balanceOf; event Transfer( address indexed _from, address indexed _to, uint256 _value ); ...
0
votes
0answers
26 views

Truffle test using multiple connections

I am running a test which involves sending transactions to a smart contract from multiple nodes. Right now, I have seperate truffle folders in each node, with a test file that sends the transactions ...
0
votes
1answer
23 views

Smart contract transaction takes different amounts of gas on different platforms

I have an ERC-20 token contract on which I want to perform some testing on a local chain. I got my chain setup, contract deployment and testing scripts ready on my Windows machine. However, since I ...
0
votes
0answers
15 views

How can you test with a mock when the address is hard coded in the real contract?

For testing purposes, is there any way to replace a contract referenced by a hardcoded address with a mock? I'm defining an interface in my contract address interfaceAddress = 0x...; IInterface if = ...
3
votes
1answer
62 views

Alternatives for Truffle for running and writing tests

Truffle offers many conveniences for writing tests for Ethereum smart contracts. The benefits include no need for a separate chain process like Ganache, complex automation of linking and deploying of ...
1
vote
0answers
23 views

Best way to run tests in Truffle for contracts that rely on mainnet dependencies?

I could create mocks of the dependencies but I'd really like to be able to fork mainnet using Ganache in a way similar to this (https://medium.com/@samajammin/how-to-interact-with-ethereums-mainnet-in-...
1
vote
1answer
31 views

Watching events with truffle test

Given following solidity code: pragma solidity ^0.5.1; contract Foo { event FooInc(uint256 _a); uint256 a; constructor() public { a = 42; } function inc() public ...
0
votes
0answers
11 views

Geth automining does not fill blocks to maximum

I am running a throughput test on a private geth blockchain. The test sends 500 transactions rapidly and then waits for their confirmations in order to measure transactions per second. However, I've ...
0
votes
0answers
16 views

Problem with executing Commands related to Mythril installation from Docker based Tutorial

I have found following link to install mythril through Docker: Installing Mythril using Docker The page asks to execute following two commands: $ docker run mythril/myth -dc "0x6060" I am getting ...
0
votes
2answers
46 views

Measuring deployment time of a group of transactions in a heavy load testing

I am currently trying to perform heavy load testing on a ERC20 token. My plan is to use truffle to test stuff like how long it would take for 500 transfer transactions to be deployed (on a private ...
0
votes
0answers
12 views

Executing ContractFuzzer

I am trying to execute contractfuzzer. I found the link: [contractFuzzer link][1] The above link provides link to following page: docker container page but all the information is in a chinese ...
1
vote
0answers
25 views

How to mock an ethers provider while testing with jest?

In the real app, I'm using the web3-react hook to inject the provider, etc. How do I best mock that/replicate that in a Jest Typescript environment?
1
vote
1answer
28 views

Mocha assertions not returning correctly on assert.equal with BN

Is this an issue with deep matching/object identity? AssertionError: expected <BN: 204fce5e3e25026110000000> to equal <BN: 204fce5e3e25026110000000> It seems strange that chai.should ...
0
votes
2answers
48 views

Truffle best practices - unit vs integration tests

Think about having two contracts: MockToken Faucet (which takes token address as constructor parameter) To unit test Faucet I would create two new instances: const token = await MockToken.new() ...
0
votes
0answers
27 views

Testing of 2 Smart Contracts using Truffle

I'm writing 2 smart contracts: one is a satellite of the other. That is contract A is calling contract B. When I migrate in truffle all is OK, but when I try to run the tests it is not working. Is ...
1
vote
0answers
14 views

Geth's golang contract bindings need “RPC subscription features that are still under review” to process event logs. What are those features?

The documentation for Geth's golang contract bindings start out with Please note, events are not yet implemented as they need some RPC subscription features that are still under review. What ...
2
votes
1answer
33 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
36 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
43 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 ...
3
votes
0answers
27 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
38 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
36 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
36 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
40 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
97 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
37 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
139 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 ...
4
votes
0answers
108 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 ...
2
votes
2answers
84 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
60 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
71 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
77 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
37 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
23 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
672 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
152 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
159 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, '...
1
vote
0answers
70 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
17 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
293 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
51 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
307 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
73 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
36 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
39 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
208 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
180 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
43 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 ...

1
2 3 4 5
7