Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [testing]

questions regarding the testing during development of contracts and DApps

0
votes
0answers
20 views

Not storing Item in variable

I am working on making a game where users can collect items. I have chosen to store the ERC721 tokens that represent the items in this way: Item struct: User struct and map that maps account-...
0
votes
0answers
25 views

Help learning contract testing [closed]

Hi im new to the smart contract space and i would appreciate it greatly if anyone could refer me any good materials which i could use to learn smart contract auditing and testing. Thanks.
0
votes
0answers
6 views

Metamask browser apps reusing Truffle tests?

After reading the documentation about metamask (https://github.com/trufflesuite/trufflesuite.com/blob/master/src/docs/truffle/getting-started/truffle-with-metamask.md) is not clear to me whether it's ...
1
vote
2answers
35 views

Trying to test the contracts fully

truffle(develop)> version Truffle v5.0.5 (core: 5.0.5) Solidity v0.5.0 (solc-js) Node v10.15.1 const ApprovalContracts = artifacts.require('../../contracts/ApprovalContracts.sol'); contract ('...
1
vote
0answers
12 views

Is there a way to launch an in-memory Parity private chain?

Is there a way to launch a all-in-memory Parity private chain for purpose of, for example, unit testing?
1
vote
1answer
32 views

how to test overloaded function in truffle?

I recently upgraded truffle to the newest version. Now it does not automatically detect overloaded functions anymore. Before, I could just do the following: await contract.function({ from: accounts[...
2
votes
1answer
26 views

Truffle .call() returns values with array index instead of keys

I am currently writing tests for solidity contract using truffle. When I invoke a function from the contract with .call(), the object that is being returned to me has the values included twice, once ...
2
votes
1answer
50 views

Returns TX Object instead result in Truffle test

I'm getting AssertionError: expected { Object (tx, receipt, ...) } to be true Here is my testing code let apprOrOwnr = await this.erc721.isApprovedOrOwner(owner, tokenId); expect(apprOrOwnr).to....
0
votes
1answer
14 views

Javascript Read Message Value Received

In my smart contract, I have a function that sends ether to the caller using the msg.sender.send() function. I need to check that the value being returned by the function is correct (i.e. the amount ...
2
votes
1answer
38 views

Contract Not Deploying In Truffle Tests

I am trying to do a simple test on Truffle, but it seems that the deployed() promise is never being executed. var MyContract = artifacts.require('MyContract') contract('MyContract', function(...
0
votes
0answers
17 views

Contract Testing: Modifying State variable and using arguments

I tested the following contract on an online tool: pragma solidity ^0.4.24; contract Calculator{ int private lastValue =0; function Add(int a, int b) public returns (int){ lastValue = a+ ...
1
vote
1answer
23 views

Can anyone please help me how can I start with blockchain testing,Deploy application and testing app [closed]

I am completely new to blockchain testing.Can someone please help me with how can I start with blockchain testing and procedure from where I should start and material for the same if possible.
0
votes
1answer
57 views

Unable to test the value from contract using truffle test

block builders! I have trouble testing the return value from my contract, because the return uint value is always a "transaction" object (I actually don't really know what that mean) Here is the ...
0
votes
0answers
12 views

Maian: Concrete validator

I am reading an article related to Maian which is a tool for testing ethereum smart contracts. It says that: Maian, the first tool for specifying and reasoning about trace properties, which ...
0
votes
0answers
29 views

Difference between fuzzing tool and instrumentation tool

I am reading an article related to a smart contract testing tool. I got following: The ContractFuzzer tool contains an offline EVM instrumentation tool and an online fuzzing tool. The offline ...
0
votes
1answer
21 views

SC Truffle Testing: Domain Object Returned?

Working through some tests in Truffle to become more acquainted with the environment but am running into an issue. What I am trying to do Test a smart contract with, among others, the following ...
2
votes
0answers
66 views

Truffle test of two transactions during the same block

I'm trying to test a solidity function that only allows it to be called once per block. E.g. (my desired functionality): Tx1 calls Fn during block #100, and when successful sets a boolean flag for ...
0
votes
1answer
90 views

Solidity test file reaches gas limit due to imports

I have a sol contract X.sol and a sol test file TestX.sol. X.sol is large: ~4m Gas after optimisation TextX.sol compiles, migrates and executes tests fine when just executing a single test - testY, ...
2
votes
1answer
47 views

Ethereum performance using whiteblock

I have recently heard about whiteblock testing platform, however, there is no details on how to build your own test. Do you have any idea about how to use it and how powerful the platform is?
3
votes
1answer
121 views

Evaluate the performance of a smart contract [closed]

What is the best way and tools to evaluate the performance of a smart contract. More specifically, I want to test my contract for large scale deployment by making a script that emulate real world ...
1
vote
1answer
26 views

Where goes eth cost in private chain

I have a private test blockchain with ganache. I deploy one contract and make a couple transactions. Looking at the ganache UI I realized that the first account haves a ether consume to make the ...
1
vote
1answer
46 views

Simple Debug during tests

I'm new in solidity and I'd like to have a little bit of debug. this is my simple example (I'm using web3 1.0) I have a simple function in my contract function bar(address _address_usr) public { ...
1
vote
1answer
31 views

How to test time-dependent contracts on the mainnet?

In Ganache, I use evm_mine to simulate the passage of time. Assuming block times are accurate enough, what are the best practices to test some contracts on the mainnet or a testnet which depend on ...
1
vote
2answers
205 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 ...
1
vote
2answers
175 views

Choosing between Javascript and Solidity for testing smart contracts

Truffle offers two ways to test smart contracts: either using test files written as Solidity contracts, or Javascript/Mocha. https://truffleframework.com/docs/truffle/testing/writing-tests-in-...
1
vote
0answers
50 views

is not contract address during truffle test

I have a stupid smart contract like this: pragma solidity ^0.4.24; contract ProdottoFactory { function foo() view returns(string nome){ return "foo"; } } And I want to test it ...
2
votes
2answers
189 views

Truffle test, logs do not include an emitted event

I am calling a contract function which emits an event in a transaction. This transaction should include the event and is typically visible via: const receipt = await contractInstance.someFunction() ...
0
votes
1answer
122 views

Mocking msg.sender during unit test [duplicate]

I am currently trying to push my unit testing far in order to achieve a complete coverage over my code. I am using Open Zepplin's Ownable.sol contract and I cannot find in the documentation something ...
0
votes
2answers
40 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; ...
1
vote
1answer
95 views

Unit test in truffle fails

pragma solidity ^0.4.23; contract adding{ uint256 public total; function add(uint256 val1,uint256 val2) public returns(uint256){ total = val1+val2; return total; } } The above code ...
0
votes
2answers
247 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 ../...
1
vote
1answer
46 views

fromAccount and web3.js

This is my function in solidity function transferForm(address _from, address _to, uint256 _value) public returns (bool success) { } Now i am calling the same function in test file for testing my ...
0
votes
1answer
102 views

Accessing Contract Variables from JS Unit Tests

I am having trouble unit testing my contracts: I am using Mocha, Chai and calling truffle test I am testing LoanRecord.sol contract LoanRecord { public bool on; ... constructor(...){ ... ...
0
votes
1answer
50 views

Truffle beta Contract.at is supposed to be a promise

I'm trying to test a contract with Truffle beta (because of the new web3 1.0.0 support). When i try to create the contract object by using Contract = artifacts.require("Contract"); contract = ...
0
votes
1answer
86 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 ...
2
votes
0answers
44 views

How to run a test file (.go) from ethereum source?

I have download the ethereum source from github and store the source in directory "~/EthereumSource/go-ethereum". I have install all required software to build the source and successfully build the ...
0
votes
2answers
102 views

Contract state won't change during Truffle tests

I am trying to test my contracts using the Truffle suite, along with Ganache. Up until now, I have been testing contract functions which are restricted to view only. Now, when I attempt to make ...
1
vote
2answers
24 views

block.number during development

I am developing a code that verify if a period of time has passed. I do not need precision. Just to check if aproximately 1hour has passed. I am using block.number. But, I noticed that it is not ...
0
votes
0answers
56 views

Unable to run test cases truffle

I am using truffle tests for my smart contract.I guess there is no problem with contracts because I can compile and deploy them in Remix. I can also run truffle migrate --reset successfully, and it ...
0
votes
1answer
88 views

How do I access the owner's funds in the Truffle test environment?

I'm trying to test my simple coin-based contract in the Truffle test environment by sending funds to the first user's address. My understanding is that the contract is created (thereby calling the ...
1
vote
1answer
164 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/...
1
vote
1answer
32 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; }...
1
vote
1answer
80 views

Contract call with ether and gas fails with revert

Testing with Truffle and solidity on localhost ganache network: Works: function dosomething(string a) { //do nothing } testing with: TokenFactory tf = TokenFactory(TokenFactoryAddress); ...
1
vote
1answer
73 views

Smart Contract execution time through Truffle

I would like to know if there is a way to obtain the smart contract execution time when you send it to the network through Truffle. Is it possible using the test tool? through an application? I know ...
0
votes
0answers
146 views

External js file not getting load in Truffle test

I'm writing up test cases for my smart contract. Here is the folder structure: - bin - build - contracts - mytestfile.sol - modules - mymodule.js - test - mytestfile.js truffle.js I want ...
1
vote
1answer
101 views

Getting storage array data from contract

I have a solidity contract which stores an array of Proposal information: contract Submissions { Proposal[] public proposals; struct Proposal { // .... } } In a test (using ...
1
vote
1answer
56 views

How can I use performance data on Rinkeby to project performance data on the Ethereum Mainnet?

I'm testing a DApp on the Rinkeby testnet, and want to know how well it would perform on the mainnet if I deployed it there, specifically how much gas was consumed by the DApp. Is there any way for ...
1
vote
1answer
730 views

What address deploys a contract in truffle test

I have a contract called AccessControl, in which the owner of the contract is set when it is deployed. I want to test that the method on it setCEO updates correctly, but in order to do this the ...
0
votes
0answers
115 views

Calling ERC223 both transfer functions fail

Given the contracts below (unnecessary code omitted), my tests fail when trying to call the ERC20 transfer() or ERC223 transfer() functions. Why is this happening? Both give Error: VM Exception while ...
1
vote
2answers
111 views

Solidity: fund a test contract

I'm trying to write a test suite in Solidity for a few contracts contained in a single script. I can't alter the code in the contracts - they're not written by me, and I don't have the rights. I would ...