From f9d4480a772bb60d9b9fd2c69cc6be4bcb8f1d6a Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Wed, 22 May 2019 01:02:05 +0300 Subject: [PATCH] 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