Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add token contract e2e test #233

Merged
merged 3 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

@leighmcculloch leighmcculloch Oct 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❔ Where is the code that creates the account? I see a single key in the e2e_rpc_server.rs file but I don't see any logic that uses friendbot to create the account before the transaction is submitted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That logic doesn't exist, that's why I left a TODO instead of biting the bullet and doing it.

- 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();
}