Skip to content

Commit

Permalink
Followup regarding subxt test (hyperledger-solang#1381)
Browse files Browse the repository at this point in the history
  • Loading branch information
xermicus authored Jun 23, 2023
1 parent d772fe4 commit cf83e28
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ jobs:
toolchain: stable
default: true
override: true
- run: solang compile --target substrate ../substrate/*.sol ../substrate/test/*.sol -o ./contracts/
- run: 'parallel solang compile -v --target substrate --release -o ./contracts/ ::: ../substrate/*.sol ../substrate/test/*.sol'
working-directory: ./integration/subxt-tests
- name: Deploy and test contracts
run: cargo test -- --test-threads=1
Expand Down Expand Up @@ -426,4 +426,4 @@ jobs:
run: |
make test
./test
working-directory: ./stdlib
working-directory: ./stdlib
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
src/emit/substrate/ @xermicus
src/emit/solana/ @LucasSte @seanyoung
integration/substrate/ @xermicus
integration/subxt-tests/ @xermicus
integration/solana/ @LucasSte @seanyoung
integration/anchor/ @LucasSte @seanyoung
27 changes: 27 additions & 0 deletions integration/subxt-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Solang `subxt` integration test suite

This directroy contains integration tests against a real node using `subxt`.

## How to execute the tests

The test cases requires compiled versions of the contracts from the `substrate` integration test suite inside the `./outputs` dir. To compile everything, run:

```bash
parallel solang compile -v --target substrate --release -o ./contracts/ ::: ../substrate/*.sol ../substrate/test/*.sol
```

Make sure to start a [solang-substrate-ci node](https://github.com/hyperledger/solang-substrate-ci) or a [substrate-contracts-node](https://github.com/paritytech/substrate-contracts-node) on the test host.

Run only one test at the time against the node by setting the `RUST_TEST_THREADS=1` env var or by passing `-- --test-threads=1 ` to `cargo test`.

```bash
# Execute all test cases
cargo test -- --test-threads=1
```

## How to upgrade the node metadata
A version upgrade of the node likely requires new metadata. The metadata from a local node can be acquired using [subxt](https://crates.io/crates/subxt) like so:

```bash
subxt metadata --url ws://127.0.0.1:9944 -f bytes > metadata.scale
```
Binary file added integration/subxt-tests/metadata.scale
Binary file not shown.
5 changes: 4 additions & 1 deletion integration/subxt-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// SPDX-License-Identifier: Apache-2.0

// FIXME: Stems from a bunch of disabled tests.
// Ideally they should be enable again in the future.
#![allow(unused_imports)]
#![allow(dead_code)]

Expand Down Expand Up @@ -28,7 +31,7 @@ mod cases;

// metadata file obtained from the latest substrate-contracts-node
#[subxt::subxt(
runtime_metadata_url = "ws://localhost:9944",
runtime_metadata_path = "./metadata.scale",
substitute_type(
type = "sp_weights::weight_v2::Weight",
with = "::subxt::utils::Static<::sp_weights::Weight>"
Expand Down

0 comments on commit cf83e28

Please sign in to comment.