Skip to content

Commit

Permalink
Merge pull request #291 from iamdefinitelyahuman/solc-updates
Browse files Browse the repository at this point in the history
Solc updates
  • Loading branch information
iamdefinitelyahuman authored Jan 1, 2020
2 parents 038f229 + db9d511 commit 6a07152
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ This changelog format is based on [Keep a Changelog](https://keepachangelog.com/
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/iamdefinitelyahuman/brownie)
### Added
- error message for modulus by zero
- progress bar when installing new version of solc

## [1.3.1](https://github.com/iamdefinitelyahuman/brownie/tree/v1.3.1) - 2019-12-25
### Added
Expand Down
9 changes: 6 additions & 3 deletions brownie/project/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def set_solc_version(version: str) -> str:
def install_solc(*versions: str) -> None:
"""Installs solc versions."""
for version in versions:
solcx.install_solc(str(version))
solcx.install_solc(str(version), show_progress=True)


def compile_and_format(
Expand Down Expand Up @@ -493,8 +493,11 @@ def _generate_coverage_data(
node = source_nodes[source[2]].children(include_children=False, offset_limits=offset)[0]
if node.nodeType == "IndexAccess":
pc_list[-1]["dev"] = "Index out of range"
elif node.nodeType == "BinaryOperation" and node.operator == "/":
pc_list[-1]["dev"] = "Division by zero"
elif node.nodeType == "BinaryOperation":
if node.operator == "/":
pc_list[-1]["dev"] = "Division by zero"
elif node.operator == "%":
pc_list[-1]["dev"] = "Modulus by zero"

# if op is jumpi, set active branch markers
if branch_active[path] and pc_list[-1]["op"] == "JUMPI":
Expand Down
4 changes: 4 additions & 0 deletions tests/data/brownie-test-project/contracts/EVMTester.sol
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,8 @@ contract EVMTester {
c = a / b;
}

function modulusByZero(uint a, uint b) external returns (uint) {
return a % b;
}

}
3 changes: 3 additions & 0 deletions tests/network/transaction/test_revert_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ def test_invalid_opcodes(evmtester):
with pytest.raises(VirtualMachineError) as exc:
evmtester.invalidOpcodes(2, 0)
assert exc.value.revert_msg == "Division by zero"
with pytest.raises(VirtualMachineError) as exc:
evmtester.modulusByZero(2, 0)
assert exc.value.revert_msg == "Modulus by zero"
2 changes: 1 addition & 1 deletion tests/project/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def fn(version, **kwargs):
def msolc(monkeypatch):
installed = ["v0.5.8", "v0.5.7", "v0.4.23", "v0.4.22", "v0.4.6"]
monkeypatch.setattr("solcx.get_installed_solc_versions", lambda: installed)
monkeypatch.setattr("solcx.install_solc", lambda k: installed.append("v" + k))
monkeypatch.setattr("solcx.install_solc", lambda k, **z: installed.append("v" + k))
yield installed


Expand Down

0 comments on commit 6a07152

Please sign in to comment.