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:
- Created 6 years ago
- Reactions:6
- Comments:7
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:@scherrey requesting to reopen this