Skip to content

Commit

Permalink
workaround for serde_json deserialization of ChainConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
yito88 committed Nov 10, 2023
1 parent 29624b0 commit be2df69
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 21 deletions.
5 changes: 2 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/relayer-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ hdpath = "0.6.3"
http = "0.2"
humantime = "2.1"
itertools = "0.10.5"
namada_sdk = { git = "https://github.com/anoma/namada", rev = "7116b6aa916026e97f3f871f291c6ba1c7b427d2", features = ["std"] }
oneline-eyre = "0.1"
regex = "1.9.5"
serde = { version = "1.0", features = ["serde_derive"] }
Expand All @@ -56,6 +55,7 @@ tokio = { version = "1.0", features = ["full"] }
tracing = "0.1.36"
tracing-subscriber = { version = "0.3.14", features = ["fmt", "env-filter", "json"]}
time = "0.3"

[dependencies.tendermint]
version = "0.34.0"
features = ["secp256k1"]
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer-rest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ tokio = "1.26"

[dev-dependencies]
reqwest = { version = "0.11.16", features = ["json"], default-features = false }
toml = "0.7.3"
serde_json = "1"
toml = "0.7.3"
5 changes: 4 additions & 1 deletion crates/relayer-rest/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ where
let response = reqwest::get(&format!("http://127.0.0.1:{port}{path}"))
.await
.unwrap()
.json::<R>()
.json()
.await
.unwrap();
// Workaround for serde_json deserialization failure
// from_str/from_slice() failed for ChainConfig
let response = serde_json::from_value::<R>(response).unwrap();

assert_eq!(response, expected);

Expand Down
4 changes: 0 additions & 4 deletions crates/relayer/src/chain/namada.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,6 @@ impl ChainEndpoint for NamadaChain {
)
})?;

// TODO Namada health check

// TODO version check

Ok(HealthCheck::Healthy)
}

Expand Down
11 changes: 9 additions & 2 deletions crates/relayer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,15 @@ impl ChainConfig {
.map(|(key_name, keys)| (key_name, keys.into()))
.collect()
}
// TODO Namada should use the wallet
ChainConfig::Namada(_) => return Err(keyring::errors::Error::key_not_found()),
ChainConfig::Namada(config) => {
let keyring =
KeyRing::new_namada(Store::Test, &config.id, &config.key_store_folder)?;
keyring
.keys()?
.into_iter()
.map(|(key_name, keys)| (key_name, keys.into()))
.collect()
}
};
Ok(keys)
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/namada-gaia-simple-transfers
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ ${NAMADAC} --base-dir ${base_dir} ibc-transfer \
--node ${NAMADA_LEDGER_ADDR}

# wait for relaying
sleep 10
sleep 15

echo "==== Balances on Namada ===="
${NAMADAC} --base-dir ${base_dir} balance \
Expand Down
2 changes: 1 addition & 1 deletion e2e/namada-simple-transfers
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ ${NAMADAC} --base-dir ${base_dir_b} ibc-transfer \
--node ${LEDGER_ADDR_B}

# wait for relaying
sleep 10
sleep 15

echo "==== Balances on chain A ===="
${NAMADAC} --base-dir ${base_dir_a} balance \
Expand Down
7 changes: 0 additions & 7 deletions tools/test-framework/src/chain/chain_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,18 @@ use crate::util::random::{random_u32, random_unused_tcp_port};

const COSMOS_HD_PATH: &str = "m/44'/118'/0'/0/0";
const EVMOS_HD_PATH: &str = "m/44'/60'/0'/0/0";
const NAMADA_HD_PATH: &str = "m/44'/60'/0'/0/0";

#[derive(Clone, Debug)]
pub enum ChainType {
Cosmos,
Evmos,
Namada,
}

impl ChainType {
pub fn hd_path(&self) -> &str {
match self {
Self::Cosmos => COSMOS_HD_PATH,
Self::Evmos => EVMOS_HD_PATH,
Self::Namada => NAMADA_HD_PATH,
}
}

Expand All @@ -35,7 +32,6 @@ impl ChainType {
}
}
Self::Evmos => ChainId::from_string(&format!("evmos_9000-{prefix}")),
Self::Namada => ChainId::from_string(prefix),
}
}

Expand All @@ -49,7 +45,6 @@ impl ChainType {
res.push("--json-rpc.address".to_owned());
res.push(format!("localhost:{json_rpc_port}"));
}
Self::Namada => {}
}
res
}
Expand All @@ -60,7 +55,6 @@ impl ChainType {
Self::Evmos => AddressType::Ethermint {
pk_type: "/ethermint.crypto.v1.ethsecp256k1.PubKey".to_string(),
},
Self::Namada => AddressType::default(),
}
}
}
Expand All @@ -75,7 +69,6 @@ impl FromStr for ChainType {
name if name.contains("wasmd") => Ok(ChainType::Cosmos),
name if name.contains("icad") => Ok(ChainType::Cosmos),
name if name.contains("evmosd") => Ok(ChainType::Evmos),
name if name.contains("namada") => Ok(ChainType::Namada),
_ => Ok(ChainType::Cosmos),
}
}
Expand Down

0 comments on commit be2df69

Please sign in to comment.