Skip to content

Commit

Permalink
Add web3 test dependencies (#2033)
Browse files Browse the repository at this point in the history
* Install solc from make.sh

* Add pkg_install_solc to ci_setup_deps

* Install web3.py in make.sh
  • Loading branch information
shohamc1 authored Jun 9, 2023
1 parent c18cf28 commit a16cde9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 8 additions & 0 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,13 @@ pkg_install_rust() {
_fold_end
}

pkg_install_web3_deps() {
_fold_start "pkg-install-solc"
python3 -m pip install py-solc-x web3
python3 -c 'from solcx import install_solc;install_solc("0.8.20")'
_fold_end
}

pkg_setup_rust() {
local target=${TARGET}
local rust_target
Expand Down Expand Up @@ -847,6 +854,7 @@ ci_setup_deps() {
DEBIAN_FRONTEND=noninteractive pkg_install_llvm
DEBIAN_FRONTEND=noninteractive pkg_install_rust
pkg_setup_rust
pkg_install_web3_deps
}

ci_setup_deps_target() {
Expand Down
13 changes: 7 additions & 6 deletions test/functional/test_framework/evm_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@


class EVMContract:
# Solidity compiler version
_solc_version = "0.8.10"
_path_prefix = "../contracts"
path_prefix = "../contracts"

def __init__(self, code: str, file_name: str, contract_name: str):
def __init__(self, code: str, file_name: str, contract_name: str, compiler_version: str = "0.8.20",
path_prefix: str = "../contracts"):
self.code = code
self.file_name = file_name
self.contract_name = contract_name
self.compiler_version = compiler_version
self.path_prefix = path_prefix

@staticmethod
def from_file(file_name: str, contract_name: str):
with open(f"{os.path.dirname(__file__)}/{EVMContract._path_prefix}/{file_name}", "r", encoding="utf8") as file:
with open(f"{os.path.dirname(__file__)}/{EVMContract.path_prefix}/{file_name}", "r", encoding="utf8") as file:
return EVMContract(file.read(), file_name, contract_name)

def compile(self) -> (List[Dict], str):
Expand All @@ -35,7 +36,7 @@ def compile(self) -> (List[Dict], str):
}
},
},
solc_version=self._solc_version,
solc_version=self.compiler_version,
)

data = compiled_sol["contracts"][self.file_name][self.contract_name]
Expand Down

0 comments on commit a16cde9

Please sign in to comment.