Skip to content

Commit

Permalink
fix mismatch issue in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronKutch committed Nov 17, 2023
1 parent e8ff2e5 commit 9ed79e8
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 31 deletions.
2 changes: 1 addition & 1 deletion tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ path = "src/lib/common.rs"
clap = { version = "4", features = ["derive"] }
log = "0.4"
#onomy_test_lib = { path = "./../../onomy_tests/onomy_test_lib" }
onomy_test_lib = { git = "https://github.com/pendulum-labs/onomy_tests", rev = "08143eb6f399470404515f7fd1d4b20b466b540c" }
onomy_test_lib = { git = "https://github.com/pendulum-labs/onomy_tests", rev = "4f67962483864893239c5882ad43f8e383c70c70" }
serde_json = "1.0"
tokio = "1"
7 changes: 5 additions & 2 deletions tests/src/bin/chain_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use onomy_test_lib::{
get_treasury, get_treasury_inflation_annual, sh_cosmovisor, wait_for_height,
},
nom, onomy_std_init,
setups::{onomyd_setup, CosmosSetupOptions},
setups::{cosmovisor_setup, CosmosSetupOptions},
super_orchestrator::{
docker::{Container, ContainerNetwork, Dockerfile},
sh,
Expand Down Expand Up @@ -84,7 +84,7 @@ async fn onomyd_runner(args: &Args) -> Result<()> {

info!("current version: {current_version}, upgrade version: {upgrade_version}");

onomyd_setup(CosmosSetupOptions::new(daemon_home))
cosmovisor_setup(CosmosSetupOptions::onomy(daemon_home))
.await
.stack()?;

Expand All @@ -95,6 +95,9 @@ async fn onomyd_runner(args: &Args) -> Result<()> {
current_version
);

//sh(&format!("cosmovisor add-upgrade v1.1.2 /logs/onomyd --upgrade-height
// 10"), &[]).await.stack()?;

let upgrade_prepare_start = get_block_height().await.stack()?;
let upgrade_height = &format!("{}", upgrade_prepare_start + 4);

Expand Down
73 changes: 49 additions & 24 deletions tests/src/bin/ics_cdd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@

use std::time::Duration;

use common::dockerfile_onomyd;
use log::info;
use onomy_test_lib::{
cosmovisor::{
cosmovisor_bank_send, cosmovisor_get_addr, cosmovisor_get_balances, cosmovisor_start,
set_minimum_gas_price, sh_cosmovisor, sh_cosmovisor_no_debug, sh_cosmovisor_tx,
wait_for_num_blocks,
},
dockerfiles::{dockerfile_hermes, onomy_std_cosmos_daemon_with_arbitrary},
dockerfiles::{dockerfile_hermes, dockerfile_onomyd, onomy_std_cosmos_daemon_with_arbitrary},
hermes::{
hermes_set_gas_price_denom, hermes_start, sh_hermes, write_hermes_config,
HermesChainConfig, IbcPair,
},
onomy_std_init, reprefix_bech32,
setups::{
cosmovisor_add_consumer, marketd_setup, onomyd_setup, test_proposal, CosmosSetupOptions,
},
setups::{cosmovisor_add_consumer, cosmovisor_setup, test_proposal, CosmosSetupOptions},
super_orchestrator::{
docker::{Container, ContainerNetwork, Dockerfile},
net_message::NetMessenger,
Expand Down Expand Up @@ -119,7 +116,7 @@ async fn container_runner(args: &Args) -> Result<()> {
),
Container::new(
&consumer_binary_name(),
Dockerfile::contents(onomy_std_cosmos_daemon_with_arbitrary(
Dockerfile::Contents(onomy_std_cosmos_daemon_with_arbitrary(
&consumer_binary_name(),
&consumer_directory(),
CONSUMER_VERSION,
Expand Down Expand Up @@ -198,9 +195,10 @@ async fn hermes_runner(args: &Args) -> Result<()> {
// wait for setup
nm_onomyd.recv::<()>().await.stack()?;

let ibc_pair = IbcPair::hermes_setup_ics_pair(CONSUMER_ID, "onomy")
.await
.stack()?;
let ibc_pair =
IbcPair::hermes_setup_ics_pair(CONSUMER_ID, "07-tendermint-0", "onomy", "07-tendermint-0")
.await
.stack()?;
let mut hermes_runner = hermes_start("/logs/hermes_bootstrap_runner.log")
.await
.stack()?;
Expand Down Expand Up @@ -242,11 +240,14 @@ async fn onomyd_runner(args: &Args) -> Result<()> {
.stack()
.stack()?;

let mnemonic = onomyd_setup(CosmosSetupOptions::new(daemon_home))
let cosmores = cosmovisor_setup(CosmosSetupOptions::onomy(daemon_home))
.await
.stack()?;
// send mnemonic to hermes
nm_hermes.send::<String>(&mnemonic).await.stack()?;
nm_hermes
.send::<String>(&cosmores.hermes_mnemonic.stack()?)
.await
.stack()?;

// keep these here for local testing purposes
let addr = &cosmovisor_get_addr("validator").await.stack()?;
Expand Down Expand Up @@ -300,13 +301,13 @@ async fn onomyd_runner(args: &Args) -> Result<()> {
.cosmovisor_ibc_transfer(
"validator",
&reprefix_bech32(addr, CONSUMER_ACCOUNT_PREFIX).stack()?,
&token18(1.0e3, ""),
&token18(2.0e3, ""),
"anom",
)
.await
.stack()?;
// it takes time for the relayer to complete relaying
wait_for_num_blocks(5).await.stack()?;
wait_for_num_blocks(4).await.stack()?;
// notify consumer that we have sent NOM
nm_consumer.send::<IbcPair>(&ibc_pair).await.stack()?;

Expand Down Expand Up @@ -350,9 +351,15 @@ async fn consumer(args: &Args) -> Result<()> {
// we need the initial consumer state
let ccvconsumer_state_s: String = nm_onomyd.recv().await.stack()?;

marketd_setup(daemon_home, chain_id, &ccvconsumer_state_s)
.await
.stack()?;
cosmovisor_setup(CosmosSetupOptions::new(
daemon_home,
chain_id,
"anative",
"anative",
Some(&ccvconsumer_state_s),
))
.await
.stack()?;

// get keys
let node_key = nm_onomyd.recv::<String>().await.stack()?;
Expand Down Expand Up @@ -423,16 +430,13 @@ async fn consumer(args: &Args) -> Result<()> {
.stack()?;
info!("sending back to {}", test_addr);

// avoid conflict with hermes relayer
wait_for_num_blocks(5).await.stack()?;

// send some IBC NOM back to origin chain using it as gas
ibc_pair
.a
.cosmovisor_ibc_transfer("validator", test_addr, "5000", ibc_nom)
.await
.stack()?;
wait_for_num_blocks(6).await.stack()?;
wait_for_num_blocks(4).await.stack()?;

let pubkey = sh_cosmovisor(["tendermint show-validator"]).await.stack()?;
let pubkey = pubkey.trim();
Expand All @@ -450,7 +454,7 @@ async fn consumer(args: &Args) -> Result<()> {
"--min-self-delegation",
"1",
"--amount",
&token18(500.0, ONOMY_IBC_NOM),
&token18(500.0, "anative"),
"--fees",
&format!("1000000{ONOMY_IBC_NOM}"),
"--pubkey",
Expand All @@ -470,13 +474,34 @@ async fn consumer(args: &Args) -> Result<()> {

// interchain-security-cd does not support this proposal
/*
wait_for_num_blocks(1).await.stack()?;
// test a simple text proposal
let test_deposit = token18(500.0, "anative");
let proposal = json!({
"title": "Text Proposal",
"description": "a text proposal",
"type": "Text",
"deposit": test_deposit
});
cosmovisor_gov_file_proposal(
daemon_home,
None,
&proposal.to_string(),
&format!("1{ibc_nom}"),
)
.await
.stack()?;
let proposals = sh_cosmovisor(["query gov proposals"]).await.stack()?;
assert!(proposals.contains("PROPOSAL_STATUS_PASSED"));
// but first, test governance with IBC NOM as the token
let test_crisis_denom = ONOMY_IBC_NOM;
let test_deposit = token18(2000.0, ONOMY_IBC_NOM);
let test_deposit = token18(500.0, "anative");
wait_for_num_blocks(1).await.stack()?;
cosmovisor_gov_file_proposal(
daemon_home,
"param-change",
Some("param-change"),
&format!(
r#"
{{
Expand All @@ -500,7 +525,7 @@ async fn consumer(args: &Args) -> Result<()> {
wait_for_num_blocks(5).await.stack()?;
// just running this for debug, param querying is weird because it is json
// inside of yaml, so we will instead test the exported genesis
sh_cosmovisor("query params subspace crisis ConstantFee", &[])
sh_cosmovisor(["query params subspace crisis ConstantFee"])
.await
.stack()?;*/

Expand Down
9 changes: 5 additions & 4 deletions tests/src/bin/onomyd_only.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

use std::time::Duration;

use common::{container_runner, dockerfile_onomyd};
use common::container_runner;
use log::info;
use onomy_test_lib::{
cosmovisor::{
cosmovisor_get_addr, cosmovisor_gov_file_proposal, cosmovisor_start, get_apr_annual,
get_delegations_to, get_staking_pool, get_treasury, get_treasury_inflation_annual,
sh_cosmovisor, sh_cosmovisor_no_debug, sh_cosmovisor_tx, wait_for_num_blocks,
},
dockerfiles::dockerfile_onomyd,
onomy_std_init, reprefix_bech32,
setups::{onomyd_setup, CosmosSetupOptions},
setups::{cosmovisor_setup, CosmosSetupOptions},
super_orchestrator::{
sh,
stacked_errors::{ensure, ensure_eq, Error, Result, StackableErr},
Expand Down Expand Up @@ -45,9 +46,9 @@ async fn main() -> Result<()> {

async fn onomyd_runner(args: &Args) -> Result<()> {
let daemon_home = args.daemon_home.as_ref().stack()?;
let mut options = CosmosSetupOptions::new(daemon_home);
let mut options = CosmosSetupOptions::onomy(daemon_home);
options.high_staking_level = true;
onomyd_setup(options).await.stack()?;
cosmovisor_setup(options).await.stack()?;
let mut cosmovisor_runner = cosmovisor_start("onomyd_runner.log", None).await.stack()?;

let addr = &cosmovisor_get_addr("validator").await.stack()?;
Expand Down

0 comments on commit 9ed79e8

Please sign in to comment.