Skip to content

Commit

Permalink
Add token contract e2e test (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio authored Oct 25, 2022
1 parent 5147934 commit caa7a70
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ jobs:
- run: make build-test-wasms
- 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
- run: while ! [ "$(curl -s --fail localhost:8000 | jq '.history_latest_ledger')" -gt 0 ]; do echo waiting; sleep 1; done
- run: cargo test --test 'e2e*' --target ${{ matrix.target }} -- --ignored
# Run e2e tests sequentially to avoid sequence number mismatches
# TODO: use different accounts in different tests to avoid the data race
- run: cargo test --test 'e2e*' --target ${{ matrix.target }} -- --ignored --test-threads 1

publish-dry-run:
if: startsWith(github.head_ref, 'release/')
Expand Down
38 changes: 36 additions & 2 deletions tests/e2e_rpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn get_base_cmd() -> Command {
cmd
}

// e2e tests are ignore by default
// e2e tests are ignored by default
#[test]
#[ignore]
fn deploy_and_invoke_contract_against_rpc_server() {
Expand All @@ -25,7 +25,7 @@ fn deploy_and_invoke_contract_against_rpc_server() {
const WASM: &str = "target/wasm32-unknown-unknown/test-wasms/test_hello_world.wasm";
assert!(
Path::new(WASM).is_file(),
"file {WASM:?} missing, run 'make test-wasms' to generate .wasm files before running this test"
"file {WASM:?} missing, run 'make build-test-wasms' to generate .wasm files before running this test"
);

let mut deploy = get_base_cmd();
Expand All @@ -51,3 +51,37 @@ fn deploy_and_invoke_contract_against_rpc_server() {
.stderr("success\n")
.success();
}

#[test]
#[ignore]
fn create_and_invoke_token_contract_against_rpc_server() {
// This test assumes a fresh standalone network rpc server on port 8000

let mut deploy = get_base_cmd();
let create = deploy.args(&[
"token",
"create",
"--name=Stellar Lumens",
"--symbol=XLM",
"--salt=1",
]);

create
.assert()
.stdout("8af3f0c5c2c4b5a3c6ac67b390f84d9db843b48827376f42e5bad215c42588f7\n")
.stderr("success\nsuccess\n")
.success();

let mut invoke = get_base_cmd();
let invoke = invoke.args(&[
"invoke",
"--id=8af3f0c5c2c4b5a3c6ac67b390f84d9db843b48827376f42e5bad215c42588f7",
"--fn=symbol",
]);

invoke
.assert()
.stdout("[88,76,77]\n")
.stderr("success\n")
.success();
}

0 comments on commit caa7a70

Please sign in to comment.