From 650c4a82322f9e977b2863ccde51bf5dd9ad4d75 Mon Sep 17 00:00:00 2001 From: Josselin Date: Wed, 12 May 2021 12:19:05 +0200 Subject: [PATCH 1/4] Fix variable order printer Improve tests on printers --- scripts/ci_test_printers.sh | 17 +++++++++++------ slither/printers/summary/variable_order.py | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/ci_test_printers.sh b/scripts/ci_test_printers.sh index 1acfff3f17..3ac5b928e1 100755 --- a/scripts/ci_test_printers.sh +++ b/scripts/ci_test_printers.sh @@ -2,14 +2,19 @@ ### Test printer -# Needed for evm printer -pip install evm-cfg-builder +cd tests/ast-parsing/compile || exit -if ! slither "tests/*.json" --print all --json -; then - echo "Printer tests failed" +# Do not test the evm printer,as it needs a refactoring +ALL_PRINTERS="cfg,constructor-calls,contract-summary,data-dependency,echidna,function-id,function-summary,modifiers,call-graph,human-summary,inheritance,inheritance-graph,slithir,slithir-ssa,vars-and-auth,require,variable-order" + +# Only test 0.5.17 to limit test time +for file in *0.5.17-compact.zip; do + if ! slither "$file" --print "$ALL_PRINTERS" > /dev/null 2>&1 ; then + echo "Printer failed" + echo "$file" exit 1 -fi + fi +done -solc-select use "0.5.1" slither examples/scripts/test_evm_api.sol --print evm diff --git a/slither/printers/summary/variable_order.py b/slither/printers/summary/variable_order.py index 4010fce5ce..a817bf6406 100644 --- a/slither/printers/summary/variable_order.py +++ b/slither/printers/summary/variable_order.py @@ -29,7 +29,7 @@ def output(self, _filename): table = MyPrettyTable(["Name", "Type", "Slot", "Offset"]) for variable in contract.state_variables_ordered: if not variable.is_constant: - slot, offset = self.slither.storage_layout_of(contract, variable) + slot, offset = contract.compilation_unit.storage_layout_of(contract, variable) table.add_row([variable.canonical_name, str(variable.type), slot, offset]) all_tables.append((contract.name, table)) From eaaf27df6b363996512b8ad74fe54eaeb34132ac Mon Sep 17 00:00:00 2001 From: Josselin Date: Wed, 12 May 2021 14:46:05 +0200 Subject: [PATCH 2/4] Fix printer test --- scripts/ci_test_printers.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ci_test_printers.sh b/scripts/ci_test_printers.sh index 3ac5b928e1..b08d8c615f 100755 --- a/scripts/ci_test_printers.sh +++ b/scripts/ci_test_printers.sh @@ -16,5 +16,6 @@ for file in *0.5.17-compact.zip; do fi done +cd ../../.. || exit slither examples/scripts/test_evm_api.sol --print evm From 8bea597c4d810539773aa423b671cde4600312a1 Mon Sep 17 00:00:00 2001 From: Josselin Date: Wed, 12 May 2021 14:50:00 +0200 Subject: [PATCH 3/4] Minor --- scripts/ci_test_printers.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/ci_test_printers.sh b/scripts/ci_test_printers.sh index b08d8c615f..c50737524e 100755 --- a/scripts/ci_test_printers.sh +++ b/scripts/ci_test_printers.sh @@ -17,5 +17,8 @@ for file in *0.5.17-compact.zip; do done cd ../../.. || exit - -slither examples/scripts/test_evm_api.sol --print evm +# Needed for evm printer +pip install evm-cfg-builder +solc-select use "0.5.1" +if ! slither examples/scripts/test_evm_api.sol --print evm; then + echo "EVM printer failed" From f5f456ecdd3f030788d4cfe80b789305dd1e1195 Mon Sep 17 00:00:00 2001 From: Josselin Date: Wed, 12 May 2021 15:06:49 +0200 Subject: [PATCH 4/4] Minor --- scripts/ci_test_printers.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ci_test_printers.sh b/scripts/ci_test_printers.sh index c50737524e..e542286fe4 100755 --- a/scripts/ci_test_printers.sh +++ b/scripts/ci_test_printers.sh @@ -22,3 +22,4 @@ pip install evm-cfg-builder solc-select use "0.5.1" if ! slither examples/scripts/test_evm_api.sol --print evm; then echo "EVM printer failed" +fi