Skip to content

Commit

Permalink
Merge pull request #127681 from elopez/improve-slither-bottling
Browse files Browse the repository at this point in the history
solc-select, crytic-compile, slither-analyzer, echidna: improve testing on ARM
  • Loading branch information
github-merge-queue[bot] committed Apr 18, 2023
2 parents f59b029 + 2aa150d commit 93904aa
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 34 deletions.
20 changes: 8 additions & 12 deletions Formula/crytic-compile.rb
Expand Up @@ -38,18 +38,14 @@ def install
end

test do
(testpath/"test.sol").write <<~EOS
pragma solidity ^0.8.0;
contract Test {
function f() public pure returns (bool) {
return false;
}
}
EOS

system "solc-select", "install", "0.8.0"
with_env(SOLC_VERSION: "0.8.0") do
system bin/"crytic-compile", testpath/"test.sol", "--export-format=solc", "--export-dir=#{testpath}/export"
resource "testdata" do
url "https://github.com/crytic/slither/raw/d0a4f5595d7177b3b7d4bd35e1384bf35ebc22d4/tests/ast-parsing/compile/variable-0.8.0.sol-0.8.15-compact.zip", using: :nounzip
sha256 "2f165f629882d0250d03a56cb67a84e9741375349195915a04385b0666394478"
end

resource("testdata").stage do
system bin/"crytic-compile", "variable-0.8.0.sol-0.8.15-compact.zip", \
"--export-format=solc", "--export-dir=#{testpath}/export"
end

assert_predicate testpath/"export/combined_solc.json", :exist?
Expand Down
13 changes: 7 additions & 6 deletions Formula/echidna.rb
Expand Up @@ -18,6 +18,8 @@ class Echidna < Formula
depends_on "ghc@9.2" => :build
depends_on "haskell-stack" => :build

depends_on "truffle" => :test

depends_on "crytic-compile"
depends_on "libff"
depends_on "secp256k1"
Expand Down Expand Up @@ -48,9 +50,10 @@ def install
end

test do
system "solc-select", "install", "0.7.0"
system "truffle", "init"

(testpath/"test.sol").write <<~EOS
(testpath/"contracts/test.sol").write <<~EOS
pragma solidity ^0.8.0;
contract True {
function f() public returns (bool) {
return(false);
Expand All @@ -61,9 +64,7 @@ def install
}
EOS

with_env(SOLC_VERSION: "0.7.0") do
assert_match(/echidna_true:(\s+)passed!/,
shell_output("#{bin}/echidna --format text #{testpath}/test.sol"))
end
assert_match(/echidna_true:(\s+)passed!/,
shell_output("#{bin}/echidna --format text #{testpath}"))
end
end
25 changes: 9 additions & 16 deletions Formula/slither-analyzer.rb
Expand Up @@ -216,23 +216,16 @@ def install
end

test do
(testpath/"test.sol").write <<~EOS
pragma solidity ^0.8.0;
contract Test {
function incorrect_shift() internal returns (uint a) {
assembly {
a := shr(a, 8)
}
}
}
EOS

system "solc-select", "install", "0.8.0"

with_env(SOLC_VERSION: "0.8.0") do
resource "testdata" do
url "https://github.com/crytic/slither/raw/d0a4f5595d7177b3b7d4bd35e1384bf35ebc22d4/tests/ast-parsing/compile/variable-0.8.0.sol-0.8.15-compact.zip", using: :nounzip
sha256 "2f165f629882d0250d03a56cb67a84e9741375349195915a04385b0666394478"
end

resource("testdata").stage do
# slither exits with code 255 if high severity findings are found
assert_match("1 result(s) found",
shell_output("#{bin}/slither --detect incorrect-shift --fail-high #{testpath}/test.sol 2>&1", 255))
assert_match("5 result(s) found",
shell_output("#{bin}/slither --detect uninitialized-state --fail-high " \
"variable-0.8.0.sol-0.8.15-compact.zip 2>&1", 255))
end
end
end
5 changes: 5 additions & 0 deletions Formula/solc-select.rb
Expand Up @@ -38,6 +38,11 @@ def install
system bin/"solc-select", "install", "0.8.0"
system bin/"solc-select", "use", "0.5.7"

assert_match(/0\.5\.7.*current/, shell_output("#{bin}/solc-select versions"))

# running solc itself requires an Intel system or Rosetta
return if Hardware::CPU.arm?

assert_match("0.5.7", shell_output("#{bin}/solc --version"))
with_env(SOLC_VERSION: "0.8.0") do
assert_match("0.8.0", shell_output("#{bin}/solc --version"))
Expand Down

0 comments on commit 93904aa

Please sign in to comment.