Questions tagged [testing]

questions regarding the testing during development of contracts and DApps

Filter by
Sorted by
Tagged with
3
votes
1answer
373 views

Full Integration Testing smart contracts

What is the most agile way to fully integration test smart contract code? I've seen people use shell, etc. Is there a golden standard somewhere?
0
votes
1answer
24 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){ ...
9
votes
1answer
2k views

How can I take a snapshot of Ganache or Truffle Develop state and reload later?

I would like to be able to save the state of my local Ganache or Truffle Develop chains into some sort of file. At a later time, I would like to be able to restart Ganache or Truffle Develop and apply ...
1
vote
2answers
120 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
27 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 ...
1
vote
2answers
107 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
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
1answer
21 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
1answer
37 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
30 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
2answers
197 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 ...
1
vote
1answer
1k views

call function from truffle console (newbie)

This should be fairly simple, but I'm still trying to wrap my mind around a lot of things. What is the easiest way of testing by hand the function addEntity? What command do I type into the truffle ...
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. ---...
2
votes
1answer
335 views

Error: VM Exception while processing transaction: invalid opcode at transfer function

I try test function transfer in my contract. I following by tutorial. Full project locate on my git. It is my test.js code: var SPT = artifacts.require("StepanToken2"); contract("Testing ERC20 ...
0
votes
2answers
129 views

Having trouble figuring out Truffle testing with Javascript

I've started unit testing my contracts with Truffle (using Javascript). I'm fairly new to Truffle and Mocha both, and while I've tried to follow the tutorials, I'm struggling to follow exactly what's ...
1
vote
0answers
17 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
23 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.
1
vote
1answer
64 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 ...
1
vote
1answer
123 views

How could I check value and gas at Geth

My source below pragma solidity ^0.4.17; contract EtherBox { uint balance; constructor () public payable {} function SetBalance() public payable { balance = balance + 10; }...
0
votes
1answer
75 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
2answers
95 views

promise chaining in test.js file

it("should throw an exception if you try to buy an article that does not exist", function() { return ChainList.deployed().then(function(instance) { chainListInstance = instance; ...
2
votes
1answer
161 views

Branch a Truffle test into various Ganache blockchain states

I am currently testing a contract that can evolve in different ways, depending on the interaction between parties. But all these possible scenarios share the same initialization. So, the question I ...
0
votes
1answer
42 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
37 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);...
1
vote
1answer
101 views

Deploying custom code to private network results in “instrinsic gas too low” or “check your gas” errors

TL:DR My first contract fails to deploy reporting variously: Error: intrinsic gas too low undefined Error: The contract code couldn't be stored, please check your gas amount. undefined Having just ...
1
vote
1answer
115 views

Transaction cost in a truffle test

I've a contract under test and the method I'm checking is supposed to transfer an amount, and in order to check I need to have the cost of the transaction. I'm using this code: var tx = await ...
0
votes
1answer
110 views

Truffle testing not reading contract

Here's my solidity: contract Oracle { mapping(uint => uint) oracle_values; modifier onlyOwner { require(msg.sender == owner); _; } function Oracle() public { owner = msg....
1
vote
1answer
265 views

Unable to test Solidity Remix

I am writing my own smart contract in Solidity and trying to test in Remix. The main Remix site appears to be down (https://remix.ethereum.org/). I found another site: https://ethereum.github.io/...
0
votes
1answer
224 views

Vyper: Truffle test read mapping value inside struct

I have the following struct inside my vyper file: races: public({ start: timestamp, end: timestamp, racersBetHash: bytes32[address], racersBetAmount: wei_value[address] }[int128]) Then I ...
0
votes
2answers
76 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() ...
1
vote
1answer
163 views

How to simulate multiple consecutive transactions and get the resulting state?

I'm trying to simulate a transaction on the public blockchain that invokes a contract's method with certain parameters. Then I want to make a follow-up transaction with some other method call. I ...
0
votes
1answer
123 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
1answer
128 views

Testnet password, the same as the real Ethereum wallet?

I want to deploy a smart contract, but I don't know which password to use. Is it the same as my main account on the real Ethereum network? And can I change the Testnet password? I forgot it, but I ...
0
votes
0answers
27 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, ...
0
votes
1answer
214 views

How to chain functions in truffle framework?

I am wondering how to chain functions in truffle testing framework to avoid writing the same code twice. To give an example, I am experimenting with the old version of King of the Ether Throne ...
0
votes
2answers
825 views

Running solidity-coverage with truffle gives error: can not find 'coverageEnv/migrations'

Running solidity-coverage gives the following error: $npm run coverage ... Writing artifacts to ./build/contracts Launched testrpc on port 8555 Running: node --max-old-space-size=4096 ../...
0
votes
1answer
441 views

how to test the TPS in private blockchain

I have set up a private blockchain and I design a new block structure, I want to test the relationship between TPS and block size, are there already some test tools for this use?
3
votes
3answers
2k views

Is there ERC20 token test library?

I have a custom ERC20 token project and I would like to cover the token behaviour with tests. As the ERC20 interface is standardized I wonder whether there are some libraries to test ERC20 ...
1
vote
0answers
14 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
421 views

Deploying new contract inside truffle test case

I was trying to transact between two contracts inside my truffle test case. But not been able to do it. The second contract instance comes back undefined always. As per the truffle documentation, ...
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
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
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, ...
1
vote
3answers
919 views

Truffle Tests Events via JavaScript

I am testing my contract via the chai and truffle-assertions libraries from a JavaScript file and am testing if events return the correct values. I have an event called Message. In my function, the ...
0
votes
1answer
19 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 ...
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 = ...
2
votes
1answer
88 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
72 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; ...

1
2 3 4 5
7