Questions tagged [testing]

questions regarding the testing during development of contracts and DApps

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

Proxy calls are all reverting in test suite despite implementation being set and initialised

I am currently writing an upgradable contract using the unstructured data proxy model and an ERC20 token implementation (similar to USDC). This means the traditional approach of sending a transaction ...
0
votes
1answer
48 views

Invalid address

I deployed my contract in ganache. When I was started to call a function with two arguments I started getting an error. I used an address from ganache. Error: invalid address (arg="user", ...
0
votes
0answers
9 views

How can I inject a custom web3 provider into the drizzle app when using Nightwatch e2e tests?

I have setup a basic e2e test with a Drizzle VueJS app. It appears that when the tests run drizzle uses the fallback option for connecting to the blockchain using web sockets (ws://127.0.0.1:8545). I ...
0
votes
1answer
35 views

How to find the address of the contract owner?

I'm under the impression that the owner of the contract is simply referred to as accounts[0] in Truffle's testing environment, but I'm getting the error by the modifier that the caller of a certain ...
1
vote
1answer
14 views

Why does using {value: 1} in a test results in an exception with no text?

I'm completely new to smart contracts in Etherum. Using Remix I created a small contract that does nothing except require msg.value == 1: pragma solidity >=0.4.22 <0.7.0; contract Danny { ...
0
votes
1answer
35 views

Getting undefined for the length of the dynamic array

I'm getting undefined for the length of multiSig dynimic array, or votes in testing, no matter how many items are pushed into the array. FlightSuretyData.sol address[] multiSig = new address[](0);...
0
votes
0answers
22 views

Getting the “VM Exception while processing transaction: revert” error for a pay() function

I'm getting the following error during the testing in Truffle: Error: Returned error: VM Exception while processing transaction: revert It simply says "revert" without the contingency message, ...
0
votes
0answers
15 views

Embark testing error - FAIL “before all” hook > NaNs > 0 gas > Cannot convert undefined or null to object

I am trying to get tests running and have started with a very simple one that should always pass. However, I am getting an error relating to the account balance. Code for the test is... const UTO = ...
0
votes
1answer
17 views

Is there any other signature mechanism like ECDSA to verify the signed message if its tampered or not?

I would like to know if there are other signature verification methods other than ECDSA, to verify the message (eg., string, number) signed by a signer. Actually if there are alternative algorithms ...
2
votes
1answer
71 views

Why do truffle test gives two different contract address for the same smart contract?

I was practising on a smart contract, and noticed that it gives out two different address for the same contract deployed while testing it. const Test = artifacts.require('./Test.sol'); contract('...
0
votes
1answer
26 views

Could you explain what this require conditions means in this smart contract

I would like to know what exactly this require condition do in this smart contract: function placeBet(uint betMask, uint modulo, uint commitLastBlock, uint commit, uint8 v, bytes32 r, bytes32 s) ...
0
votes
1answer
58 views

Dice2Win Truffle test fails with the message Returned error: VM Exception while processing transaction: invalid opcode

As I was going through the test for the Dice2Win smart contract, It was required to verify few tests, which failed throwing invalid opcode error. The following is the error after running the truffle ...
0
votes
1answer
25 views

Truffle test fails while checking if the contract instance has the owner address

As I was going through the truffle test for the smart contract below to check if it has the owner address: pragma solidity >=0.4.21 <0.7.0; contract Owner { address public owner; ...
0
votes
0answers
25 views

How can I test the placeBet() and settleBet() in ethereum hashdice contracts?

I would like to test the smart contract of hashdice using remix IDE, and using truffle. I wonder how to give the arguments for testing. function placeBet(uint _betMask, uint _modulo, uint _commit, ...
1
vote
0answers
29 views

Testing response times using Ganache

If you want to simulate repsonse time of your smart contract, how realisitc is it to use ganache? I'm thinking that in a live network, ropsten for example, there would be a lot more transactions ...
0
votes
1answer
13 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
39 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
32 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
33 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
17 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 = ...
4
votes
1answer
210 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
55 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
72 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
13 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
27 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
68 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
14 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
1answer
88 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
76 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
67 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
31 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
16 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
46 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
62 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
52 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
34 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
43 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
45 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
50 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
52 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
116 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
40 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
204 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
180 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
152 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
77 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
120 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....
-1
votes
1answer
45 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
29 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
1k 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('...

1
2 3 4 5
7