Questions tagged [testing]

questions regarding the testing during development of contracts and DApps

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

How to handle a Solidity return value/event in JavaScript test? [duplicate]

I'm trying to create a basic ERC721 NFT, using OpenZeppelin contarct. I started with something similar to their example code: //SPDX-License-Identifier: MIT pragma solidity >=0.4.21 <0.7.0; ...
1
vote
0answers
33 views

Setup brownie to run certain test in a specific network

I am using brownie to run tests and right now my project is using two networks, development and mainnet-fork. I have a test which only runs in mainnet-fork and I am trying to figure out a way to tell ...
0
votes
1answer
11 views

Need of writing tests again and again

I started learning about ethereum and dapps just a week ago.I totally understand the need and importance of writing tests for an ethereum smart contract. But what I didn't understand is that I already ...
0
votes
1answer
30 views

ReferenceError: accounts is not defined

I was using "truffle test" for testing with JS. gives this error. here is the code of that part. it('transfer success', function(){ return Eve.deployed().then(function(instance){ ...
0
votes
0answers
30 views

Remix Compiler Errors - Transferred GitHub .SOL Codes to Remix

I transferred all 23 Sol extension files (smart contracts for Syscoin and Ether) from GitHub to Remix but only 3 of them can be compiled and deployed. The rest of them show errors. [Here is the link ...
0
votes
1answer
25 views

How do I write test assertions for ethereum specific events?

For example, testing for a transaction that reverted or an out of gas error etc. What is the best practice for writing such tests? Specifically, I am using truffle test framework (mocha/chai).
0
votes
2answers
31 views

Best practices on testing an orchestrated contract

Let's define an orchestrated contract as one that contains at least one function that can be called by another contract - and that contract only. The function would implement the restriction like this:...
0
votes
0answers
52 views

Cannot read property 'name' of undefined

const config = require('../truffle-config.js'); const token_parameters = require('../token_parameters.json'); const ExampleToken = artifacts.require('ExampleToken'); module.exports = function(...
0
votes
1answer
19 views

Accessing dynamic variable name - external contract

Contract A wants to call an external contract B/C/D/E/F but the variable name is different within each contract B/C/D/E/F, and contract A does not know the variable name for B/C/D/E/F at the start. ---...
1
vote
0answers
18 views

Is there any free-to-use scenario builder?

The Compound Protocol has a collection of high-level integration tests, dubbed "scenarios": https://github.com/compound-finance/compound-protocol/tree/v2.8.1/spec Which look like this: Test &...
1
vote
0answers
26 views

Time-dependent tests with Buidler?

For Ganache, there are several solutions. What about Buidler? They implemented their own local blockchain, buidlerevm, which is different to Ganache.
0
votes
1answer
47 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
96 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", ...
1
vote
0answers
19 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
38 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
15 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
38 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
23 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
20 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
94 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
83 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
28 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
28 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
32 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
16 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
58 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
39 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
38 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
18 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
318 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 ...
2
votes
0answers
137 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
2answers
145 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
15 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
38 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
75 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
16 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 ...
2
votes
1answer
143 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
2answers
122 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
83 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
34 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
17 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
53 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
65 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
56 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
37 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
46 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
73 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?

1
2 3 4 5
7