Skip to content

Commit

Permalink
Merge branch 'james/mainline/vp-user-multitoken-auth' (#886) into main
Browse files Browse the repository at this point in the history
* james/mainline/vp-user-multitoken-auth:
  Add end-to-end tests for multitoken transfers
  • Loading branch information
juped committed Feb 7, 2023
2 parents 3050a14 + f2d9eda commit 94ebcef
Show file tree
Hide file tree
Showing 9 changed files with 612 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/testing/886-vp-user-multitoken-auth .md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Add e2e tests for multitoken transfers
([#886](https://github.com/anoma/namada/pull/886))
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ibc = {version = "0.14.0", default-features = false}
ibc-proto = {version = "0.17.1", default-features = false}
ibc-relayer = {version = "0.14.0", default-features = false}
prost = "0.9.0"
regex = "1.7.0"
serde_json = {version = "1.0.65"}
sha2 = "0.9.3"
test-log = {version = "0.2.7", default-features = false, features = ["trace"]}
Expand Down
1 change: 1 addition & 0 deletions tests/src/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ pub mod eth_bridge_tests;
pub mod helpers;
pub mod ibc_tests;
pub mod ledger_tests;
pub mod multitoken_tests;
pub mod setup;
pub mod wallet_tests;
49 changes: 47 additions & 2 deletions tests/src/e2e/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,54 @@ use namada::types::token;
use namada_apps::config::genesis::genesis_config;
use namada_apps::config::{Config, TendermintMode};

use super::setup::{sleep, Test, ENV_VAR_DEBUG, ENV_VAR_USE_PREBUILT_BINARIES};
use super::setup::{
self, sleep, NamadaBgCmd, Test, ENV_VAR_DEBUG,
ENV_VAR_USE_PREBUILT_BINARIES,
};
use crate::e2e::setup::{Bin, Who, APPS_PACKAGE};
use crate::run;
use crate::{run, run_as};

/// Sets up a test chain with a single validator node running in the background,
/// and returns the [`Test`] handle and [`NamadaBgCmd`] for the validator node.
/// It blocks until the node is ready to receive RPC requests from
/// `namadac`.
pub fn setup_single_node_test() -> Result<(Test, NamadaBgCmd)> {
let test = setup::single_node_net()?;
let mut ledger =
run_as!(test, Who::Validator(0), Bin::Node, &["ledger"], Some(40))?;
ledger.exp_string("Namada ledger node started")?;
// TODO(namada#867): we only need to wait until the RPC server is available,
// not necessarily for a block to be committed
// ledger.exp_string("Starting RPC HTTP server on")?;
ledger.exp_regex(r"Committed block hash.*, height: [0-9]+")?;
Ok((test, ledger.background()))
}

pub fn init_established_account(
test: &Test,
rpc_addr: &str,
source_alias: &str,
key_alias: &str,
established_alias: &str,
) -> Result<()> {
let init_account_args = vec![
"init-account",
"--source",
source_alias,
"--public-key",
key_alias,
"--alias",
established_alias,
"--ledger-address",
rpc_addr,
];
let mut client_init_account =
run!(test, Bin::Client, init_account_args, Some(40))?;
client_init_account.exp_string("Transaction is valid.")?;
client_init_account.exp_string("Transaction applied")?;
client_init_account.assert_success();
Ok(())
}

/// Find the address of an account by its alias from the wallet
pub fn find_address(test: &Test, alias: impl AsRef<str>) -> Result<Address> {
Expand Down
Loading

0 comments on commit 94ebcef

Please sign in to comment.