Skip to content

Conversation

@bbyalcinkaya
Copy link
Member

@bbyalcinkaya bbyalcinkaya commented Jun 21, 2024

Refactored the scenario and kasmer modules to use Path instead of str for variables representing file and directory paths.

Comment on lines -63 to -77
def load_input_json(test_dir: str) -> dict:
try:
with open(join(test_dir, INPUT_FILE_NAME)) as f:
return json.load(f)
except FileNotFoundError:
raise FileNotFoundError(f'{INPUT_FILE_NAME!r} not found in "{test_dir!r}"') from None


def find_test_wasm_path(test_dir: str) -> str:
test_wasm_path = glob.glob(test_dir + '/output/*.wasm')
# TODO this loads the first wasm file in the directory. what if there are multiple wasm files?
if test_wasm_path:
return test_wasm_path[0]
else:
raise ValueError(f'WASM file not found: {test_dir}/output/?.wasm')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add these functions to kasmer-multiversx in a follow-up PR.

@bbyalcinkaya bbyalcinkaya marked this pull request as ready for review June 24, 2024 13:40
Copy link
Contributor

@tothtamas28 tothtamas28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactoring!

abi_paths = glob.glob(test_dir + '/output/*.abi.json')
# TODO this loads the first wasm file in the directory. what if there are multiple wasm files?
def get_test_endpoints(test_dir: Path) -> Mapping[str, tuple[str, ...]]:
abi_paths = glob.glob(str(test_dir) + '/output/*.abi.json')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


code = get_contract_code(tx['contractCode'], filename)
assert isinstance(code, str)
assert isinstance(code, Path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert isinstance(code, Path)
assert code is not None

bbyalcinkaya and others added 3 commits June 24, 2024 18:55
@rv-jenkins rv-jenkins merged commit 3b0736a into master Jun 24, 2024
@rv-jenkins rv-jenkins deleted the bby/refactor-python branch June 24, 2024 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants