Skip to content

Commit

Permalink
Wait for finalized on transfer of money for tests
Browse files Browse the repository at this point in the history
Without this, the money might not yet be available for subsequent
actions. This happens especially often on non-local nets.
  • Loading branch information
obrok committed Jan 17, 2023
1 parent a1423c0 commit fc241f1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion e2e-tests/Cargo.lock

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

21 changes: 20 additions & 1 deletion e2e-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,29 @@ This crate contains e2e test scenarios for the aleph-node.
The most basic way to run (assuming a local node is listening on 9944) is:

```bash
$ NODE=ws://127.0.0.1:9944 cargo test name_of_one_test
$ NODE_URL=ws://127.0.0.1:9944 cargo test name_of_one_test
```

Note that the particular test cases might require different numbers of launched nodes, validators, or a particular
configuration of the launched nodes, see the documentation for a particular test case for details.

Additional options are passed to the tests via env variables. See `src/config.rs` for docs on available options.

## Running on devnet (or other-net)

You can also run the tests on some other network. For example, to run the contract test for the `adder` contract on
devnet:

1. Prepare an account with some money, note the seed of the account.
2. Deploy the contract to devnet:

```bash
contracts/adder$ NODE_URL=wss://ws.dev.azero.dev AUTHORITY="$THE_SEED" ./deploy.sh
```

3. Run the tests:

```bash
e2e-tests$ RUST_BACKTRACE=1 SUDO_SEED="$THE_SEED" NODE_URL=wss://ws.dev.azero.dev:443 \
ADDER=$DEPLOY_ADDRESS ADDER_METADATA=../contracts/adder/target/ink/metadata.json cargo test adder -- --nocapture
```
4 changes: 2 additions & 2 deletions e2e-tests/src/test/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub async fn transfer<S: SignedConnectionApi>(
to: &KeyPair,
amount: Balance,
) -> Result<()> {
conn.transfer(to.signer().public().into(), amount, TxStatus::InBlock)
conn.transfer(to.signer().public().into(), amount, TxStatus::Finalized)
.await
.map(|_| ())
}
Expand All @@ -78,7 +78,7 @@ pub async fn basic_test_context(
let authority = KeyPairWrapper(aleph_client::keypair_from_string(&config.sudo_seed));
let account = random_account();

transfer(&authority.sign(&conn), &account, alephs(100)).await?;
transfer(&authority.sign(&conn), &account, alephs(1)).await?;

Ok((conn, authority, account))
}

0 comments on commit fc241f1

Please sign in to comment.