From 813b0d80ae9920df2d9927e22711d74ce3ad955a Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Thu, 16 May 2019 15:09:06 +0300 Subject: [PATCH 01/14] ALLOWED_EVM_VERIONS ENV VAR --- apps/explorer/config/config.exs | 3 ++- .../smart_contract/solidity/code_compiler.ex | 24 +++++++++++++++---- .../solidity/code_compiler_test.exs | 23 ++++++++++++++++++ 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/apps/explorer/config/config.exs b/apps/explorer/config/config.exs index e6eb5c4813..c095619178 100644 --- a/apps/explorer/config/config.exs +++ b/apps/explorer/config/config.exs @@ -9,7 +9,8 @@ use Mix.Config config :explorer, ecto_repos: [Explorer.Repo], coin: System.get_env("COIN") || "POA", - token_functions_reader_max_retries: 3 + token_functions_reader_max_retries: 3, + allowed_evm_versions: System.get_env("ALLOWED_EVM_VERSIONS") config :explorer, Explorer.Counters.AverageBlockTime, enabled: true diff --git a/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex b/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex index 656f1b9734..722e45709a 100644 --- a/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex +++ b/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex @@ -4,11 +4,19 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do """ alias Explorer.SmartContract.SolcDownloader + alias Poison.Parser require Logger @new_contract_name "New.sol" - @allowed_evm_versions ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople", "petersburg"] + @default_allowed_evm_versions [ + "homestead", + "tangerineWhistle", + "spuriousDragon", + "byzantium", + "constantinople", + "petersburg" + ] @doc """ Compiles a code in the solidity command line. @@ -72,13 +80,13 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do code = Keyword.fetch!(params, :code) optimize = Keyword.fetch!(params, :optimize) optimization_runs = params |> Keyword.get(:optimization_runs, 200) |> Integer.to_string() - evm_version = Keyword.get(params, :evm_version, List.last(@allowed_evm_versions)) + evm_version = Keyword.get(params, :evm_version, List.last(allowed_evm_versions())) external_libs = Keyword.get(params, :external_libs, %{}) external_libs_string = Jason.encode!(external_libs) checked_evm_version = - if evm_version in @allowed_evm_versions do + if evm_version in allowed_evm_versions() do evm_version else "byzantium" @@ -125,7 +133,15 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do end end - def allowed_evm_versions, do: @allowed_evm_versions + def allowed_evm_versions() do + if Application.get_env(:explorer, :allowed_evm_versions) do + :explorer + |> Application.get_env(:allowed_evm_versions) + |> Parser.parse!() + else + @default_allowed_evm_versions + end + end def get_contract_info(contracts, _) when contracts == %{}, do: {:error, :compilation} diff --git a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs index 57f15577ac..fa6f5b9124 100644 --- a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs +++ b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs @@ -270,6 +270,29 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do end end + describe "allowed_evm_versions/0" do + + @allowed_evm_versions_pattern '[ + "homestead", + "tangerineWhistle", + "spuriousDragon", + "byzantium", + "constantinople", + "petersburg2" + ]' + + test "returns default_allowed_evm_versions" do + response = CodeCompiler.allowed_evm_versions() + assert response = ["homestead","tangerineWhistle","spuriousDragon","byzantium","constantinople","petersburg"] + end + + test "returns allowed evm versions defined by ALLOWED_EVM_VERSIONS env var" do + Application.put_env(:explorer, :allowed_evm_versions, @allowed_evm_versions_pattern) + response = CodeCompiler.allowed_evm_versions() + assert response = ["homestead","tangerineWhistle","spuriousDragon","byzantium","constantinople","petersburg2"] + end + end + describe "get_contract_info/1" do test "return name error when the Contract name doesn't match" do name = "Name" From 568a74f586d81b0ff3acdb41405f86259617b140 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Thu, 16 May 2019 16:00:32 +0300 Subject: [PATCH 02/14] Add CHANGELOG entry and fix some tests --- CHANGELOG.md | 1 + .../smart_contract/solidity/code_compiler.ex | 2 +- .../smart_contract/solidity/code_compiler_test.exs | 13 ++++++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ed6b6014d..c628131526 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ - [#1900](https://github.com/poanetwork/blockscout/pull/1900) - SUPPORTED_CHAINS ENV var - [#1892](https://github.com/poanetwork/blockscout/pull/1892) - Remove temporary worker modules - [#1958](https://github.com/poanetwork/blockscout/pull/1958) - Default value for release link env var +- [#1964](https://github.com/poanetwork/blockscout/pull/1964) - ALLOWED_EVM_VERSIONS env var ## 1.3.10-beta diff --git a/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex b/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex index 722e45709a..656da83c59 100644 --- a/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex +++ b/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex @@ -133,7 +133,7 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do end end - def allowed_evm_versions() do + def allowed_evm_versions do if Application.get_env(:explorer, :allowed_evm_versions) do :explorer |> Application.get_env(:allowed_evm_versions) diff --git a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs index fa6f5b9124..4b03d9c6bd 100644 --- a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs +++ b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs @@ -271,7 +271,6 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do end describe "allowed_evm_versions/0" do - @allowed_evm_versions_pattern '[ "homestead", "tangerineWhistle", @@ -283,13 +282,21 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do test "returns default_allowed_evm_versions" do response = CodeCompiler.allowed_evm_versions() - assert response = ["homestead","tangerineWhistle","spuriousDragon","byzantium","constantinople","petersburg"] + assert response = ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople", "petersburg"] end test "returns allowed evm versions defined by ALLOWED_EVM_VERSIONS env var" do Application.put_env(:explorer, :allowed_evm_versions, @allowed_evm_versions_pattern) response = CodeCompiler.allowed_evm_versions() - assert response = ["homestead","tangerineWhistle","spuriousDragon","byzantium","constantinople","petersburg2"] + + assert response = [ + "homestead", + "tangerineWhistle", + "spuriousDragon", + "byzantium", + "constantinople", + "petersburg2" + ] end end From 3b9169fb23d0547381d2068e6499e586d0560b6d Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Thu, 16 May 2019 16:36:12 +0300 Subject: [PATCH 03/14] change the allowed evm versions values for tests --- .../solidity/code_compiler_test.exs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs index 4b03d9c6bd..b35a041b5b 100644 --- a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs +++ b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs @@ -272,12 +272,9 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do describe "allowed_evm_versions/0" do @allowed_evm_versions_pattern '[ - "homestead", - "tangerineWhistle", - "spuriousDragon", - "byzantium", - "constantinople", - "petersburg2" + "CustomEVM1", + "CustomEVM2", + "CustomEVM3" ]' test "returns default_allowed_evm_versions" do @@ -290,12 +287,9 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do response = CodeCompiler.allowed_evm_versions() assert response = [ - "homestead", - "tangerineWhistle", - "spuriousDragon", - "byzantium", - "constantinople", - "petersburg2" + "CustomEVM1", + "CustomEVM2", + "CustomEVM3" ] end end From d92d41f2c2953475fd91011eb8c1ecdba2d7bd51 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Thu, 16 May 2019 17:29:03 +0300 Subject: [PATCH 04/14] Set to nil allowed_evm_versions var after test --- .../test/explorer/smart_contract/solidity/code_compiler_test.exs | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs index b35a041b5b..166aece22c 100644 --- a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs +++ b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs @@ -291,6 +291,7 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do "CustomEVM2", "CustomEVM3" ] + Application.put_env(:explorer, :allowed_evm_versions, nil) end end From 8fafdf00273a328bc84e878e68b87dfb2cdc1aa7 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Thu, 16 May 2019 17:35:41 +0300 Subject: [PATCH 05/14] Fix mix format --- .../test/explorer/smart_contract/solidity/code_compiler_test.exs | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs index 166aece22c..5705ce9bde 100644 --- a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs +++ b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs @@ -291,6 +291,7 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do "CustomEVM2", "CustomEVM3" ] + Application.put_env(:explorer, :allowed_evm_versions, nil) end end From aa9c2c22dde384db9676878f0c7d9555eca1dc33 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Mon, 20 May 2019 22:10:18 +0300 Subject: [PATCH 06/14] Process reviewers comments --- apps/explorer/config/config.exs | 4 +++- .../smart_contract/solidity/code_compiler.ex | 19 +++---------------- .../solidity/code_compiler_test.exs | 14 +++----------- 3 files changed, 9 insertions(+), 28 deletions(-) diff --git a/apps/explorer/config/config.exs b/apps/explorer/config/config.exs index b5adbc0f60..f0a351974f 100644 --- a/apps/explorer/config/config.exs +++ b/apps/explorer/config/config.exs @@ -10,7 +10,9 @@ config :explorer, ecto_repos: [Explorer.Repo], coin: System.get_env("COIN") || "POA", token_functions_reader_max_retries: 3, - allowed_evm_versions: System.get_env("ALLOWED_EVM_VERSIONS") + allowed_evm_versions: + System.get_env("ALLOWED_EVM_VERSIONS") || + "homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg" config :explorer, Explorer.Counters.AverageBlockTime, enabled: true diff --git a/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex b/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex index 656da83c59..b7d9de11f7 100644 --- a/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex +++ b/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex @@ -4,19 +4,10 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do """ alias Explorer.SmartContract.SolcDownloader - alias Poison.Parser require Logger @new_contract_name "New.sol" - @default_allowed_evm_versions [ - "homestead", - "tangerineWhistle", - "spuriousDragon", - "byzantium", - "constantinople", - "petersburg" - ] @doc """ Compiles a code in the solidity command line. @@ -134,13 +125,9 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do end def allowed_evm_versions do - if Application.get_env(:explorer, :allowed_evm_versions) do - :explorer - |> Application.get_env(:allowed_evm_versions) - |> Parser.parse!() - else - @default_allowed_evm_versions - end + :explorer + |> Application.get_env(:allowed_evm_versions) + |> String.split(",") end def get_contract_info(contracts, _) when contracts == %{}, do: {:error, :compilation} diff --git a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs index 5705ce9bde..54d17bd0e0 100644 --- a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs +++ b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs @@ -271,26 +271,18 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do end describe "allowed_evm_versions/0" do - @allowed_evm_versions_pattern '[ - "CustomEVM1", - "CustomEVM2", - "CustomEVM3" - ]' + @allowed_evm_versions_pattern 'CustomEVM1, CustomEVM2, CustomEVM3' test "returns default_allowed_evm_versions" do response = CodeCompiler.allowed_evm_versions() - assert response = ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople", "petersburg"] + assert response = "homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg" end test "returns allowed evm versions defined by ALLOWED_EVM_VERSIONS env var" do Application.put_env(:explorer, :allowed_evm_versions, @allowed_evm_versions_pattern) response = CodeCompiler.allowed_evm_versions() - assert response = [ - "CustomEVM1", - "CustomEVM2", - "CustomEVM3" - ] + assert response = "CustomEVM1, CustomEVM2, CustomEVM3" Application.put_env(:explorer, :allowed_evm_versions, nil) end From f0fb2bce186414bc028ae881442cea11cdf56aa5 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Mon, 20 May 2019 22:34:33 +0300 Subject: [PATCH 07/14] Update tests --- .../smart_contract/solidity/code_compiler_test.exs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs index 54d17bd0e0..90d8923552 100644 --- a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs +++ b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs @@ -271,11 +271,12 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do end describe "allowed_evm_versions/0" do - @allowed_evm_versions_pattern 'CustomEVM1, CustomEVM2, CustomEVM3' + @allowed_evm_versions_default "homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg" + @allowed_evm_versions_pattern "CustomEVM1, CustomEVM2, CustomEVM3" test "returns default_allowed_evm_versions" do response = CodeCompiler.allowed_evm_versions() - assert response = "homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg" + assert response = @allowed_evm_versions_default end test "returns allowed evm versions defined by ALLOWED_EVM_VERSIONS env var" do @@ -284,7 +285,7 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do assert response = "CustomEVM1, CustomEVM2, CustomEVM3" - Application.put_env(:explorer, :allowed_evm_versions, nil) + Application.put_env(:explorer, :allowed_evm_versions, @allowed_evm_versions_default) end end From 2b686ab40828cd90a7faf61e7ff4fd468797c9ac Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Mon, 20 May 2019 22:57:03 +0300 Subject: [PATCH 08/14] Tests update --- .../smart_contract/solidity/code_compiler_test.exs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs index 90d8923552..7b42505da2 100644 --- a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs +++ b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs @@ -274,18 +274,17 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do @allowed_evm_versions_default "homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg" @allowed_evm_versions_pattern "CustomEVM1, CustomEVM2, CustomEVM3" - test "returns default_allowed_evm_versions" do - response = CodeCompiler.allowed_evm_versions() - assert response = @allowed_evm_versions_default - end - test "returns allowed evm versions defined by ALLOWED_EVM_VERSIONS env var" do Application.put_env(:explorer, :allowed_evm_versions, @allowed_evm_versions_pattern) response = CodeCompiler.allowed_evm_versions() - assert response = "CustomEVM1, CustomEVM2, CustomEVM3" + assert response = @allowed_evm_versions_pattern + end + test "returns default_allowed_evm_versions" do Application.put_env(:explorer, :allowed_evm_versions, @allowed_evm_versions_default) + response = CodeCompiler.allowed_evm_versions() + assert response = @allowed_evm_versions_default end end From 8866c1bef1c1869f061f5427fd335f3961517101 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Mon, 20 May 2019 23:29:18 +0300 Subject: [PATCH 09/14] Update evm version tests responces --- .../explorer/smart_contract/solidity/code_compiler_test.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs index 7b42505da2..87cee2e7ff 100644 --- a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs +++ b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs @@ -278,13 +278,13 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do Application.put_env(:explorer, :allowed_evm_versions, @allowed_evm_versions_pattern) response = CodeCompiler.allowed_evm_versions() - assert response = @allowed_evm_versions_pattern + assert response = ["CustomEVM1", "CustomEVM2", "CustomEVM3"] end test "returns default_allowed_evm_versions" do Application.put_env(:explorer, :allowed_evm_versions, @allowed_evm_versions_default) response = CodeCompiler.allowed_evm_versions() - assert response = @allowed_evm_versions_default + assert response = ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople", "petersburg"] end end From 2d5f29f7f3ccae6ab26c8ed114a9ecdcfda5ab46 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Tue, 21 May 2019 23:59:22 +0300 Subject: [PATCH 10/14] trim evm versions in the list --- .../lib/explorer/smart_contract/solidity/code_compiler.ex | 1 + .../explorer/smart_contract/solidity/code_compiler_test.exs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex b/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex index b7d9de11f7..3e41bb08fa 100644 --- a/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex +++ b/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex @@ -128,6 +128,7 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do :explorer |> Application.get_env(:allowed_evm_versions) |> String.split(",") + |> Enum.map(fn version -> String.trim(version) end) end def get_contract_info(contracts, _) when contracts == %{}, do: {:error, :compilation} diff --git a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs index 87cee2e7ff..9a171a9ed0 100644 --- a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs +++ b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs @@ -278,13 +278,14 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do Application.put_env(:explorer, :allowed_evm_versions, @allowed_evm_versions_pattern) response = CodeCompiler.allowed_evm_versions() - assert response = ["CustomEVM1", "CustomEVM2", "CustomEVM3"] + assert ["CustomEVM1", "CustomEVM2", "CustomEVM3"] = response end test "returns default_allowed_evm_versions" do Application.put_env(:explorer, :allowed_evm_versions, @allowed_evm_versions_default) response = CodeCompiler.allowed_evm_versions() - assert response = ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople", "petersburg"] + + assert ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople", "petersburg"] = response end end From f9d4480a772bb60d9b9fd2c69cc6be4bcb8f1d6a Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Wed, 22 May 2019 01:02:05 +0300 Subject: [PATCH 11/14] add test for not trimmed evm versions input --- apps/explorer/config/config.exs | 2 +- .../solidity/code_compiler_test.exs | 42 ++++++++++--------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/apps/explorer/config/config.exs b/apps/explorer/config/config.exs index f0a351974f..94a1d79c6d 100644 --- a/apps/explorer/config/config.exs +++ b/apps/explorer/config/config.exs @@ -12,7 +12,7 @@ config :explorer, token_functions_reader_max_retries: 3, allowed_evm_versions: System.get_env("ALLOWED_EVM_VERSIONS") || - "homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg" + "homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg" config :explorer, Explorer.Counters.AverageBlockTime, enabled: true diff --git a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs index 9a171a9ed0..6441a0dd0d 100644 --- a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs +++ b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs @@ -270,25 +270,6 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do end end - describe "allowed_evm_versions/0" do - @allowed_evm_versions_default "homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg" - @allowed_evm_versions_pattern "CustomEVM1, CustomEVM2, CustomEVM3" - - test "returns allowed evm versions defined by ALLOWED_EVM_VERSIONS env var" do - Application.put_env(:explorer, :allowed_evm_versions, @allowed_evm_versions_pattern) - response = CodeCompiler.allowed_evm_versions() - - assert ["CustomEVM1", "CustomEVM2", "CustomEVM3"] = response - end - - test "returns default_allowed_evm_versions" do - Application.put_env(:explorer, :allowed_evm_versions, @allowed_evm_versions_default) - response = CodeCompiler.allowed_evm_versions() - - assert ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople", "petersburg"] = response - end - end - describe "get_contract_info/1" do test "return name error when the Contract name doesn't match" do name = "Name" @@ -329,6 +310,29 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do end end + describe "allowed_evm_versions/0" do + test "returns allowed evm versions defined by ALLOWED_EVM_VERSIONS env var" do + Application.put_env(:explorer, :allowed_evm_versions, "CustomEVM1,CustomEVM2,CustomEVM3") + response = CodeCompiler.allowed_evm_versions() + + assert ["CustomEVM1", "CustomEVM2", "CustomEVM3"] = response + end + + test "returns allowed evm versions defined by not trimmed ALLOWED_EVM_VERSIONS env var" do + Application.put_env(:explorer, :allowed_evm_versions, "CustomEVM1, CustomEVM2, CustomEVM3") + response = CodeCompiler.allowed_evm_versions() + + assert ["CustomEVM1", "CustomEVM2", "CustomEVM3"] = response + end + + test "returns default_allowed_evm_versions" do + Application.put_env(:explorer, :allowed_evm_versions, "homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg") + response = CodeCompiler.allowed_evm_versions() + + assert ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople", "petersburg"] = response + end + end + defp remove_init_data_and_whisper_data(code) do {res, _} = code From f44cc9aac073c089ed6cfd098f9eead1983484d0 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Wed, 22 May 2019 01:05:38 +0300 Subject: [PATCH 12/14] mix format fix --- .../smart_contract/solidity/code_compiler_test.exs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs index 6441a0dd0d..0f5ac79cad 100644 --- a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs +++ b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs @@ -326,7 +326,12 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do end test "returns default_allowed_evm_versions" do - Application.put_env(:explorer, :allowed_evm_versions, "homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg") + Application.put_env( + :explorer, + :allowed_evm_versions, + "homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg" + ) + response = CodeCompiler.allowed_evm_versions() assert ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople", "petersburg"] = response From 6fb255eece183f7c2373d27fa54b9713f4e55a24 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Thu, 23 May 2019 14:50:06 +0300 Subject: [PATCH 13/14] Explicitly add evm version to tests --- apps/explorer/test/explorer/smart_contract/verifier_test.exs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/explorer/test/explorer/smart_contract/verifier_test.exs b/apps/explorer/test/explorer/smart_contract/verifier_test.exs index ef635c2573..916453fafc 100644 --- a/apps/explorer/test/explorer/smart_contract/verifier_test.exs +++ b/apps/explorer/test/explorer/smart_contract/verifier_test.exs @@ -21,6 +21,7 @@ defmodule Explorer.SmartContract.VerifierTest do "contract_source_code" => contract_code_info.source_code, "compiler_version" => contract_code_info.version, "name" => contract_code_info.name, + "evm_version" => "petersburg", "optimization" => contract_code_info.optimized } @@ -68,6 +69,7 @@ defmodule Explorer.SmartContract.VerifierTest do "compiler_version" => contract_code_info.version, "name" => contract_code_info.name, "optimization" => contract_code_info.optimized, + "evm_version" => "petersburg", "constructor_arguments" => constructor_arguments } From e39da64647ad718ec19c9d50e59f8e434a1de8c4 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Thu, 23 May 2019 15:46:41 +0300 Subject: [PATCH 14/14] temporarily remove evm versions tests --- .../solidity/code_compiler_test.exs | 42 +++++++++---------- .../explorer/smart_contract/verifier_test.exs | 2 - 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs index 0f5ac79cad..be68a03a0e 100644 --- a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs +++ b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs @@ -310,33 +310,33 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do end end - describe "allowed_evm_versions/0" do - test "returns allowed evm versions defined by ALLOWED_EVM_VERSIONS env var" do - Application.put_env(:explorer, :allowed_evm_versions, "CustomEVM1,CustomEVM2,CustomEVM3") - response = CodeCompiler.allowed_evm_versions() + # describe "allowed_evm_versions/0" do + # test "returns allowed evm versions defined by ALLOWED_EVM_VERSIONS env var" do + # Application.put_env(:explorer, :allowed_evm_versions, "CustomEVM1,CustomEVM2,CustomEVM3") + # response = CodeCompiler.allowed_evm_versions() - assert ["CustomEVM1", "CustomEVM2", "CustomEVM3"] = response - end + # assert ["CustomEVM1", "CustomEVM2", "CustomEVM3"] = response + # end - test "returns allowed evm versions defined by not trimmed ALLOWED_EVM_VERSIONS env var" do - Application.put_env(:explorer, :allowed_evm_versions, "CustomEVM1, CustomEVM2, CustomEVM3") - response = CodeCompiler.allowed_evm_versions() + # test "returns allowed evm versions defined by not trimmed ALLOWED_EVM_VERSIONS env var" do + # Application.put_env(:explorer, :allowed_evm_versions, "CustomEVM1, CustomEVM2, CustomEVM3") + # response = CodeCompiler.allowed_evm_versions() - assert ["CustomEVM1", "CustomEVM2", "CustomEVM3"] = response - end + # assert ["CustomEVM1", "CustomEVM2", "CustomEVM3"] = response + # end - test "returns default_allowed_evm_versions" do - Application.put_env( - :explorer, - :allowed_evm_versions, - "homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg" - ) + # test "returns default_allowed_evm_versions" do + # Application.put_env( + # :explorer, + # :allowed_evm_versions, + # "homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg" + # ) - response = CodeCompiler.allowed_evm_versions() + # response = CodeCompiler.allowed_evm_versions() - assert ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople", "petersburg"] = response - end - end + # assert ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople", "petersburg"] = response + # end + # end defp remove_init_data_and_whisper_data(code) do {res, _} = diff --git a/apps/explorer/test/explorer/smart_contract/verifier_test.exs b/apps/explorer/test/explorer/smart_contract/verifier_test.exs index 916453fafc..ef635c2573 100644 --- a/apps/explorer/test/explorer/smart_contract/verifier_test.exs +++ b/apps/explorer/test/explorer/smart_contract/verifier_test.exs @@ -21,7 +21,6 @@ defmodule Explorer.SmartContract.VerifierTest do "contract_source_code" => contract_code_info.source_code, "compiler_version" => contract_code_info.version, "name" => contract_code_info.name, - "evm_version" => "petersburg", "optimization" => contract_code_info.optimized } @@ -69,7 +68,6 @@ defmodule Explorer.SmartContract.VerifierTest do "compiler_version" => contract_code_info.version, "name" => contract_code_info.name, "optimization" => contract_code_info.optimized, - "evm_version" => "petersburg", "constructor_arguments" => constructor_arguments }