Skip to content

Commit

Permalink
fix relayer-cli and testS
Browse files Browse the repository at this point in the history
  • Loading branch information
noot committed Oct 9, 2024
1 parent 85cd075 commit 0789c11
Show file tree
Hide file tree
Showing 20 changed files with 146 additions and 131 deletions.
2 changes: 1 addition & 1 deletion crates/chain-registry/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl UriFormatter for SimpleGrpcFormatter {

#[cfg(test)]
mod tests {
use std::{cmp::PartialEq, fmt::Debug};
use super::*;

use std::fmt::Debug;

Expand Down
25 changes: 7 additions & 18 deletions crates/relayer-cli/src/commands/clear.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
use eyre::eyre;
use std::ops::RangeInclusive;

use abscissa_core::{clap::Parser, config::Override, Command, FrameworkErrorKind, Runnable};
use ibc_relayer::{
chain::handle::{BaseChainHandle, ChainHandle},
config::Config,
link::{error::LinkError, Link, LinkParameters},
util::seq_range::parse_seq_range,
};
use ibc_relayer_types::{
core::{
ics04_channel::packet::Sequence,
ics24_host::identifier::{ChainId, ChannelId, PortId},
},
events::IbcEvent,
};
use abscissa_core::clap::Parser;
use abscissa_core::config::Override;
use abscissa_core::{Command, FrameworkErrorKind, Runnable};

use ibc_relayer::chain::handle::{BaseChainHandle, ChainHandle};
use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight};
Expand Down Expand Up @@ -276,13 +265,13 @@ where

#[cfg(test)]
mod tests {
use super::ClearPacketsCmd;

use std::str::FromStr;

use abscissa_core::clap::Parser;
use ibc_relayer_types::core::{
ics04_channel::packet::Sequence,
ics24_host::identifier::{ChainId, ChannelId, PortId},
};
use ibc_relayer_types::core::ics04_channel::packet::Sequence;
use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ChannelId, PortId};

#[test]
fn test_clear_packets_required_only() {
Expand Down
3 changes: 0 additions & 3 deletions crates/relayer-cli/src/commands/config/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ use itertools::Itertools;

use crate::conclude::Output;

use abscissa_core::{clap::Parser, Command, Runnable};
use ibc_relayer::config::{store, ChainConfig, Config};

use std::collections::HashSet;
use std::path::PathBuf;
use tracing::{error, info, warn};

use crate::{chain_registry::get_configs, conclude::Output};

fn find_key(chain_config: &ChainConfig) -> Option<String> {
let keys = chain_config.list_keys().ok()?;
keys.into_iter().next().map(|(name, _)| name)
Expand Down
20 changes: 5 additions & 15 deletions crates/relayer-cli/src/commands/create/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,19 @@ use abscissa_core::clap::Parser;

use console::style;
use dialoguer::Confirm;

use ibc_relayer::chain::handle::ChainHandle;
use ibc_relayer::chain::requests::{
IncludeProof, QueryClientStateRequest, QueryConnectionRequest, QueryHeight,
};
use ibc_relayer::channel::Channel;
use ibc_relayer::config::default::connection_delay;
use ibc_relayer::connection::Connection;
use ibc_relayer::foreign_client::ForeignClient;
use ibc_relayer::{
chain::{
handle::ChainHandle,
requests::{IncludeProof, QueryClientStateRequest, QueryConnectionRequest, QueryHeight},
},
channel::Channel,
config::default::connection_delay,
connection::Connection,
foreign_client::ForeignClient,
};
use ibc_relayer_types::core::ics03_connection::connection::IdentifiedConnectionEnd;
use ibc_relayer_types::core::ics04_channel::channel::Ordering;
use ibc_relayer_types::core::ics04_channel::version::Version;
use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ConnectionId, PortId};
use ibc_relayer_types::core::{
ics03_connection::connection::IdentifiedConnectionEnd,
ics04_channel::{channel::Ordering, version::Version},
ics24_host::identifier::{ChainId, ConnectionId, PortId},
};

use crate::cli_utils::{spawn_chain_runtime, ChainHandlePair};
use crate::conclude::{exit_with_unrecoverable_error, Output};
Expand Down
37 changes: 29 additions & 8 deletions crates/relayer-cli/src/commands/evidence.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
use std::{
collections::HashMap,
ops::{ControlFlow, Deref},
sync::Arc,
thread::sleep,
time::Duration,
};
use std::collections::HashMap;
use std::ops::{ControlFlow, Deref};
use std::sync::Arc;
use std::thread::sleep;
use std::time::Duration;

use abscissa_core::clap::Parser;
use ibc_relayer::config::{ChainConfig, Config};
use tokio::runtime::Runtime as TokioRuntime;

use crate::{conclude::Output, prelude::*};
use tendermint::block::Height as TendermintHeight;
use tendermint::evidence::{DuplicateVoteEvidence, LightClientAttackEvidence};
use tendermint::validator;
use tendermint_rpc::{Client, Paging};

use ibc_relayer::chain::cosmos::CosmosSdkChain;
use ibc_relayer::chain::endpoint::ChainEndpoint;
use ibc_relayer::chain::handle::{BaseChainHandle, ChainHandle};
use ibc_relayer::chain::requests::{IncludeProof, PageRequest, QueryHeight};
use ibc_relayer::chain::tracking::TrackedMsgs;
use ibc_relayer::foreign_client::ForeignClient;
use ibc_relayer::spawn::spawn_chain_runtime_with_modified_config;
use ibc_relayer_types::applications::ics28_ccv::msgs::ccv_double_voting::MsgSubmitIcsConsumerDoubleVoting;
use ibc_relayer_types::applications::ics28_ccv::msgs::ccv_misbehaviour::MsgSubmitIcsConsumerMisbehaviour;
use ibc_relayer_types::clients::ics07_tendermint::header::Header as TendermintHeader;
use ibc_relayer_types::clients::ics07_tendermint::misbehaviour::Misbehaviour as TendermintMisbehaviour;
use ibc_relayer_types::core::ics02_client::height::Height;
use ibc_relayer_types::core::ics02_client::msgs::misbehaviour::MsgSubmitMisbehaviour;
use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ClientId};
use ibc_relayer_types::events::IbcEvent;
use ibc_relayer_types::tx_msg::Msg;

use crate::conclude::Output;
use crate::prelude::*;

#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)]
pub struct EvidenceCmd {
Expand Down
11 changes: 6 additions & 5 deletions crates/relayer-cli/src/commands/health.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use abscissa_core::clap::Parser;

use crate::{
cli_utils::spawn_chain_runtime,
conclude::{exit_with_unrecoverable_error, Output},
prelude::*,
};
use ibc_relayer::chain::endpoint::HealthCheck::*;
use ibc_relayer::chain::handle::ChainHandle;

use crate::cli_utils::spawn_chain_runtime;
use crate::conclude::{exit_with_unrecoverable_error, Output};
use crate::prelude::*;

#[derive(Clone, Command, Debug, Parser)]
pub struct HealthCheckCmd {}
Expand Down
27 changes: 4 additions & 23 deletions crates/relayer-cli/src/commands/misbehaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,11 @@ use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ClientId};
use ibc_relayer_types::events::IbcEvent;
use std::ops::Deref;

use abscissa_core::{clap::Parser, Command, Runnable};
use crate::cli_utils::{spawn_chain_runtime, spawn_chain_runtime_generic};
use crate::conclude::Output;
use crate::prelude::*;
use eyre::eyre;
use ibc_relayer::{
chain::{
handle::ChainHandle,
requests::{IncludeProof, QueryClientStateRequest, QueryHeight},
},
config::Config,
foreign_client::{ForeignClient, MisbehaviourResults},
util::pretty::PrettySlice,
};
use ibc_relayer_types::{
core::{
ics02_client::{client_state::ClientState, events::UpdateClient},
ics24_host::identifier::{ChainId, ClientId},
},
events::IbcEvent,
};

use crate::{
cli_utils::{spawn_chain_runtime, spawn_chain_runtime_generic},
conclude::Output,
prelude::*,
};
use ibc_relayer_types::core::ics02_client::client_state::ClientState;

#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)]
pub struct MisbehaviourCmd {
Expand Down
14 changes: 9 additions & 5 deletions crates/relayer-cli/src/commands/query/channel.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
use abscissa_core::clap::Parser;
use ibc_relayer::chain::handle::ChainHandle;

use crate::{
cli_utils::spawn_chain_runtime,
conclude::{exit_with_unrecoverable_error, Output},
prelude::*,
};
use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight};
use ibc_relayer_types::core::ics24_host::identifier::ChainId;
use ibc_relayer_types::core::ics24_host::identifier::{ChannelId, PortId};

use crate::cli_utils::spawn_chain_runtime;
use crate::conclude::{exit_with_unrecoverable_error, Output};
use crate::prelude::*;
use ibc_relayer_types::core::ics04_channel::channel::State;
use ibc_relayer_types::Height;

#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)]
pub struct QueryChannelEndCmd {
Expand Down
17 changes: 14 additions & 3 deletions crates/relayer-cli/src/commands/query/channel_ends.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
use abscissa_core::clap::Parser;
use serde::{Deserialize, Serialize};

use crate::{
conclude::{exit_with_unrecoverable_error, Output},
prelude::*,
use eyre::eyre;
use ibc_relayer::chain::handle::{BaseChainHandle, ChainHandle};
use ibc_relayer::chain::requests::{
IncludeProof, QueryChannelRequest, QueryClientStateRequest, QueryConnectionRequest, QueryHeight,
};
use ibc_relayer::client_state::AnyClientState;
use ibc_relayer::registry::Registry;
use ibc_relayer_types::core::ics03_connection::connection::ConnectionEnd;
use ibc_relayer_types::core::ics04_channel::channel::{ChannelEnd, State};
use ibc_relayer_types::core::ics24_host::identifier::ChainId;
use ibc_relayer_types::core::ics24_host::identifier::{ChannelId, ClientId, ConnectionId, PortId};
use ibc_relayer_types::Height;

use crate::conclude::{exit_with_unrecoverable_error, Output};
use crate::prelude::*;

#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)]
pub struct QueryChannelEndsCmd {
Expand Down
16 changes: 15 additions & 1 deletion crates/relayer-cli/src/commands/query/channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,21 @@ use core::fmt::{Debug, Error, Formatter};
use abscissa_core::clap::Parser;
use serde::Serialize;

use crate::{commands::query::channel_ends::ChannelEnds, conclude::Output, prelude::*};
use eyre::eyre;
use ibc_relayer::chain::handle::{BaseChainHandle, ChainHandle};
use ibc_relayer::chain::requests::{
IncludeProof, PageRequest, QueryChannelRequest, QueryChannelsRequest, QueryClientStateRequest,
QueryConnectionRequest, QueryHeight,
};
use ibc_relayer::registry::Registry;
use ibc_relayer_types::core::ics04_channel::channel::{ChannelEnd, State};
use ibc_relayer_types::core::ics24_host::identifier::{
ChainId, ChannelId, ConnectionId, PortChannelId, PortId,
};

use crate::commands::query::channel_ends::ChannelEnds;
use crate::conclude::Output;
use crate::prelude::*;

#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)]
pub struct QueryChannelsCmd {
Expand Down
14 changes: 9 additions & 5 deletions crates/relayer-cli/src/commands/query/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ use ibc_relayer::chain::requests::{
QueryHeight, QueryTxRequest,
};

use crate::{
application::app_config,
cli_utils::spawn_chain_runtime,
conclude::{exit_with_unrecoverable_error, Output},
};
use ibc_relayer_types::core::ics02_client::client_state::ClientState;
use ibc_relayer_types::core::ics24_host::identifier::ChainId;
use ibc_relayer_types::core::ics24_host::identifier::ClientId;
use ibc_relayer_types::events::WithBlockDataType;
use ibc_relayer_types::Height;

use crate::application::app_config;
use crate::cli_utils::spawn_chain_runtime;
use crate::conclude::{exit_with_unrecoverable_error, Output};

/// Query client state command
#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)]
Expand Down
13 changes: 7 additions & 6 deletions crates/relayer-cli/src/commands/query/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ use abscissa_core::clap::Parser;
use ibc_relayer::chain::handle::ChainHandle;
use serde::Serialize;

use crate::{
cli_utils::spawn_chain_runtime,
conclude::{exit_with_unrecoverable_error, Output},
error::Error,
prelude::*,
};
use ibc_relayer::chain::requests::{PageRequest, QueryClientStatesRequest};
use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ClientId};

use crate::cli_utils::spawn_chain_runtime;
use crate::conclude::{exit_with_unrecoverable_error, Output};
use crate::error::Error;
use crate::prelude::*;

/// Query clients command
#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)]
Expand Down
15 changes: 10 additions & 5 deletions crates/relayer-cli/src/commands/query/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ use ibc_relayer::chain::requests::{
IncludeProof, PageRequest, QueryConnectionChannelsRequest, QueryConnectionRequest, QueryHeight,
};

use crate::{
cli_utils::spawn_chain_runtime,
conclude::{exit_with_unrecoverable_error, Output},
error::Error,
prelude::*,
use ibc_relayer_types::core::{
ics03_connection::connection::State,
ics24_host::identifier::ConnectionId,
ics24_host::identifier::{ChainId, PortChannelId},
};
use ibc_relayer_types::Height;

use crate::cli_utils::spawn_chain_runtime;
use crate::conclude::{exit_with_unrecoverable_error, Output};
use crate::error::Error;
use crate::prelude::*;

#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)]
pub struct QueryConnectionEndCmd {
Expand Down
15 changes: 9 additions & 6 deletions crates/relayer-cli/src/commands/query/packet/ack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ use abscissa_core::clap::Parser;
use ibc_relayer::chain::requests::{IncludeProof, QueryHeight, QueryPacketAcknowledgementRequest};
use subtle_encoding::{Encoding, Hex};

use crate::{
cli_utils::spawn_chain_runtime,
conclude::{exit_with_unrecoverable_error, Output},
error::Error,
prelude::*,
};
use ibc_relayer::chain::handle::ChainHandle;
use ibc_relayer_types::core::ics04_channel::packet::Sequence;
use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ChannelId, PortId};
use ibc_relayer_types::Height;

use crate::cli_utils::spawn_chain_runtime;
use crate::conclude::{exit_with_unrecoverable_error, Output};
use crate::error::Error;
use crate::prelude::*;

#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)]
pub struct QueryPacketAcknowledgmentCmd {
Expand Down
1 change: 0 additions & 1 deletion crates/relayer-cli/src/commands/query/packet/pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use crate::error::Error;
use crate::prelude::*;

use super::util::CollatedPendingPackets;
use crate::{cli_utils::spawn_chain_counterparty, conclude::Output, error::Error, prelude::*};

/// A structure to display pending packet commitment sequence IDs
/// at both ends of a channel.
Expand Down
6 changes: 5 additions & 1 deletion crates/relayer-cli/src/commands/tx/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ use ibc_relayer_types::core::ics04_channel::channel::Ordering;
use ibc_relayer_types::core::ics24_host::identifier::{
ChainId, ChannelId, ClientId, ConnectionId, PortId,
};
use ibc_relayer_types::events::IbcEvent;

use crate::{cli_utils::ChainHandlePair, conclude::Output, error::Error, prelude::*};
use crate::cli_utils::ChainHandlePair;
use crate::conclude::Output;
use crate::error::Error;
use crate::prelude::*;

/// Macro that generates the `Runnable::run` implementation for a
/// `tx channel` subcommand.
Expand Down
Loading

0 comments on commit 0789c11

Please sign in to comment.