Skip to content

Commit

Permalink
Merge branch 'yuji/ibc-e2e-test' (#664)
Browse files Browse the repository at this point in the history
* yuji/ibc-e2e-test:
  [ci] wasm checksums update
  use ibc-transfer cmd
  rename local variables
  fix for v0.8.1
  fix a way to call ibc_proof_specs
  fix for ibc integration branch
  add a test for non-IBC transfer on the same chain
  fix for denom decoding
  get receipt absence proof for TimeoutOnClose
  add a failure test
  add timeout and close tests
  add transfer back
  check balances
  add sub_prefix
  with height
  query with the height
  wait the next block
  add update_client
  fix requests
  add sleep
  add transfer test
  • Loading branch information
tzemanovic authored and juped committed Nov 14, 2022
2 parents 4602c1e + 8143264 commit 45f0528
Show file tree
Hide file tree
Showing 16 changed files with 5,786 additions and 140 deletions.
670 changes: 657 additions & 13 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ tendermint-config = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev
tendermint-proto = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"}
tendermint-rpc = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"}
tendermint-testgen = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"}
tendermint-light-client = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"}
tendermint-light-client-verifier = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"}

# patched to a commit on the `eth-bridge-integration` branch of our fork
ibc = {git = "https://github.com/heliaxdev/ibc-rs.git", rev = "f4703dfe2c1f25cc431279ab74f10f3e0f6827e2"}
ibc-proto = {git = "https://github.com/heliaxdev/ibc-rs.git", rev = "f4703dfe2c1f25cc431279ab74f10f3e0f6827e2"}
ibc-relayer = {git = "https://github.com/heliaxdev/ibc-rs.git", rev = "f4703dfe2c1f25cc431279ab74f10f3e0f6827e2"}

# patched to a commit on the `eth-bridge-integration` branch of our fork
tower-abci = {git = "https://github.com/heliaxdev/tower-abci.git", rev = "fcc0014d0bda707109901abfa1b2f782d242f082"}
Expand Down
35 changes: 28 additions & 7 deletions apps/src/lib/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ use namada::types::governance::{
VotePower,
};
use namada::types::key::*;
use namada::types::storage::{Epoch, Key, KeySeg, PrefixValue};
use namada::types::storage::{BlockHeight, Epoch, Key, KeySeg, PrefixValue};
use namada::types::token::{balance_key, Amount};
use namada::types::{address, storage, token};

use crate::cli::{self, args, Context};
use crate::client::tendermint_rpc_types::TxResponse;
use crate::facade::tendermint::abci::Code;
use crate::facade::tendermint::block::Height;
use crate::facade::tendermint::merkle::proof::Proof;
use crate::facade::tendermint_config::net::Address as TendermintAddress;
use crate::facade::tendermint_rpc::error::Error as TError;
use crate::facade::tendermint_rpc::query::Query;
Expand Down Expand Up @@ -1293,20 +1295,39 @@ pub async fn query_storage_value<T>(
where
T: BorshDeserialize,
{
let (bytes, _proof) =
query_storage_value_bytes(client, key, None, false).await;
match bytes {
Some(b) => match T::try_from_slice(&b[..]) {
Ok(value) => Some(value),
Err(err) => {
eprintln!("Error decoding the value: {}", err);
cli::safe_exit(1)
}
},
None => None,
}
}

/// Query a storage value and the proof without decoding.
pub async fn query_storage_value_bytes(
client: &HttpClient,
key: &storage::Key,
height: Option<BlockHeight>,
prove: bool,
) -> (Option<Vec<u8>>, Option<Proof>) {
let path = Path::Value(key.to_owned());
let data = vec![];
let height = height.map(|h| Height::try_from(h.0).unwrap());
let response = client
.abci_query(Some(path.into()), data, None, false)
.abci_query(Some(path.into()), data, height, prove)
.await
.unwrap();
match response.code {
Code::Ok => match T::try_from_slice(&response.value[..]) {
Ok(value) => return Some(value),
Err(err) => eprintln!("Error decoding the value: {}", err),
},
Code::Ok => return (Some(response.value), response.proof),
Code::Err(err) => {
if err == 1 {
return None;
return (None, response.proof);
} else {
eprintln!(
"Error in the query {} (error code {})",
Expand Down
2 changes: 1 addition & 1 deletion apps/src/lib/client/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ pub async fn fetch_wasms_aux(base_dir: &Path, chain_id: &ChainId) {
const TENDERMINT_NODE_ID_LENGTH: usize = 20;

/// Derive Tendermint node ID from public key
fn id_from_pk(pk: &common::PublicKey) -> TendermintNodeId {
pub fn id_from_pk(pk: &common::PublicKey) -> TendermintNodeId {
let mut bytes = [0u8; TENDERMINT_NODE_ID_LENGTH];

match pk {
Expand Down
2 changes: 1 addition & 1 deletion shared/src/ledger/storage/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Ledger's state storage with key-value backed store and a merkle tree
mod ics23_specs;
pub mod ics23_specs;
mod merkle_tree;
#[cfg(any(test, feature = "testing"))]
pub mod mockdb;
Expand Down
8 changes: 8 additions & 0 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,19 @@ namada_vp_prelude = {path = "../vp_prelude"}
namada_tx_prelude = {path = "../tx_prelude"}
chrono = {version = "0.4.22", default-features = false, features = ["clock", "std"]}
concat-idents = "1.1.2"
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"
serde_json = {version = "1.0.65"}
sha2 = "0.9.3"
test-log = {version = "0.2.7", default-features = false, features = ["trace"]}
tempfile = "3.2.0"
tendermint = "0.23.6"
tendermint-config = "0.23.6"
tendermint-proto = "0.23.6"
tendermint-rpc = {version = "0.23.6", features = ["http-client"]}
tokio = {version = "1.8.2", features = ["full"]}
tracing = "0.1.30"
tracing-subscriber = {version = "0.3.7", default-features = false, features = ["env-filter", "fmt"]}
derivative = "2.2.0"
Expand Down
1 change: 1 addition & 0 deletions tests/src/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
pub mod eth_bridge_tests;
pub mod helpers;
pub mod ibc_tests;
pub mod ledger_tests;
pub mod setup;
pub mod wallet_tests;
20 changes: 20 additions & 0 deletions tests/src/e2e/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use eyre::eyre;
use namada::types::address::Address;
use namada::types::key::*;
use namada::types::storage::Epoch;
use namada_apps::config::genesis::genesis_config;
use namada_apps::config::{Config, TendermintMode};

use super::setup::{Test, ENV_VAR_DEBUG, ENV_VAR_USE_PREBUILT_BINARIES};
Expand Down Expand Up @@ -54,6 +55,25 @@ pub fn get_actor_rpc(test: &Test, who: &Who) -> String {
config.ledger.tendermint.rpc_address.to_string()
}

/// Get the public key of the validator
pub fn get_validator_pk(test: &Test, who: &Who) -> Option<common::PublicKey> {
let index = match who {
Who::NonValidator => return None,
Who::Validator(i) => i,
};
let file = format!("{}.toml", test.net.chain_id.as_str());
let path = test.test_dir.path().join(file);
let config = genesis_config::open_genesis_config(path).unwrap();
let pk = config
.validator
.get(&format!("validator-{}", index))
.unwrap()
.account_public_key
.as_ref()
.unwrap();
Some(pk.to_public_key().unwrap())
}

/// Find the address of an account by its alias from the wallet
#[allow(dead_code)]
pub fn find_keypair(
Expand Down
Loading

0 comments on commit 45f0528

Please sign in to comment.