Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
chore: update sov-ibc-mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Farhad-Shabani committed Mar 8, 2024
1 parent babc662 commit 73b2353
Show file tree
Hide file tree
Showing 13 changed files with 2,443 additions and 171 deletions.
2,528 changes: 2,395 additions & 133 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
"clients/sov-celestia-cw",
"modules/sov-ibc-transfer",
"modules/sov-ibc",
# "mocks",
"mocks",
]

exclude = [
Expand Down
12 changes: 5 additions & 7 deletions mocks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,20 @@ tracing = "0.1.36"
typed-builder = "0.18.0"

# internal dependencies
sov-ibc = { git = "https://github.com/informalsystems/sovereign-ibc.git", rev = "3fe4048" }
sov-ibc-transfer = { git = "https://github.com/informalsystems/sovereign-ibc.git", rev = "3fe4048" }
sov-celestia-client = { git = "https://github.com/informalsystems/sovereign-ibc.git", rev = "3fe4048", features = ["test-util"] }
sov-ibc = { git = "https://github.com/informalsystems/sovereign-ibc.git", rev = "babc662" }
sov-ibc-transfer = { git = "https://github.com/informalsystems/sovereign-ibc.git", rev = "babc662" }
sov-celestia-client = { git = "https://github.com/informalsystems/sovereign-ibc.git", rev = "babc662", features = ["test-util"] }

# ibc dependencies
ibc-core = { workspace = true }
ibc-app-transfer = { workspace = true }
ibc-client-tendermint = { workspace = true }
ibc-core-host-cosmos = { workspace = true }
ibc-query = { workspace = true }
ibc-testkit = { git = "https://github.com/cosmos/ibc-rs.git", rev = "a9761140d3", default-features = false }
ibc-testkit = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }

# cosmos dependencies
basecoin-app = { git = "https://github.com/informalsystems/basecoin-rs.git", rev = "e668ec4" }
basecoin-store = { git = "https://github.com/informalsystems/basecoin-rs.git", rev = "e668ec4" }

basecoin = { git = "https://github.com/informalsystems/basecoin-rs.git", rev = "63013eb" }
tendermint = { workspace = true }
tendermint-testgen = { workspace = true }

Expand Down
25 changes: 12 additions & 13 deletions mocks/src/cosmos/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
//! tendermint instance.
use std::fmt::Debug;

use basecoin_app::abci::v0_37::impls::query as basecoin_query;
use basecoin_app::modules::auth::proto::AccountId;
use basecoin_app::modules::auth::Auth;
use basecoin_app::modules::bank::{Bank, BankReader, Denom};
use basecoin_app::modules::context::{prefix, Identifiable};
use basecoin_app::modules::ibc::{Ibc, IbcContext};
use basecoin_app::{BaseCoinApp, Builder};
use basecoin_store::context::ProvableStore;
use basecoin_store::impls::RevertibleStore;
use basecoin::app::abci::v0_37::impls::query as basecoin_query;
use basecoin::app::{BaseCoinApp, Builder};
use basecoin::helper::{bank, ibc};
use basecoin::modules::auth::proto::AccountId;
use basecoin::modules::auth::Auth;
use basecoin::modules::bank::{Bank, BankReader, Denom};
use basecoin::modules::context::{prefix, Identifiable};
use basecoin::modules::ibc::{Ibc, IbcContext};
use basecoin::store::context::ProvableStore;
use basecoin::store::impls::RevertibleStore;
use ibc_core::client::types::Height;
use ibc_core::commitment_types::commitment::CommitmentProofBytes;
use ibc_core::host::types::identifiers::ChainId;
Expand Down Expand Up @@ -63,17 +64,15 @@ impl<S: ProvableStore + Default + Debug> MockCosmosChain<S> {
}

pub fn ibc_ctx(&self) -> IbcContext<RevertibleStore<S>> {
self.app.ibc().ctx()
ibc(self.app.clone()).ctx()
}

