Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Tests fail when running on solc 0.8.0 or above #309

Closed
xJonathanLEI opened this issue Jun 7, 2021 · 2 comments · Fixed by #310
Closed

Tests fail when running on solc 0.8.0 or above #309

xJonathanLEI opened this issue Jun 7, 2021 · 2 comments · Fixed by #310

Comments

@xJonathanLEI
Copy link
Contributor

cargo test fails with errors when the installed solc version is 0.8.0 or above:

running 2 tests
test ds_proxy_code ... FAILED
test ds_proxy_transformer ... FAILED

failures:

---- ds_proxy_code stdout ----
thread 'ds_proxy_code' panicked at 'could not compile DSProxyFactory: SolcError("Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing \"SPDX-License-Identifier: <SPDX-License>\" to each source file. Use \"SPDX-License-Identifier: UNLICENSED\" for non-open-source code. Please see https://spdx.org for more information.\n--> tests/solidity-contracts/DSProxy.sol\n\nWarning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it \"abstract\" is sufficient.\n  --> tests/solidity-contracts/DSProxy.sol:20:5:\n   |\n20 |     constructor() public {\n   |     ^ (Relevant source part starts here and spans across multiple lines).\n\nError: Explicit type conversion not allowed from \"int_const 0\" to \"contract DSAuthority\".\n  --> tests/solidity-contracts/DSProxy.sol:51:33:\n   |\n51 |         } else if (authority == DSAuthority(0)) {\n   |
                ^^^^^^^^^^^^^^\n\nWarning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it \"abstract\" is sufficient.\n  --> tests/solidity-contracts/DSProxy.sol:94:5:\n   |\n94 |     constructor(address _cacheAddr) public {\n   |     ^ (Relevant source part starts here and spans across multiple lines).\n\n")', ethers-middleware/tests/transformer.rs:121:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- ds_proxy_transformer stdout ----
thread 'ds_proxy_transformer' panicked at 'could not compile DSProxyFactory: SolcError("Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing \"SPDX-License-Identifier: <SPDX-License>\" to each source file. Use \"SPDX-License-Identifier: UNLICENSED\" for non-open-source code. Please see https://spdx.org for more information.\n--> tests/solidity-contracts/DSProxy.sol\n\nWarning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it \"abstract\" is sufficient.\n  --> tests/solidity-contracts/DSProxy.sol:20:5:\n   |\n20 |     constructor() public {\n   |     ^ (Relevant source part starts here and spans across multiple lines).\n\nError: Explicit type conversion not allowed from \"int_const 0\" to \"contract DSAuthority\".\n  --> tests/solidity-contracts/DSProxy.sol:51:33:\n   |\n51 |         } else if (authority == DSAuthority(0)) {\n   |                                 ^^^^^^^^^^^^^^\n\nWarning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it \"abstract\" is sufficient.\n  --> tests/solidity-contracts/DSProxy.sol:94:5:\n   |\n94 |     constructor(address _cacheAddr) public {\n   |     ^ (Relevant source part starts here and spans across multiple lines).\n\n")', ethers-middleware/tests/transformer.rs:36:10


failures:
    ds_proxy_code
    ds_proxy_transformer

test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.74s

This is because solc of version 0.8.0 cannot compile the test contracts. For example with DSProxy.sol:

Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> DSProxy.sol

Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
--> DSProxy.sol:20:5:
|
20 |     constructor() public {
|     ^ (Relevant source part starts here and spans across multiple lines).

Error: Explicit type conversion not allowed from "int_const 0" to "contract DSAuthority".
--> DSProxy.sol:51:33:
|
51 |         } else if (authority == DSAuthority(0)) {
|                                 ^^^^^^^^^^^^^^

Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
--> DSProxy.sol:94:5:
|
94 |     constructor(address _cacheAddr) public {
|     ^ (Relevant source part starts here and spans across multiple lines).

We should probably do one of the followings:

  • make such incompatibility explicit by adding <0.8.0 to the pragma statements;
  • document this incompatibility in the Running the tests section on README;
  • update the test contracts so that that work with 0.8.0+
@xJonathanLEI
Copy link
Contributor Author

The compilation fails because a new restriction on on explicit type conversions was introduced in 0.8.0:

The conversion is only allowed when there is at most one change in sign, width or type-category...
...
- Contract(uint): converting both type-category and width. Replace this by Contract(address(uint160(uint))).

@xJonathanLEI
Copy link
Contributor Author

Changing this line:

} else if (authority == DSAuthority(0)) {

to

} else if (authority == DSAuthority(address(uint160(0)))) {

fixes the issue.

meetmangukiya pushed a commit to meetmangukiya/ethers-rs that referenced this issue Mar 21, 2022
* record/accesses

* fmt + clippy

* reads -> writes

* no tracing feature for evm

* add no contract size limit option

* doc comment
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant