Skip to content

Commit

Permalink
build: CI test generated TS libraries
Browse files Browse the repository at this point in the history
What
----

Add CI test to run the tests in cmd/crates/soroban-spec-typescript/ts-tests

Why
---

This will ensure that the generated typescript libraries continue to work as they should.
  • Loading branch information
chadoh committed Aug 28, 2023
1 parent 510089a commit 758f29e
Show file tree
Hide file tree
Showing 28 changed files with 482 additions and 71 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/bindings-ts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: bindings typescript

on: [push]

jobs:
test:
name: test generated libraries
runs-on: ubuntu-20.04
services:
rpc:
image: stellar/quickstart:soroban-dev@sha256:a6b03cf6b0433c99f2f799b719f0faadbb79684b1b763e7674ba749fb0f648ee
ports:
- 8000:8000
env:
ENABLE_LOGS: true
NETWORK: standalone
ENABLE_SOROBAN_RPC: true
options: >-
--health-cmd "curl -X POST \"http://localhost:8000/soroban/rpc\""
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- run: echo $CARGO_TARGET_DIR
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: rustup update
- run: cargo build
- run: rustup target add wasm32-unknown-unknown
- run: make build-test-wasms
- run: npm ci && npm run test
working-directory: cmd/crates/soroban-spec-typescript/ts-tests
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
target/
.soroban/
!test.toml

cmd/crates/soroban-spec-typescript/fixtures/ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions cmd/crates/soroban-spec-typescript/src/boilerplate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::generate;
static PROJECT_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/src/project_template");

const NETWORK_PASSPHRASE_FUTURENET: &str = "Test SDF Future Network ; October 2022";
const NETWORK_PASSPHRASE_LOCALNET: &str = "Standalone Network ; February 2017";
const NETWORK_PASSPHRASE_STANDALONE: &str = "Standalone Network ; February 2017";

pub struct Project(PathBuf);

Expand Down Expand Up @@ -112,8 +112,8 @@ impl Project {
fn format_networks_object(contract_id: &str, network_passphrase: &str) -> String {
let network = if network_passphrase == NETWORK_PASSPHRASE_FUTURENET {
"futurenet"
} else if network_passphrase == NETWORK_PASSPHRASE_LOCALNET {
"localnet"
} else if network_passphrase == NETWORK_PASSPHRASE_STANDALONE {
"standalone"
} else {
"unknown"
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"dependencies": {
"@stellar/freighter-api": "1.5.1",
"buffer": "6.0.3",
"soroban-client": "0.11.0"
"soroban-client": "0.11.1"
},
"scripts": {
"build": "node ./scripts/build.mjs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export async function invoke<R extends ResponseTypes, T = string>({
contractId,
wallet,
}: InvokeArgs<R, T>): Promise<T | string | SomeRpcResponse> {
wallet = wallet ?? (await import("@stellar/freighter-api"));
wallet = wallet ?? (await import("@stellar/freighter-api")).default;
let parse = parseResultXdr;
const server = new SorobanClient.Server(rpcUrl, {
allowHttp: rpcUrl.startsWith("http://"),
Expand Down Expand Up @@ -165,8 +165,8 @@ export async function invoke<R extends ResponseTypes, T = string>({
if (responseType === "full") return raw;

// if `sendTx` awaited the inclusion of the tx in the ledger, it used
// `getTransaction`, which has a `resultXdr` field
if ("resultXdr" in raw) return parse(raw.resultXdr.result().toXDR("base64"));
// `getTransaction`, which has a `returnValue` field
if ("returnValue" in raw) return parse(raw.returnValue);

// otherwise, it returned the result of `sendTransaction`
if ("errorResultXdr" in raw) return parse(raw.errorResultXdr);
Expand Down
1 change: 1 addition & 0 deletions cmd/crates/soroban-spec-typescript/ts-tests/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SOROBAN_NETWORK=standalone
4 changes: 3 additions & 1 deletion cmd/crates/soroban-spec-typescript/ts-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
build
node_modules
yarn.lock
yarn.lock
!.soroban/network/standalone.toml
contract-id-*.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rpc_url = "http://localhost:8000/soroban/rpc"
network_passphrase = "Standalone Network ; February 2017"
Loading

0 comments on commit 758f29e

Please sign in to comment.