Skip to content

Commit

Permalink
Refactor test and use feature flag for e2e-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Oct 19, 2022
1 parent 4ab1107 commit 67e848d
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 62 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,24 @@ jobs:
- run: rustup update
- run: rustup target add ${{ matrix.target }}
- run: cargo clippy --all-targets --target ${{ matrix.target }}
# unit tests
- run: cargo test --bins --target ${{ matrix.target }}
# integration tests
# TODO: we should probably manage the container in the test itself
# TODO: do a proper functional check on the container startup instead of waiting 15 seconds
- run: docker run -d -p 8000:8000 stellar/quickstart:soroban-dev --standalone --enable-soroban-rpc --enable-core-artificially-accelerate-time-for-testing --protocol-version 20 && sleep 15
- run: cargo test --test 'integration_*' --target ${{ matrix.target }}
- run: cargo test --target ${{ matrix.target }}

e2e-tests:
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- run: rustup update
- run: rustup target add ${{ matrix.target }}
# TODO: we should probably manage the container in the test itself
# TODO: do a proper functional check on the container startup instead of waiting 15 seconds
- run: docker run -d -p 8000:8000 stellar/quickstart:soroban-dev --standalone --enable-soroban-rpc --enable-core-artificially-accelerate-time-for-testing --protocol-version 20 && sleep 15
- run: cargo test --test 'integration_*' --target ${{ matrix.target }}

publish-dry-run:
if: startsWith(github.head_ref, 'release/')
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ rust-version = "1.64"
autobins = false
build = "build.rs"

[features]
e2e_tests = []

[build-dependencies]
serde = "1.0.82"
serde_derive = "1.0.82"
Expand Down
48 changes: 48 additions & 0 deletions tests/e2e_rpc_server.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use assert_cmd::Command;

fn get_base_cmd() -> Command {
let mut cmd = Command::cargo_bin("soroban").unwrap();
cmd.env("SOROBAN_RPC_URL", "http://localhost:8000/soroban/rpc")
.env(
"SOROBAN_SECRET_KEY",
"SC5O7VZUXDJ6JBDSZ74DSERXL7W3Y5LTOAMRF7RQRL3TAGAPS7LUVG3L",
)
.env(
"SOROBAN_NETWORK_PASSPHRASE",
"Standalone Network ; February 2017",
);
cmd
}

#[test]
#[cfg_attr(not(feature = "e2e_tests"), ignore)]
fn deploy_and_invoke_contract_against_rpc_server() {
// This test assumes a fresh standalone network rpc server on port 8000

let mut deploy = get_base_cmd();
let deploy = deploy.args(&[
"deploy",
"--wasm=tests/fixtures/soroban_hello_world_contract.wasm",
"--salt=0",
]);

deploy
.assert()
.stdout("1f3eb7b8dc051d6aa46db5454588a142c671a0cdcdb36a2f754d9675a64bf613\n")
.stderr("success\n")
.success();

let mut invoke = get_base_cmd();
let invoke = invoke.args(&[
"invoke",
"--id=1f3eb7b8dc051d6aa46db5454588a142c671a0cdcdb36a2f754d9675a64bf613",
"--fn=hello",
"--arg=world",
]);

invoke
.assert()
.stdout("[\"Hello\",\"world\"]\n")
.stderr("success\n")
.success();
}
55 changes: 0 additions & 55 deletions tests/integration_rpc_server.rs

This file was deleted.

File renamed without changes.

0 comments on commit 67e848d

Please sign in to comment.