question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Basic solidity unit tests fail to compile.

See original GitHub issue
  • [ X] I’ve asked for help in the Truffle Gitter before filing this issue.

Issue

Trying to get basic Solidity unit tests working ala http://truffleframework.com/docs/getting_started/solidity-tests but the simplest assert fails compilation

Steps to Reproduce

`pragma solidity ^0.4.17;

import “truffle/Assert.sol”; import “truffle/DeployedAddresses.sol”; import “…/…/contracts/HotokenReservation.sol”;

contract TestHotokenReservationMath { function testSanity() public { Assert.equal(1,1,“One is One.”); } }`

trying to run unit tests results in: ,/home/scherrey/projects/languages/hotoken/test/SolTests/TestHotokenReservationMath.sol:11:9: TypeError: Member “equal” not unique after argument-dependent lookup in type(library Assert) Assert.equal(1,1,“One is One.”); ^----------^ Compilation failed. See above. npm ERR! Test failed. See above for more details.

Expected Behavior

Unit test should compile & pass.

Actual Results

`scherrey@satriani:~/projects/languages/hotoken$ npm test

hotoken@0.1.0 test /home/scherrey/projects/languages/hotoken truffle test

Using network ‘development’.

Compiling ./contracts/HotokenReservation.sol… Compiling ./contracts/math/SafeMath.sol… Compiling ./contracts/ownership/Ownable.sol… Compiling ./contracts/token/BasicToken.sol… Compiling ./contracts/token/ERC20.sol… Compiling ./contracts/token/ERC20Basic.sol… Compiling ./contracts/token/StandardToken.sol… Compiling ./contracts/utils/strings.sol… Compiling ./test/SolTests/TestHotokenReservationMath.sol… Compiling truffle/Assert.sol… Compiling truffle/DeployedAddresses.sol…

Compilation warnings encountered:

/home/scherrey/projects/languages/hotoken/contracts/HotokenReservation.sol:246:13: Warning: Variable is declared as a storage pointer. Use an explicit “storage” keyword to silence this warning. Ledger ledger = ledgerMap[_address][i]; ^-----------^ ,/home/scherrey/projects/languages/hotoken/contracts/utils/strings.sol:474:21: Warning: Jump instructions are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using “switch” or “for” statements instead. jumpi(exit, eq(and(mload(ptr), mask), needledata)) ^—^ ,/home/scherrey/projects/languages/hotoken/contracts/utils/strings.sol:476:21: Warning: Jump instructions are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using “switch” or “for” statements instead. jumpi(loop, lt(sub(ptr, 1), end)) ^—^ ,/home/scherrey/projects/languages/hotoken/contracts/utils/strings.sol:511:21: Warning: Jump instructions are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using “switch” or “for” statements instead. jumpi(ret, eq(and(mload(ptr), mask), needledata)) ^—^ ,/home/scherrey/projects/languages/hotoken/contracts/utils/strings.sol:513:21: Warning: Jump instructions are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using “switch” or “for” statements instead. jumpi(loop, gt(add(ptr, 1), selfptr)) ^—^ ,/home/scherrey/projects/languages/hotoken/contracts/utils/strings.sol:515:21: Warning: Jump instructions are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using “switch” or “for” statements instead. jump(exit) ^–^

/home/scherrey/projects/languages/hotoken/contracts/HotokenReservation.sol:246:13: Warning: Variable is declared as a storage pointer. Use an explicit “storage” keyword to silence this warning. Ledger ledger = ledgerMap[_address][i]; ^-----------^ ,/home/scherrey/projects/languages/hotoken/contracts/utils/strings.sol:474:21: Warning: Jump instructions are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using “switch” or “for” statements instead. jumpi(exit, eq(and(mload(ptr), mask), needledata)) ^—^ ,/home/scherrey/projects/languages/hotoken/contracts/utils/strings.sol:476:21: Warning: Jump instructions are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using “switch” or “for” statements instead. jumpi(loop, lt(sub(ptr, 1), end)) ^—^ ,/home/scherrey/projects/languages/hotoken/contracts/utils/strings.sol:511:21: Warning: Jump instructions are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using “switch” or “for” statements instead. jumpi(ret, eq(and(mload(ptr), mask), needledata)) ^—^ ,/home/scherrey/projects/languages/hotoken/contracts/utils/strings.sol:513:21: Warning: Jump instructions are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using “switch” or “for” statements instead. jumpi(loop, gt(add(ptr, 1), selfptr)) ^—^ ,/home/scherrey/projects/languages/hotoken/contracts/utils/strings.sol:515:21: Warning: Jump instructions are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using “switch” or “for” statements instead. jump(exit) ^–^ ,/home/scherrey/projects/languages/hotoken/test/SolTests/TestHotokenReservationMath.sol:11:9: TypeError: Member “equal” not unique after argument-dependent lookup in type(library Assert) Assert.equal(1,1,“One is One.”); ^----------^ Compilation failed. See above. npm ERR! Test failed. See above for more details. scherrey@satriani:~/projects/languages/hotoken$ git status On branch solidity_unit_test Your branch is up-to-date with ‘origin/solidity_unit_test’.

nothing to commit, working directory clean scherrey@satriani:~/projects/languages/hotoken$`

Environment

  • Operating System: Linux satriani 4.4.0-101-generic #124~14.04.1-Ubuntu SMP Fri Nov 10 19:05:36 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • Truffle version: Truffle v4.0.1 (core: 4.0.1) Solidity v0.4.18 (solc-js)
  • Ethereum client: testrpc
  • node version: v9.2.0
  • npm version: 5.5.1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:7

github_iconTop GitHub Comments

9reactions
onetomcommented, Dec 7, 2017

As the error message suggest it, it’s a method overloading issue. Being more specific about the types allows Solidity to pick exactly one equal implementation:

        Assert.equal(uint(1), uint(1), "One is One.");
4reactions
v-stickykeyscommented, Jul 9, 2018

@scherrey requesting to reopen this

screen shot 2018-07-09 at 1 39 43 pm
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unit Testing Plugin — Remix - Ethereum IDE 1 documentation
Solidity Unit Testing refers to the Solidity Compiler plugin for compiler configurations. Configure Compiler , EVM Version , Enable Optimization & runs ...
Read more >
Unit test compilation failed due member not found or not visible
In solidity you do not have direct access to a different contract properties even if they are public. You have to explicitely call...
Read more >
Tips for Unit Testing Ethereum Smart Contracts in Solidity
some useful tactics for better Truffle smart contract test in JavaScript - grouping test-cases, using random test data, confirming events/reverts and so on....
Read more >
Solidity unit testing using remix-tests -part 2 - Medium
If you are looking to pass custom compiler options for your test contract, you can use the Solidity Compiler plugin to set the...
Read more >
Unit testing and deploying smart contracts with Forge
vm.expectRevert(bytes32) is another cheat code that checks if the next call reverts with the given error message ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found