Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] #4151: Enhance the test environment by automatically generating WASM files for the smartcontracts to be tested #4187

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ result
/test/
/iroha-java/
/lcov.info
**/test-smartcontracts/
Asem-Abdelhady marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ bash ./scripts/test_env.sh setup
bash ./scripts/tests/register_mint_quantity.sh
bash ./scripts/test_env.sh cleanup
```
To generate WASM files for smart contracts, use the provided script `generate_wasm.sh`. If you are in the root directory of iroha run the following command:

```bash
bash ./scripts/generate_wasm.sh [path/to/smartcontracts]
```

The generated WASM files will be saved in a generated directory `test-smartcontracts`, relative to your current working directory. The default path for smart contracts in this project is `client/tests/integration/smartcontracts`.

</details>

Expand Down
28 changes: 28 additions & 0 deletions scripts/generate_wasm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

# Default source directory
DEFAULT_SOURCE_DIR="client/tests/integration/smartcontracts"

# If no arguments are provided, use the default source directory
if [ "$#" -eq 0 ]; then
SOURCE_DIR="$DEFAULT_SOURCE_DIR"
else
SOURCE_DIR="$1"
fi

TARGET_DIR="test-smartcontracts"

mkdir -p "$TARGET_DIR"

for folder in "$SOURCE_DIR"/*; do
if [ -d "$folder" ] && [ "$(basename "$folder")" != ".cargo" ]; then

folder_name=$(basename "$folder")
target_wasm_file_path="${TARGET_DIR}/${folder_name}.wasm"
# Build the smart contracts
cargo run --bin iroha_wasm_builder_cli -- build "$folder" --optimize --outfile "$target_wasm_file_path"

fi
done

echo "Smart contracts build complete."