pub fn get_balance_of(&self, denom: &str, account: String) -> Option<u64> {
let account_id: AccountId = account.parse().unwrap();

let denom = Denom(denom.to_string());

if let Some(coin) = self
.app
.bank()
if let Some(coin) = bank(self.app.clone())
.balance_reader()
.get_all_balances(account_id)
.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion mocks/src/cosmos/builder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Defines a builder structure for instantiating a mock Cosmos chain
use std::fmt::Debug;

use basecoin_store::context::ProvableStore;
use basecoin::store::context::ProvableStore;

use super::app::MockCosmosChain;
use super::MockTendermint;
Expand Down
2 changes: 1 addition & 1 deletion mocks/src/cosmos/configs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use basecoin_store::avl::get_proof_spec;
use basecoin::store::avl::get_proof_spec;
use ibc_client_tendermint::client_state::ClientState;
use ibc_client_tendermint::types::ConsensusState as TmConsensusState;
use ibc_core::client::types::Height;
Expand Down
2 changes: 1 addition & 1 deletion mocks/src/cosmos/manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use core::fmt::Debug;

use basecoin_store::context::ProvableStore;
use basecoin::store::context::ProvableStore;
use ibc_core::channel::types::channel::{
ChannelEnd, Counterparty as ChanCounterparty, Order, State as ChannelState,
};
Expand Down
6 changes: 3 additions & 3 deletions mocks/src/cosmos/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
use core::fmt::Debug;
use std::time::Duration;

use basecoin_app::modules::types::IdentifiedModule;
use basecoin_store::context::{ProvableStore, Store};
use basecoin_store::utils::SharedRwExt;
use basecoin::modules::types::IdentifiedModule;
use basecoin::store::context::{ProvableStore, Store};
use basecoin::store::utils::SharedRwExt;
use tendermint::abci::request::InitChain;
use tendermint::block::Height as TmHeight;
use tendermint::v0_37::abci::Request as AbciRequest;
Expand Down
17 changes: 12 additions & 5 deletions mocks/src/relayer/handle/cosmos.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use std::fmt::Debug;

use async_trait::async_trait;
use basecoin_store::context::ProvableStore;
use basecoin::helper::ibc;
use basecoin::store::context::ProvableStore;
use ibc_client_tendermint::types::Header;
use ibc_core::client::context::ClientValidationContext;
use ibc_core::handler::types::events::IbcEvent;
use ibc_core::host::types::path::ClientConsensusStatePath;
use ibc_core::host::ValidationContext;
Expand Down Expand Up @@ -30,11 +32,16 @@ impl<S: ProvableStore + Debug + Default> Handle for MockCosmosChain<S> {
QueryReq::ClientCounter => {
QueryResp::ClientCounter(self.ibc_ctx().client_counter().unwrap())
}
QueryReq::ClientState(client_id) => {
QueryResp::ClientState(self.ibc_ctx().client_state(&client_id).unwrap().into())
}
QueryReq::ClientState(client_id) => QueryResp::ClientState(
self.ibc_ctx()
.get_client_validation_context()
.client_state(&client_id)
.unwrap()
.into(),
),
QueryReq::ConsensusState(client_id, height) => QueryResp::ConsensusState(
self.ibc_ctx()
.get_client_validation_context()
.consensus_state(&ClientConsensusStatePath::new(
client_id,
height.revision_number(),
Expand Down Expand Up @@ -83,7 +90,7 @@ impl<S: ProvableStore + Debug + Default> Handle for MockCosmosChain<S> {

let events = msgs
.into_iter()
.flat_map(|msg| self.app.ibc().process_message(msg).unwrap())
.flat_map(|msg| ibc(self.app.clone()).process_message(msg).unwrap())
.collect();

wait_for_block().await;
Expand Down
12 changes: 9 additions & 3 deletions mocks/src/relayer/handle/rollup.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use async_trait::async_trait;
use ibc_client_tendermint::types::Header;
use ibc_core::channel::types::proto::v1::QueryPacketCommitmentRequest;
use ibc_core::client::context::ClientValidationContext;
use ibc_core::client::types::proto::v1::{QueryClientStateRequest, QueryConsensusStateRequest};
use ibc_core::client::types::Height;
use ibc_core::handler::types::events::IbcEvent;
Expand Down Expand Up @@ -41,11 +42,16 @@ where
QueryReq::HostConsensusState(height) => {
QueryResp::HostConsensusState(ibc_ctx.host_consensus_state(&height).unwrap().into())
}
QueryReq::ClientState(client_id) => {
QueryResp::ClientState(ibc_ctx.client_state(&client_id).unwrap().into())
}
QueryReq::ClientState(client_id) => QueryResp::ClientState(
ibc_ctx
.get_client_validation_context()
.client_state(&client_id)
.unwrap()
.into(),
),
QueryReq::ConsensusState(client_id, height) => QueryResp::ConsensusState(
ibc_ctx
.get_client_validation_context()
.consensus_state(&ClientConsensusStatePath::new(
client_id,
height.revision_number(),
Expand Down
2 changes: 1 addition & 1 deletion mocks/src/relayer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub use relay::*;

#[cfg(feature = "native")]
mod types {
use basecoin_store::impls::InMemoryStore;
use basecoin::store::impls::InMemoryStore;

use super::relay::MockRelayer;
use crate::cosmos::MockCosmosChain;
Expand Down
2 changes: 1 addition & 1 deletion mocks/src/relayer/msgs/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::str::FromStr;

use base64::engine::general_purpose;
use base64::Engine;
use basecoin_app::modules::ibc::AnyClientState;
use basecoin::modules::ibc::AnyClientState;
use ibc_app_transfer::types::msgs::transfer::MsgTransfer;
use ibc_app_transfer::types::packet::PacketData;
use ibc_app_transfer::types::{Coin, Memo, PrefixedDenom};
Expand Down
2 changes: 1 addition & 1 deletion mocks/src/tests/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use basecoin_app::modules::ibc::AnyClientState;
use basecoin::modules::ibc::AnyClientState;
use borsh::BorshDeserialize;
use ibc_client_tendermint::types::proto::v1::{
ClientState as RawClientState, ConsensusState as RawConsensusState,
Expand Down

0 comments on commit 73b2353

Please sign in to comment.