浏览代码

Followup regarding subxt test (#1381)

Cyrill Leutwiler 2 年之前
父节点
当前提交
cf83e286b5
共有 5 个文件被更改,包括 34 次插入3 次删除
  1. 2 2
      .github/workflows/test.yml
  2. 1 0
      CODEOWNERS
  3. 27 0
      integration/subxt-tests/README.md
  4. 二进制
      integration/subxt-tests/metadata.scale
  5. 4 1
      integration/subxt-tests/src/lib.rs

+ 2 - 2
.github/workflows/test.yml

@@ -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
@@ -426,4 +426,4 @@ jobs:
         run: |
           make test
           ./test
-        working-directory: ./stdlib
+        working-directory: ./stdlib

+ 1 - 0
CODEOWNERS

@@ -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 - 0
integration/subxt-tests/README.md

@@ -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
+```

二进制
integration/subxt-tests/metadata.scale


+ 4 - 1
integration/subxt-tests/src/lib.rs

@@ -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)]
 
@@ -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>"