From 99b73c4ba726d06edf2196e8a07a279558b7a17c Mon Sep 17 00:00:00 2001 From: George Date: Thu, 2 Nov 2023 15:31:28 -0700 Subject: [PATCH] Update JavaScript references to use the latest `stellar-sdk` (#81) * Update references to use js-stellar-sdk * Rename references in Makefile, use later Go version * Refresh go.mod to v1.21 + go mod tidy * Updated start script to use latest quickstart env variables for soroban * Include quickstart's soroban high limit override on core cfg by default --------- Co-authored-by: Shawn Reuland --- .github/workflows/Dockerfile.yml | 10 +-- CHANGELOG.md | 27 +++--- Dockerfile | 30 +++---- Makefile | 18 ++-- README.md | 148 +++++++++++++++---------------- events.ts | 25 +++--- features/dapp_develop/main.go | 15 +--- go.mod | 2 +- go.sum | 16 ++++ invoke.ts | 34 +++---- js-soroban-client/README.md | 19 ---- js-stellar-sdk/README.md | 18 ++++ start | 20 +++-- 13 files changed, 203 insertions(+), 179 deletions(-) delete mode 100644 js-soroban-client/README.md create mode 100644 js-stellar-sdk/README.md diff --git a/.github/workflows/Dockerfile.yml b/.github/workflows/Dockerfile.yml index 51871cc..24cb276 100644 --- a/.github/workflows/Dockerfile.yml +++ b/.github/workflows/Dockerfile.yml @@ -5,7 +5,7 @@ on: branches: - master tags: - - '*' + - '*' pull_request: release: types: [published] @@ -25,7 +25,7 @@ env: RUST_TOOLCHAIN_VERSION: stable SOROBAN_CLI_GIT_REF: https://github.com/stellar/soroban-tools.git#main QUICKSTART_GIT_REF: https://github.com/stellar/quickstart.git#master - JS_SOROBAN_CLIENT_NPM_VERSION: https://github.com/stellar/js-soroban-client.git#main + JS_SOROBAN_CLIENT_NPM_VERSION: https://github.com/stellar/js-stellar-sdk.git#master jobs: complete: if: always() @@ -56,7 +56,7 @@ jobs: - if: ${{ env.PUSH_ENABLED == 'true' }} name: Save Docker Image to file run: | - docker save ${{ env.IMAGE }} -o /tmp/image; + docker save ${{ env.IMAGE }} -o /tmp/image; - if: ${{ env.PUSH_ENABLED == 'true' }} name: Upload System Test Image uses: actions/upload-artifact@v2 @@ -66,7 +66,7 @@ jobs: push: # Only push non 'vX.Y.Z' tags as pre-built system test image with versions compiled into image. - # pr's and releases don't need to be pushed as docker images, because system test is meant to be built + # pr's and releases don't need to be pushed as docker images, because system test is meant to be built # from source locally. needs: build permissions: @@ -88,5 +88,3 @@ jobs: registry: ${{ secrets.DOCKERHUB_TOKEN && 'docker.io' || 'ghcr.io' }} username: ${{ secrets.DOCKERHUB_USERNAME || github.actor }} password: ${{ secrets.DOCKERHUB_TOKEN || github.token }} - - diff --git a/CHANGELOG.md b/CHANGELOG.md index 40b6d3d..f20eb01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # System Test Releases +#### Unreleased + +* js invocation upgraded to use [`stellar-sdk`](https://github.com/stellar/js-stellar-sdk) rather than the now-deprecated `soroban-client`. [system-test, #81](https://github.com/stellar/system-test/pull/81) + #### 1.0.19 * js verification of contract invoke results, compare as strings. [system-test, #68](https://github.com/stellar/system-test/pull/68) @@ -39,7 +43,7 @@ #### 1.0.9 -* Fix bug in NODEJS test invocation. [system-test, #46](https://github.com/stellar/system-test/pull/46) +* Fix bug in NODEJS test invocation. [system-test, #46](https://github.com/stellar/system-test/pull/46) #### 1.0.8 @@ -64,31 +68,31 @@ #### 1.0.5 -* Fixed `--TargetNetwork futurenet`, was incorrectly trying to configure artificial acceleration on core config also, which is only allowed on `standalone`. [system-test, #25](https://github.com/stellar/system-test/pull/25). +* Fixed `--TargetNetwork futurenet`, was incorrectly trying to configure artificial acceleration on core config also, which is only allowed on `standalone`. [system-test, #25](https://github.com/stellar/system-test/pull/25). -This version of tests is based on [Soroban Preview 7](https://soroban.stellar.org/docs/releases) system interfaces. +This version of tests is based on [Soroban Preview 7](https://soroban.stellar.org/docs/releases) system interfaces. #### 1.0.4 -* Fixed git ref resolution to detached head state when compiling soroban cli during image build [system-test, #23](https://github.com/stellar/system-test/pull/23), to build [Stellar Quickstart](https://github.com/stellar/quickstart). +* Fixed git ref resolution to detached head state when compiling soroban cli during image build [system-test, #23](https://github.com/stellar/system-test/pull/23), to build [Stellar Quickstart](https://github.com/stellar/quickstart). -This version of tests is based on [Soroban Preview 7](https://soroban.stellar.org/docs/releases) system interfaces. +This version of tests is based on [Soroban Preview 7](https://soroban.stellar.org/docs/releases) system interfaces. #### 1.0.3 -* Modified test framework, [system-test, #21](https://github.com/stellar/system-test/pull/21), to build [Stellar Quickstart](https://github.com/stellar/quickstart) as the base image. -Refer to [README.md](https://github.com/stellar/system-test#readme) for new two step process of running tests: -(1) run make with server versions, creates docker image -(2) run the docker image to run tests. +* Modified test framework, [system-test, #21](https://github.com/stellar/system-test/pull/21), to build [Stellar Quickstart](https://github.com/stellar/quickstart) as the base image. +Refer to [README.md](https://github.com/stellar/system-test#readme) for new two step process of running tests: +(1) run make with server versions, creates docker image +(2) run the docker image to run tests. -This version of tests is based on [Soroban Preview 7](https://soroban.stellar.org/docs/releases) system interfaces. +This version of tests is based on [Soroban Preview 7](https://soroban.stellar.org/docs/releases) system interfaces. #### 1.0.2 * Modified tests to follow the new dynamic args format on cli [soroban-tools, #307](https://github.com/stellar/soroban-tools/pull/307) -This version of tests is based on [Soroban Preview 6](https://soroban.stellar.org/docs/releases#preview-6-january-9th-2023) system interfaces, combined with the additional change applied on top of dynamic args in cli `contract invoke` +This version of tests is based on [Soroban Preview 6](https://soroban.stellar.org/docs/releases#preview-6-january-9th-2023) system interfaces, combined with the additional change applied on top of dynamic args in cli `contract invoke` #### 1.0.1 @@ -105,4 +109,3 @@ First release of packaged system tests. Initial focus is on Soroban e2e cases us * DApp developer compiles, deploys and invokes a contract This version of tests execute the [Soroban Preview 5](https://soroban.stellar.org/docs/releases#preview-5-december-8th-2022) system interfaces only. - diff --git a/Dockerfile b/Dockerfile index 3bca29a..a455ee2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ ARG QUICKSTART_IMAGE_REF=stellar/quickstart:soroban-dev ARG SOROBAN_CLI_IMAGE_REF=stellar/system-test-soroban-cli:dev -FROM golang:1.20 as go +FROM golang:1.21 as go -RUN ["mkdir", "-p", "/test"] -RUN ["mkdir", "-p", "/test/bin"] +RUN ["mkdir", "-p", "/test"] +RUN ["mkdir", "-p", "/test/bin"] WORKDIR /test ADD go.mod go.sum ./ @@ -13,7 +13,7 @@ ADD e2e.go ./ ADD features ./features # build each feature folder with go test module. -# compiles each feature to a binary to be executed, +# compiles each feature to a binary to be executed, # and copies the .feature file with it for runtime. RUN go test -c -o ./bin/dapp_develop_test.bin ./features/dapp_develop/... ADD features/dapp_develop/dapp_develop.feature ./bin @@ -30,7 +30,7 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y build-essential expect git && apt-get clean # Install Rust -RUN ["mkdir", "-p", "/rust"] +RUN ["mkdir", "-p", "/rust"] ENV CARGO_HOME=/rust/.cargo ENV RUSTUP_HOME=/rust/.rust ENV RUST_TOOLCHAIN_VERSION=$RUST_TOOLCHAIN_VERSION @@ -64,20 +64,20 @@ RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION} ENV PATH="/home/tester/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}" RUN npm install -g ts-node yarn -# Install js-soroban-client -ARG JS_SOROBAN_CLIENT_NPM_VERSION +# Install js-stellar-sdk +ARG JS_STELLAR_SDK_NPM_VERSION ADD package.json /home/tester/ -ADD js-soroban-client /home/tester/js-soroban-client +ADD js-stellar-sdk /home/tester/js-stellar-sdk RUN sudo chown -R tester:tester /home/tester RUN yarn install --network-concurrency 1 -RUN if echo "$JS_SOROBAN_CLIENT_NPM_VERSION" | grep -q '.*file:.*'; then \ - cd /home/tester/js-soroban-client; \ - yarn cache clean; \ - yarn install --network-concurrency 1; \ - cd /home/tester; \ - yarn add ${JS_SOROBAN_CLIENT_NPM_VERSION} --network-concurrency 1; \ +RUN if echo "$JS_STELLAR_SDK_NPM_VERSION" | grep -q '.*file:.*'; then \ + cd /home/tester/js-stellar-sdk; \ + yarn cache clean; \ + yarn install --network-concurrency 1; \ + cd /home/tester; \ + yarn add ${JS_STELLAR_SDK_NPM_VERSION} --network-concurrency 1; \ else \ - yarn add "soroban-client@${JS_SOROBAN_CLIENT_NPM_VERSION}" --network-concurrency 1; \ + yarn add "stellar-sdk@${JS_STELLAR_SDK_NPM_VERSION}" --network-concurrency 1; \ fi ADD *.ts /home/tester/bin/ diff --git a/Makefile b/Makefile index 9f7a0fc..5ecd53a 100644 --- a/Makefile +++ b/Makefile @@ -22,10 +22,10 @@ SOROBAN_CLI_GIT_REF=https://github.com/stellar/soroban-tools.git\#main GO_GIT_REF=https://github.com/stellar/go.git\#master QUICKSTART_GIT_REF=https://github.com/stellar/quickstart.git\#master # specify the published npm repo version of soroban-client js library, or you can specify gh git ref url as the version also -JS_SOROBAN_CLIENT_NPM_VERSION=https://github.com/stellar/js-soroban-client.git\#main +JS_STELLAR_SDK_NPM_VERSION=https://github.com/stellar/js-stellar-sdk.git\#master # variables to set if wanting to use existing dockerhub images instead of compiling -# image during build. if using this option, the image ref should provide a version for same +# image during build. if using this option, the image ref should provide a version for same # platform arch as the build host is on, i.e. linux/amd64 or linux/arm64. # # image must have soroban cli bin at /usr/local/cargo/bin/soroban @@ -43,7 +43,7 @@ FRIENDBOT_IMAGE= # image must have core bin at /usr/local/bin/stellar-core CORE_IMAGE= # -# a prebuilt 'soroban-dev' image from the quickstart repo, if this is supplied, +# a prebuilt 'soroban-dev' image from the quickstart repo, if this is supplied, # the other core, rpc, horizon, friendbot config settings are mostly ignored, since the quickstart image # has them compiled in already. the 'stellar/quickstart' images also support multi-arch, so the build will # work those images whether the build host is arm64 or amd64. @@ -54,11 +54,11 @@ NODE_VERSION?=16.20.2 # if crate version is set, then it overrides SOROBAN_CLI_GIT_REF, cli will be installed from this create instead SOROBAN_CLI_CRATE_VERSION= -# sets the rustc version in the system test image +# sets the rustc version in the system test image RUST_TOOLCHAIN_VERSION=stable # temporarily needed, builds core with soroban enabled features -CORE_COMPILE_CONFIGURE_FLAGS=--disable-tests --enable-next-protocol-version-unsafe-for-production +CORE_COMPILE_CONFIGURE_FLAGS=--disable-tests # the final image name that is created in local docker images store for system test SYSTEM_TEST_IMAGE=stellar/system-test:dev @@ -73,7 +73,7 @@ build-friendbot: docker build -t "$(FRIENDBOT_STAGE_IMAGE)" \ --build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=true \ -f services/friendbot/docker/Dockerfile "$$SOURCE_URL"; \ - fi + fi build-soroban-rpc: if [ -z "$(QUICKSTART_IMAGE)" ] && [ -z "$(SOROBAN_RPC_IMAGE)" ]; then \ @@ -109,7 +109,7 @@ build-horizon: --target builder -f services/horizon/docker/Dockerfile.dev "$$SOURCE_URL"; \ fi -build-core: +build-core: if [ -z "$(QUICKSTART_IMAGE)" ] && [ -z "$(CORE_IMAGE)" ]; then \ SOURCE_URL="$(CORE_GIT_REF)"; \ if [[ ! "$(CORE_GIT_REF)" =~ \.git ]]; then \ @@ -136,6 +136,8 @@ build-quickstart: build-core build-friendbot build-horizon build-soroban-rpc docker build -t "$(QUICKSTART_STAGE_IMAGE)" \ --build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=true \ --build-arg STELLAR_CORE_IMAGE_REF=$$CORE_IMAGE_REF \ + --build-arg CORE_SUPPORTS_ENABLE_SOROBAN_DIAGNOSTIC_EVENTS=true \ + --build-arg CORE_SUPPORTS_TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE=true \ --build-arg HORIZON_IMAGE_REF=$$HORIZON_IMAGE_REF \ --build-arg FRIENDBOT_IMAGE_REF=$$FRIENDBOT_IMAGE_REF \ --build-arg SOROBAN_RPC_IMAGE_REF=$$SOROBAN_RPC_IMAGE_REF \ @@ -152,5 +154,5 @@ build: build-quickstart build-soroban-cli --build-arg SOROBAN_CLI_IMAGE_REF=$$SOROBAN_CLI_IMAGE_REF \ --build-arg RUST_TOOLCHAIN_VERSION=$(RUST_TOOLCHAIN_VERSION) \ --build-arg NODE_VERSION=$(NODE_VERSION) \ - --build-arg JS_SOROBAN_CLIENT_NPM_VERSION=$(JS_SOROBAN_CLIENT_NPM_VERSION) \ + --build-arg JS_STELLAR_SDK_NPM_VERSION=$(JS_STELLAR_SDK_NPM_VERSION) \ --label org.opencontainers.image.revision="$(SYSTEM_TEST_SHA)" .; diff --git a/README.md b/README.md index 27c6b99..fc41c6e 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # System Test -### Runing system tests: +### Running system tests: Identify the system-test image you want to use for running tests: - Use a prebuilt system test image published as tags under `dockerhub.io/stellar/system-test` - - Build the system test docker image locally with specific versions of core, horizon, soroban rpc, rust toolchain, soroban cli, this will create a docker image named - `stellar/system-test:dev`. - All `GIT_REF` variables can refer to either a fully qualified local path to checked out git repo, or a fully qualified github remote repo url `https://github.com/repo#` + - Build the system test docker image locally with specific versions of core, horizon, soroban rpc, rust toolchain, soroban cli, this will create a docker image named + `stellar/system-test:dev`. + All `GIT_REF` variables can refer to either a fully qualified local path to checked out git repo, or a fully qualified github remote repo url `https://github.com/repo#` ``` - make + make QUICKSTART_GIT_REF=? \ CORE_GIT_REF=? \ CORE_COMPILE_CONFIGURE_FLAGS=? \ @@ -16,12 +16,12 @@ GO_GIT_REF=? \ RUST_TOOLCHAIN_VERSION=? \ SOROBAN_CLI_CRATE_VERSION=? \ - JS_SOROBAN_CLIENT_NPM_VERSION=? \ + JS_STELLAR_SDK_NPM_VERSION=? \ NODE_VERSION=? \ - build - ``` + build + ``` - example of build using specific git refs, mainline from repos in this example, or use tags, branches, etc: + example of build using specific git refs, mainline from repos in this example, or use tags, branches, etc: ``` make CORE_GIT_REF=https://github.com/stellar/stellar-core.git#f1dc39f0f146815e5e3a94ed162e2f0639cb433f \ CORE_COMPILE_CONFIGURE_FLAGS="--disable-tests --enable-next-protocol-version-unsafe-for-production" \ @@ -29,111 +29,113 @@ RUST_TOOLCHAIN_VERSION=stable \ SOROBAN_CLI_GIT_REF=https://github.com/stellar/soroban-tools.git#main \ QUICKSTART_GIT_REF=https://github.com/stellar/quickstart.git#master \ - JS_SOROBAN_CLIENT_NPM_VERSION=https://github.com/stellar/js-soroban-client.git#main \ + JS_STELLAR_SDK_NPM_VERSION=https://github.com/stellar/js-stellar-sdk.git#master \ build - ``` + ``` - example of build using an existing quickstart image, this can dramatically speed up the build time, as the existing quickstart image will provide the pre-compiled rpc, and core runtimes already: + example of build using an existing quickstart image, this can dramatically speed up the build time, as the existing quickstart image will provide the pre-compiled rpc, and core runtimes already: ``` make QUICKSTART_IMAGE=stellar/quickstart:soroban-dev \ RUST_TOOLCHAIN_VERSION=1.66.0 \ SOROBAN_CLI_GIT_REF=/Users/user/soroban-tools build - ``` + ``` - some settings have defaults pre-set, and optionally be overriden: + some settings have defaults pre-set, and optionally be overriden: ``` - SOROBAN_CLI_GIT_REF=https://github.com/stellar/soroban-tools.git#main - SOROBAN_RPC_GIT_REF=https://github.com/stellar/soroban-tools.git#main - RUST_TOOLCHAIN_VERSION=stable + SOROBAN_CLI_GIT_REF=https://github.com/stellar/soroban-tools.git#main + SOROBAN_RPC_GIT_REF=https://github.com/stellar/soroban-tools.git#main + RUST_TOOLCHAIN_VERSION=stable QUICKSTART_GIT_REF=https://github.com/stellar/quickstart.git#master # the GO_GIT_REF provides the reference on the stellar/go repo from which # to build horizon GO_GIT_REF=https://github.com/stellar/go.git#master CORE_COMPILE_CONFIGURE_FLAGS="--disable-tests" CORE_GIT_REF=https://github.com/stellar/stellar-core.git#master - JS_SOROBAN_CLIENT_NPM_VERSION=https://github.com/stellar/js-soroban-client.git#main - ``` + JS_STELLAR_SDK_NPM_VERSION=https://github.com/stellar/js-stellar-sdk.git#master + ``` - optional to set: + optional to set: ``` # this will override SOROBAN_CLI_GIT_REF, and install soroban cli from crates repo instead - SOROBAN_CLI_CRATE_VERSION=0.4.0 + SOROBAN_CLI_CRATE_VERSION=0.4.0 # this will override the default Node JS vm version used for running the JS code: NODE_VERSION=16.20.2 - # soroban js client version can be set to a published npm version on https://www.npmjs.com/package/soroban-client - JS_SOROBAN_CLIENT_NPM_VERSION=latest - # or it can be set to a github git ref of a js-soroban-client repo - JS_SOROBAN_CLIENT_NPM_VERSION=https://github.com/stellar/js-soroban-client.git#main + # js sdk version can be set to a published npm version from https://www.npmjs.com/package/stellar-sdk + JS_STELLAR_SDK_NPM_VERSION=latest + # or it can be set to a github git ref of a js-stellar-sdk repo + JS_STELLAR_SDK_NPM_VERSION=https://github.com/stellar/js-stellar-sdk.git#master - # Image overrides. - # If using these, the image ref should provide a manifiest version for same - # platform arch as the build host is running on, i.e. linux/amd64 or linux/arm64. + # Image overrides. + # If using these, the image ref should provide a manifiest version for same + # platform arch as the build host is running on, i.e. linux/amd64 or linux/arm64. # Otherwise, build will fail if image is not available for matching host platform. # - # this will skip building from source for core(CORE_GIT_REF), rpc(SOROBAN_RPC_GIT_REF) and quickstart(QUICKSTART_GIT_REF), instead - # will use the versions already compiled in the existing quickstart docker image provided: + # this will skip building from source for core(CORE_GIT_REF), rpc(SOROBAN_RPC_GIT_REF) and quickstart(QUICKSTART_GIT_REF), instead + # will use the versions already compiled in the existing quickstart docker image provided: QUICKSTART_IMAGE=/: - # this will skip building core from CORE_GIT_REF and instead - # will use the bin already compiled at /usr/local/bin/stellar-core in the existing docker image provided: + # this will skip building core from CORE_GIT_REF and instead + # will use the bin already compiled at /usr/local/bin/stellar-core in the existing docker image provided: CORE_IMAGE=/: - # this will skip building soroban-rpc from SOROBAN_RPC_GIT_REF and instead - # will use the bin already compiled at /bin/soroban-rpc in the existing docker image provided: + # this will skip building soroban-rpc from SOROBAN_RPC_GIT_REF and instead + # will use the bin already compiled at /bin/soroban-rpc in the existing docker image provided: SOROBAN_RPC_IMAGE=/: - # this will skip building soroban-cli from SOROBAN_CLI_GIT_REF and instead - # will use the bin already compiled at /usr/local/cargo/bin/soroban in the existing docker image provided: + # this will skip building soroban-cli from SOROBAN_CLI_GIT_REF and instead + # will use the bin already compiled at /usr/local/cargo/bin/soroban in the existing docker image provided: SOROBAN_CLI_IMAGE=/: - # this will skip building horizon from GO_GIT_REF and instead - # will use the bin already compiled at /go/bin/horizon in the existing docker image provided: + # this will skip building horizon from GO_GIT_REF and instead + # will use the bin already compiled at /go/bin/horizon in the existing docker image provided: HORIZON_IMAGE=/: - # this will skip building friendbot from GO_GIT_REF and instead - # will use the bin already compiled at /app/friendbot in the existing docker image provided: + # this will skip building friendbot from GO_GIT_REF and instead + # will use the bin already compiled at /app/friendbot in the existing docker image provided: FRIENDBOT_IMAGE=/: ``` Optional parameters to pass when running system-test image, `stellar/system-test:`: -To specify git version of the smart contract source code used in soroban test fixtures. -`--SorobanExamplesGitHash {branch, tag, git commit hash}` -`--SorobanExamplesRepoURL "https://github.com/stellar/soroban-examples.git"` - -To specify which system test feature/scenarios to run, it is a regex of the feature test name and a scenario defined within, each row in example data for a scenario outline is postfixed with '#01', '#02', examples: -`--TestFilter "^TestDappDevelop$/^DApp developer compiles, deploys and invokes a contract.*$"` -or -`--TestFilter "^TestDappDevelop$/^DApp developer compiles, deploys and invokes a contract#01$"` - -The default target network for system tests is a new/empty instance of local network hosted inside the docker container, tests will use the default root account already seeded into local network. Alternatively, can override the network settings for local and remote usages: -- Tests will use an internally hosted core watcher node: -`--TargetNetwork {standalone|futurenet|testnet}` -- Tests will use an external rpc instance and the container will not run core, horizon, rpc services internally: -`--TargetNetworkRPCURL {http:///soroban/rpc}` -- Tests use these settings in either target network mode, and these are by default set to work with local: -`--TargetNetworkPassphrase "{passphrase}"` -`--TargetNetworkTestAccountSecret "{your test account key pair info}"` -`--TargetNetworkTestAccountPublic "{your test account key pair info}"` +To specify git version of the smart contract source code used in soroban test fixtures. +`--SorobanExamplesGitHash {branch, tag, git commit hash}` +`--SorobanExamplesRepoURL "https://github.com/stellar/soroban-examples.git"` + +To specify which system test feature/scenarios to run, it is a regex of the feature test name and a scenario defined within, each row in example data for a scenario outline is postfixed with '#01', '#02', examples: +`--TestFilter "^TestDappDevelop$/^DApp developer compiles, deploys and invokes a contract.*$"` +or +`--TestFilter "^TestDappDevelop$/^DApp developer compiles, deploys and invokes a contract#01$"` + +The default target network for system tests is a new/empty instance of local network hosted inside the docker container, tests will use the default root account already seeded into local network. Alternatively, can override the network settings for local and remote usages: +- Tests will use an internally hosted core watcher node: +`--TargetNetwork {standalone|futurenet|testnet}` +- Tests will use an external rpc instance and the container will not run core, horizon, rpc services internally: +`--TargetNetworkRPCURL {http:///soroban/rpc}` +- Tests use these settings in either target network mode, and these are by default set to work with local: +`--TargetNetworkPassphrase "{passphrase}"` +`--TargetNetworkTestAccountSecret "{your test account key pair info}"` +`--TargetNetworkTestAccountPublic "{your test account key pair info}"` Debug mode, the docker container will exit with error code when any pre-setup or test fails to pass, -you can enable DEBUG_MODE flag, and the container will stay running, prompting you for enter key before shutting down, make sure you invoke docker with `-it` so the prompt will reach your command line. While container is kept running, you can shell into it via `docker exec -it ` and view log files of services in the stack such as core, rpc located in container at `/var/log/supervisor`. +you can enable DEBUG_MODE flag, and the container will stay running, prompting you for enter key before shutting down, make sure you invoke docker with `-it` so the prompt will reach your command line. While container is kept running, you can shell into it via `docker exec -it ` and view log files of services in the stack such as core, rpc located in container at `/var/log/supervisor`. `--DebugMode=true` The docker run follows standard exit code conventions, so if all tests pass in the container run, exit code from command line execution will be 0, otherwise, if any failures in container or tests, then exit code will be greater than 0. #### Running Test Examples - Run tests against an instance of core and rpc on a local network all running in the test container: - + + ``` docker run --rm -t --name e2e_test stellar/system-test: \ --VerboseOutput true ``` - Run tests against a remote instance of rpc configured for testnet, this will not run core or rpc instances locally in the test container. It requires you provide a key pair of an account that is funded with Lumens on the target network for the tests to use as source account on transactions it will submit to target network: - + + ``` docker run --rm -t --name e2e_test stellar/system-test: \ --VerboseOutput true \ @@ -146,29 +148,29 @@ The docker run follows standard exit code conventions, so if all tests pass in t ### Development mode and running tests directly from checked out system-test repo. -This approach allows to run the tests from source code directly on host as go tests, no docker image is used. +This approach allows to run the tests from source code directly on host as go tests, no docker image is used. #### Prerequisites: 1. go 1.18 or above - https://go.dev/doc/install - 2. rust toolchain(cargo and rustc), install the version per testing requirements or stable, - use rustup - https://www.rust-lang.org/tools/install + 2. rust toolchain(cargo and rustc), install the version per testing requirements or stable, - use rustup - https://www.rust-lang.org/tools/install 3. `soroban` cli, compile or install via cargo crate a version of soroban cli onto your machine and accessible from PATH. 4. target network stack for the tests to access soroban-rpc instance. You can use an existing/running instance if reachable or can use the quickstart image `stellar/quickstart:soroban-dev` from dockerhub to run the latest stable target network stack locally, or build quickstart with specific versions of core, horizon and soroban rpc first [following these instructions](https://github.com/stellar/quickstart#building-custom-images) and run `stellar/quickstart:dev` locally. ``` docker run --rm -it -p 8000:8000 --name stellar stellar/quickstart:dev --standalone --enable-soroban-rpc ``` 5. locally checkout stellar/system-test GH repo and go into top folder - `git clone https://github.com/stellar/system-test.git;cd system-test` - + #### Running tests locally as go programs ``` -system-test $ SorobanExamplesGitHash="main" \ -SorobanExamplesRepoURL="https://github.com/stellar/soroban-examples.git" \ -TargetNetworkPassPhrase="Standalone Network ; February 2017" \ -TargetNetworkSecretKey="SC5O7VZUXDJ6JBDSZ74DSERXL7W3Y5LTOAMRF7RQRL3TAGAPS7LUVG3L" \ -TargetNetworkPublicKey="GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI" \ -TargetNetworkRPCURL="http://localhost:8000/soroban/rpc" \ -VerboseOutput=false \ +system-test $ SorobanExamplesGitHash="main" \ +SorobanExamplesRepoURL="https://github.com/stellar/soroban-examples.git" \ +TargetNetworkPassPhrase="Standalone Network ; February 2017" \ +TargetNetworkSecretKey="SC5O7VZUXDJ6JBDSZ74DSERXL7W3Y5LTOAMRF7RQRL3TAGAPS7LUVG3L" \ +TargetNetworkPublicKey="GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI" \ +TargetNetworkRPCURL="http://localhost:8000/soroban/rpc" \ +VerboseOutput=false \ go test -v --run "^TestDappDevelop$/^DApp developer compiles, deploys and invokes a contract.*$" ./features/dapp_develop/... ``` @@ -180,8 +182,6 @@ This example uses a feature/scenario filter also to limit which tests are run. * the verbose output of BDD scenerio results for tests is dependent on go's testing verbose output rules, need to specify -v and a directory with single package, if multiple packages detected on directory location, then go won't print verbose output for each package, i.e. you wont see the BDD scenerio summaries printed, just the standard one liner for summary of package pass/fail status. -#### Debugging tests +#### Debugging tests A debug config [launch.json](.vscode/launch.json) is provided for example reference on how to run a test with the go/dlv debugger. - - diff --git a/events.ts b/events.ts index 587cae4..727a178 100755 --- a/events.ts +++ b/events.ts @@ -1,8 +1,7 @@ #!/usr/bin/env ts-node-script import { ArgumentParser } from 'argparse'; -import * as SorobanClient from 'soroban-client'; -const xdr = SorobanClient.xdr; +import { Contract, SorobanRpc } from 'stellar-sdk'; async function main() { const parser = new ArgumentParser({ description: 'Get contract events' }) @@ -18,27 +17,27 @@ async function main() { ledgerFrom, } = parser.parse_args() as Record; - const server = new SorobanClient.Server(rpcUrl, { allowHttp: true }); + const server = new SorobanRpc.Server(rpcUrl, { allowHttp: true }); - let filters: SorobanClient.SorobanRpc.EventFilter[] = []; + let filters: SorobanRpc.Api.EventFilter[] = []; if (contractId != null) { filters.push({ - contractIds: [ new SorobanClient.Contract(contractId).contractId() ] + contractIds: [ new Contract(contractId).contractId() ] }); } - let response = await server - .getEvents({ - startLedger: Number(ledgerFrom), - filters: filters, - limit: Number(size)}); - + let response = await server.getEvents({ + startLedger: Number(ledgerFrom), + filters: filters, + limit: Number(size) + }); + if (!response.events) { throw new Error(`No events in response: ${JSON.stringify(response)}`); } - - console.log(JSON.stringify(response.events)); + + console.log(JSON.stringify(response.events)); } main().catch(err => { diff --git a/features/dapp_develop/main.go b/features/dapp_develop/main.go index 34eae50..358c997 100644 --- a/features/dapp_develop/main.go +++ b/features/dapp_develop/main.go @@ -42,7 +42,6 @@ func compileContract(contractExamplesSubPath string, contractWorkingDirectory st func deployContract(compiledContractFileName string, contractWorkingDirectory string, contractExamplesSubPath string, installedContractId string, e2eConfig *e2e.E2EConfig) (string, error) { var envCmd *cmd.Cmd - // Always use --ignore-checks since system-test will use contracts compiled with RC versions of the Soroban Rust SDK. if installedContractId != "" { envCmd = cmd.NewCmd("soroban", "contract", @@ -50,8 +49,7 @@ func deployContract(compiledContractFileName string, contractWorkingDirectory st "--wasm-hash", installedContractId, "--rpc-url", e2eConfig.TargetNetworkRPCURL, "--source", e2eConfig.TargetNetworkSecretKey, - "--network-passphrase", e2eConfig.TargetNetworkPassPhrase, - "--ignore-checks") + "--network-passphrase", e2eConfig.TargetNetworkPassPhrase) } else { envCmd = cmd.NewCmd("soroban", "contract", @@ -59,8 +57,7 @@ func deployContract(compiledContractFileName string, contractWorkingDirectory st "--wasm", fmt.Sprintf("./%s/%s/target/wasm32-unknown-unknown/release/%s", contractWorkingDirectory, contractExamplesSubPath, compiledContractFileName), "--rpc-url", e2eConfig.TargetNetworkRPCURL, "--source", e2eConfig.TargetNetworkSecretKey, - "--network-passphrase", e2eConfig.TargetNetworkPassPhrase, - "--ignore-checks") + "--network-passphrase", e2eConfig.TargetNetworkPassPhrase) } status, stdOut, err := e2e.RunCommand(envCmd, e2eConfig) @@ -77,14 +74,12 @@ func deployContract(compiledContractFileName string, contractWorkingDirectory st } func deployContractUsingConfigParams(compiledContractFileName string, contractWorkingDirectory string, contractExamplesSubPath string, identityName string, networkConfigName string, e2eConfig *e2e.E2EConfig) (string, error) { - // Always use --ignore-checks since system-test will use contracts compiled with RC versions of the Soroban Rust SDK. envCmd := cmd.NewCmd("soroban", "contract", "deploy", "--wasm", fmt.Sprintf("./%s/%s/target/wasm32-unknown-unknown/release/%s", contractWorkingDirectory, contractExamplesSubPath, compiledContractFileName), "--network", networkConfigName, - "--source", identityName, - "--ignore-checks") + "--source", identityName) status, stdOut, err := e2e.RunCommand(envCmd, e2eConfig) @@ -101,15 +96,13 @@ func deployContractUsingConfigParams(compiledContractFileName string, contractWo // returns the installed contract id func installContract(compiledContractFileName string, contractWorkingDirectory string, contractExamplesSubPath string, e2eConfig *e2e.E2EConfig) (string, error) { - // Always use --ignore-checks since system-test will use contracts compiled with RC versions of the Soroban Rust SDK. envCmd := cmd.NewCmd("soroban", "contract", "install", "--wasm", fmt.Sprintf("./%s/%s/target/wasm32-unknown-unknown/release/%s", contractWorkingDirectory, contractExamplesSubPath, compiledContractFileName), "--rpc-url", e2eConfig.TargetNetworkRPCURL, "--source", e2eConfig.TargetNetworkSecretKey, - "--network-passphrase", e2eConfig.TargetNetworkPassPhrase, - "--ignore-checks") + "--network-passphrase", e2eConfig.TargetNetworkPassPhrase) status, stdOut, err := e2e.RunCommand(envCmd, e2eConfig) diff --git a/go.mod b/go.mod index 5f0985f..c069510 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/stellar/system-test -go 1.20 +go 1.21 require ( github.com/cucumber/godog v0.12.5 diff --git a/go.sum b/go.sum index 1dee41e..a5189b4 100644 --- a/go.sum +++ b/go.sum @@ -47,15 +47,18 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-chi/chi v4.0.3+incompatible h1:gakN3pDJnzZN5jqFV2TEdF66rTfKeITyR8qu6ekICEY= +github.com/go-chi/chi v4.0.3+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/go-cmd/cmd v1.4.1 h1:JUcEIE84v8DSy02XTZpUDeGKExk2oW3DA10hTjbQwmc= github.com/go-cmd/cmd v1.4.1/go.mod h1:tbBenttXtZU4c5djS1o7PWL5pd2xAr5sIqH1kGdNiRc= github.com/go-errors/errors v0.0.0-20150906023321-a41850380601 h1:jxTbmDuqQUTI6MscgbqB39vtxGfr2fi61nYIcFQUnlE= +github.com/go-errors/errors v0.0.0-20150906023321-a41850380601/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M= +github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -81,6 +84,7 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/schema v1.1.0 h1:CamqUDOFUBqzrvxuz2vEwo8+SUdwsluFh7IlzJh30LY= +github.com/gorilla/schema v1.1.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= @@ -114,6 +118,7 @@ github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0m github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -134,6 +139,7 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/manucorporat/sse v0.0.0-20160126180136-ee05b128a739 h1:ykXz+pRRTibcSjG1yRhpdSHInF8yZY/mfn+Rz2Nd1rE= +github.com/manucorporat/sse v0.0.0-20160126180136-ee05b128a739/go.mod h1:zUx1mhth20V3VKgL5jbd1BSQcW4Fy6Qs4PZvQwRFwzM= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -151,7 +157,9 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -176,9 +184,11 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/segmentio/go-loggly v0.5.1-0.20171222203950-eb91657e62b2 h1:S4OC0+OBKz6mJnzuHioeEat74PuQ4Sgvbf8eus695sc= +github.com/segmentio/go-loggly v0.5.1-0.20171222203950-eb91657e62b2/go.mod h1:8zLRYR5npGjaOXgPSKat5+oOh+UHd8OdbS18iqX9F6Y= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= @@ -200,6 +210,7 @@ github.com/stellar/go-xdr v0.0.0-20211103144802-8017fc4bdfee/go.mod h1:yoxyU/M8n github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As= +github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -208,6 +219,7 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/xdrpp/goxdr v0.1.1 h1:E1B2c6E8eYhOVyd7yEpOyopzTPirUeF6mVOfXfGyJyc= +github.com/xdrpp/goxdr v0.1.1/go.mod h1:dXo1scL/l6s7iME1gxHWo2XCppbHEKZS7m/KyYWkNzA= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -226,6 +238,7 @@ golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxT golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= +golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -282,6 +295,7 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -330,9 +344,11 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/invoke.ts b/invoke.ts index 318e564..1590833 100755 --- a/invoke.ts +++ b/invoke.ts @@ -1,7 +1,16 @@ #!/usr/bin/env ts-node-script import { ArgumentParser } from 'argparse'; -import * as SorobanClient from 'soroban-client'; +import { + Contract, + Keypair, + TransactionBuilder, + SorobanRpc, + scValToNative, + xdr +} from 'stellar-sdk'; + +const { Server } = SorobanRpc; async function main() { const parser = new ArgumentParser({ description: 'Invoke a contract function' }) @@ -24,21 +33,17 @@ async function main() { functionName, } = parser.parse_args() as Record; - const contract = new SorobanClient.Contract(contractId); - const server = new SorobanClient.Server(rpcUrl, { allowHttp: true }); - const secretKey = SorobanClient.Keypair.fromSecret(source); + const contract = new Contract(contractId); + const server = new Server(rpcUrl, { allowHttp: true }); + const secretKey = Keypair.fromSecret(source); const account = secretKey.publicKey(); const sourceAccount = await server.getAccount(account); // Some hacky param-parsing as csv. Generated Typescript bindings would be better. - const params: SorobanClient.xdr.ScVal[] = []; - if (functionParams) { - functionParams.split(",").forEach((param) => { - params.push(SorobanClient.xdr.ScVal.scvSymbol(param)); - }); - } + const params: xdr.ScVal[] = functionParams + ? functionParams.split(",").map((p) => xdr.ScVal.scvSymbol(p)) : []; - const originalTxn = new SorobanClient.TransactionBuilder(sourceAccount, { + const originalTxn = new TransactionBuilder(sourceAccount, { fee: "100", networkPassphrase, }) @@ -46,10 +51,10 @@ async function main() { .setTimeout(30) .build(); - const txn = await server.prepareTransaction(originalTxn,networkPassphrase); + const txn = await server.prepareTransaction(originalTxn); txn.sign(secretKey); const send = await server.sendTransaction(txn); - if (send.errorResultXdr) { + if (send.errorResult) { throw new Error(`Transaction failed: ${JSON.stringify(send)}`); } let response = await server.getTransaction(send.hash); @@ -66,8 +71,7 @@ async function main() { throw new Error(`No invoke host fn return value provided: ${JSON.stringify(response)}`); } - const scval:SorobanClient.xdr.ScVal = response.returnValue; - const parsed = SorobanClient.scValToNative(scval); + const parsed = scValToNative(response.returnValue); console.log(JSON.stringify(parsed)); return; } diff --git a/js-soroban-client/README.md b/js-soroban-client/README.md deleted file mode 100644 index 375eed3..0000000 --- a/js-soroban-client/README.md +++ /dev/null @@ -1,19 +0,0 @@ -This is a placeholder file only. - -the system-teset/js-soroban-client directory can be used if you want to build system-test -with a local file path for the js-soroban-client project rather than pulling it from remote -npm or gh ref. - -js-soroban-client$ `yarn build` - -then copy the entire js-soroban-client directory over the top of system-test/js-soroban-client, -or soft link the directories, but be careful in soft link case as you don't want to accidentally delete, etc. - -once you have the system-teset/js-soroban-client ready, then build system-test and trigger it to use with: - -``` -make .... JS_SOROBAN_CLIENT_NPM_VERSION=file:/home/tester/js-soroban-client build - -``` - -system-teset/js-soroban-client is copied to the `/home/tester/js-soroban-client` path in the docker image. diff --git a/js-stellar-sdk/README.md b/js-stellar-sdk/README.md new file mode 100644 index 0000000..de2fdc2 --- /dev/null +++ b/js-stellar-sdk/README.md @@ -0,0 +1,18 @@ +**This is a placeholder file only.** + +The `system-test/js-stellar-sdk` directory can be used if you want to build `system-test` with a local file path for the [stellar/js-stellar-sdk](https://github.com/stellar/js-stellar-sdk) project rather than pulling it from remote +npm or GitHub ref. Run, + +```bash +js-stellar-sdk$ yarn build +``` + +Then, copy the entire directory over the top of `system-test/js-stellar-sdk` (or soft link the directories, but be careful in the soft link case as you don't want to accidentally delete, etc.) + +Once you have the `system-test/js-stellar-sdk` ready, then build `system-test` and trigger it to use with: + +```bash +make .... JS_STELLAR_SDK_NPM_VERSION=file:/home/tester/js-stellar-sdk build +``` + +Then, `system-test/js-stellar-sdk` is copied to the `/home/tester/js-stellar-sdk` path in the docker image. diff --git a/start b/start index faefa29..46d1126 100755 --- a/start +++ b/start @@ -62,12 +62,16 @@ function main() { process_args "$@" if [ ! -z "$TARGET_NETWORK_RPC_URL" ] && [ ! -z "$TARGET_NETWORK" ]; then - echo "Invalid TargetNetwork config, must be TargetNetwork=standalone|futurenet or TargetNetworkRPCURL, aborting test ..." >&2 + echo "Invalid TargetNetwork config, must set TargetNetwork or TargetNetworkRPCURL, aborting test ..." >&2 exit 1 fi - if [ -z "$TARGET_NETWORK_RPC_URL" ] && [ "$TARGET_NETWORK" != "standalone" ] && [ "$TARGET_NETWORK" != "futurenet" && ]; then - echo "Invalid TargetNetwork, must be one of standalone or futurenet, aborting test ..." >&2 + if [ -z "$TARGET_NETWORK_RPC_URL" ] && \ + [ "$TARGET_NETWORK" != "standalone" ] && \ + [ "$TARGET_NETWORK" != "local" ] && \ + [ "$TARGET_NETWORK" != "futurenet" && ] && \ + [ "$TARGET_NETWORK" != "testnet" && ]; then + echo "Invalid TargetNetwork, must be one of: standalone or local(both mean the same), futurenet, or testnet, aborting test ..." >&2 exit 1 fi @@ -186,7 +190,7 @@ function process_args() { done if [ -z "$TARGET_NETWORK_RPC_URL" ] && [ -z "$TARGET_NETWORK" ]; then - TARGET_NETWORK=standalone + TARGET_NETWORK=local fi } @@ -205,7 +209,13 @@ function soroban_rpc_status () { if [ $(expr $COUNTER % 12) -eq 0 ]; then print_screen_output "waited $(expr $COUNTER / 12) minutes for soroban rpc to report ready state..." fi - COUNTER=$[$COUNTER +1] + COUNTER=$[$COUNTER +1] + + if [ $COUNTER -gt 900 ]; then + echo "Waited longer than 15 minutes for rpc, cancelling and exit." + exit + fi + sleep 5 done print_screen_output "soroban rpc reported ready status, the service can be used by tools/cli now ..."