Questions tagged [testing]

questions regarding the testing during development of contracts and DApps

Filter by
Sorted by
Tagged with
0
votes
0answers
10 views

Metamask doesn't allow me to approve transactions

Metamask does'nt allow me to click on confirm when I wan't to approve a transaction. (i.e. the Confirm button is disabled and stays disabled whatever I do) Because "Confirm" is disabled I ...
0
votes
1answer
14 views

TypeError: Cannot read property 'providers' of undefined: Truffle & Web3

Here is the necessary part of the code, from where I keep receiving the following error: const { Web3 } = require("web3"); const web3 = new Web3(new Web3.providers.HttpProvider('http://...
1
vote
1answer
19 views

TDD Solidity: expect internal struct state

I'm a big fan of TDD/BDD so I figured hardhat and chai/waffle are a good start to learning smart contract development. I've run into an issue though where I'm wondering what best practice would be to ...
0
votes
1answer
43 views

How to unit test when a function depends on hardcoded deployed contract address?

I've been writing unit tests for a contract using Hardhat + Ethers + Typescript, let's call it ContractA. This ContractA has a hardcoded address of a deployed ERC20 token in it like this TokenA = '0x.....
1
vote
1answer
28 views

Changing contract property to public increases gas costs

I am following kind of an outdated tutorial and trying to adapt it to the more recent changes in Solidity and other packages. Following one of my changes, I am running into a problem that I can't find ...
0
votes
1answer
17 views

Testing the functions of an instance contract with truffle

I have contract A and contract B with the following structures: contract A { int x; function setX(){ x = _x; } } contract B { A[] contractInstances; function ...
0
votes
1answer
19 views

Setting token balances in js test

I want to be able to set the token balance for Alice to 500 DAI & 500 USDT, however I have no clue how I am going to do that. Is there a way you can set an account's balance before a test without ...
0
votes
1answer
156 views

How to interact with the functions of my smart contract in Hardhat?

I am learning to program in Solidity and have followed a basic tutorial on creating a smart contract from a number counter. The tutorial was followed by using Remix and I was very clear about the ...
0
votes
1answer
38 views

Limit gas in brownie automated tests

I have create a brownie project with automated tests according to this documentation: https://vyper.readthedocs.io/en/stable/testing-contracts-brownie.html#writing-a-basic-test Here is an example: def ...
0
votes
1answer
15 views

error comparing numbers in smart contract (Big Number)

I am unable to understand when all do we need to convert numbers to bigNumbers for asserting to be equal. In some cases by mistake i missed to convert integer variables to bigNumber and they worked ...
0
votes
1answer
29 views

Perimeter of mocha, waffle and chai

Here is what i've understood (please tell me if i am wrong): Mocha (mochajs.org) is a testing framework Waffle (getwaffle.io) is another testing framework chai: This is not a framework, this is a ...
0
votes
1answer
506 views

Ethers.js testing: Giving hardhat generated accounts ETH

Deployment √ Should set the contract's address as owner (44ms) √ Should assign the totalSupply of credits to the creditsContract (114ms) Transactions 1) Should fail if sender ...
0
votes
0answers
10 views

toNumber in test.js

I am creating a test.js for my smart contract. I forgot to use "toNumber" while testing some uint variables to be equal in some cases and it executed without any error. So in what all cases ...
0
votes
0answers
74 views

Why is the allowance 10**8 inside the test but equal to zero in the smart contract?

I'm running this test: def test_mint(prf, exValue, web3): wBtcAddress = "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599" ABI = [{"constant":True,"inputs":[],"...
0
votes
0answers
17 views

dapp without test.js

We can test our smart contract in remix and can perform several workflow checks before putting the contract in the final sol file in the dapp project. This way we can ensure that everything is in ...
0
votes
1answer
28 views

Using openzeppelin-test-environment to test upgradeable contract

openzeppelin-test-environment is quite a new package, it doesn't tell how to initialize the upgradeable contract https://github.com/OpenZeppelin/openzeppelin-test-environment Just a basic example from ...
1
vote
0answers
36 views

Maian Tool Repository on Docker: How to store contract retrieved from etherscan.io and what is ‘test.sol’

I am in the MAIAN tool repository on docker. The link at : MAIAN Tool GitHub Link They provided details of how to execute the MAIAN tool from docker. I am in the MAIAN tool repository on docker. They ...
1
vote
1answer
21 views

How to resolve the issue while trying to test my contract

I'm new to blockchain development and can't figure out what I have done wrong. This is my smart contract Election : pragma solidity ^0.5.0; contract Election { struct Candidate { uint ...
0
votes
0answers
81 views

Feedback on Implementing Merkle Airdrop for Rug Pull Victims

Summary: Developed a smart contract that enables the GovernorDAO Community to un-rug the CBDAO Rug Pull victims by providing them with a Merkle Distribution Airdrop. Over 1/3 of an already-minted ...
2
votes
1answer
46 views

Load testing Besu + IBFT2?

The context: I have a simple app that that consults historic of events frequently. It works fine on my development machine, with just a few thousands blocks. I am not sure if it will continue to work ...
0
votes
0answers
67 views

gas_estimate returning error for too man arguments

running Web3 5.13; python 3.9; Mac 10.15.7 Trying to run test on solidity contract based on the example provided in teh Web3.py docs. When running this I receive an error stating TypeError: ...
0
votes
1answer
107 views

Truffle test: getting Transaction Object instead of uint result

I have a method in my contract like so: mapping(address => uint256) allowance; ... function setAllowance(address user, uint256 amount) external onlyOwner nonReentrant returns (uint256) { ...
0
votes
0answers
16 views

Testing issue with mocha

I am having some mocha tests and trying to run them, I am on TS these are my two test file code import { Signer } from "@ethersproject/abstract-signer"; import { ethers, waffle } from "...
2
votes
1answer
77 views

Truffle Test: Simply comparing BigNumber to String works, but WHY?

Reading from this post, one should not use toNumber() when working with uint256, so when writting the below test, I was expecting it to crash, but it does not, instead it runs to success! why ? it(&...
0
votes
1answer
203 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
1answer
74 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
14 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
183 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
132 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
40 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).
1
vote
2answers
91 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
281 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
27 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
24 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 &...
4
votes
1answer
330 views

Time-dependent tests with Hardhat?

For Ganache, there are several solutions. What about Hardhat? They implemented their own local blockchain, Hardhat Network, which is different to Ganache.
0
votes
1answer
127 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 ...
1
vote
1answer
267 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
42 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
49 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
27 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
27 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
188 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
45 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
124 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
57 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
33 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
68 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 ...

1
2 3 4 5
7