Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use TEST_PRESET env to run cosmos tests with different chains #477

Merged
12 changes: 9 additions & 3 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ jobs:
cosmos-integration-tests:
runs-on: ubuntu-20.04
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
preset:
- GaiaToGaia
- OsmosisToOsmosis
- OsmosisToGaia
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
Expand All @@ -32,10 +39,9 @@ jobs:
- name: run integration tests
env:
RUST_BACKTRACE: 1
TEST_PRESET: ${{ matrix.preset }}
run: |
export LEGACY_GAIA_BIN=$(nix build .#gaia14 --print-out-paths --no-link)/bin/gaiad

nix shell .#cargo-nextest .#protobuf .#gaia .#celestia-app .#ibc-go-v8-simapp -c \
nix shell .#cargo-nextest .#protobuf .#gaia .#celestia-app .#ibc-go-v8-simapp .#osmosis -c \
cargo nextest run -p hermes-cosmos-integration-tests \
--test-threads=2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::sync::Arc;
use cgp::core::component::UseContext;
use cgp::core::error::{ErrorRaiserComponent, ErrorTypeComponent};
use cgp::prelude::*;
use hermes_cosmos_chain_components::types::config::gas::dynamic_gas_config::DynamicGasConfig;
use hermes_cosmos_relayer::contexts::build::CosmosBuilder;
use hermes_cosmos_test_components::bootstrap::components::cosmos_sdk_legacy::*;
use hermes_cosmos_test_components::bootstrap::impls::generator::wallet_config::GenerateStandardWalletConfig;
Expand All @@ -14,9 +15,7 @@ use hermes_cosmos_test_components::bootstrap::traits::fields::account_prefix::Ac
use hermes_cosmos_test_components::bootstrap::traits::fields::chain_command_path::ChainCommandPathGetterComponent;
use hermes_cosmos_test_components::bootstrap::traits::fields::chain_store_dir::ChainStoreDirGetterComponent;
use hermes_cosmos_test_components::bootstrap::traits::fields::denom::DenomPrefixGetterComponent;
use hermes_cosmos_test_components::bootstrap::traits::fields::dynamic_gas_fee::{
DynamicGasGetterComponent, ReturnNoDynamicGas,
};
use hermes_cosmos_test_components::bootstrap::traits::fields::dynamic_gas_fee::DynamicGasGetterComponent;
use hermes_cosmos_test_components::bootstrap::traits::fields::random_id::RandomIdFlagGetterComponent;
use hermes_cosmos_test_components::bootstrap::traits::generator::generate_wallet_config::WalletConfigGeneratorComponent;
use hermes_cosmos_test_components::bootstrap::traits::modifiers::modify_comet_config::CometConfigModifierComponent;
Expand Down Expand Up @@ -66,6 +65,7 @@ pub struct LegacyCosmosBootstrapFields {
Box<dyn Fn(&mut serde_json::Value) -> Result<(), Error> + Send + Sync + 'static>,
pub comet_config_modifier:
Box<dyn Fn(&mut toml::Value) -> Result<(), Error> + Send + Sync + 'static>,
pub dynamic_gas: Option<DynamicGasConfig>,
}

impl CanUseLegacyCosmosSdkChainBootstrapper for LegacyCosmosBootstrap {}
Expand Down Expand Up @@ -112,15 +112,14 @@ delegate_components! {
ChainCommandPathGetterComponent,
AccountPrefixGetterComponent,
DenomPrefixGetterComponent,
DynamicGasGetterComponent,
RandomIdFlagGetterComponent,
CompatModeGetterComponent,
CosmosBuilderGetterComponent,
CometConfigModifierComponent,
CosmosGenesisConfigModifierComponent,
]:
UseContext,
DynamicGasGetterComponent:
ReturnNoDynamicGas,
CosmosSdkConfigModifierComponent:
NoModifyCosmosSdkConfig,
RelayerChainConfigBuilderComponent:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use core::time::Duration;

use cgp::core::error::CanRaiseError;
use hermes_cosmos_relayer::contexts::chain::CosmosChain;
use hermes_cosmos_test_components::bootstrap::traits::fields::dynamic_gas_fee::HasDynamicGas;
use hermes_cosmos_test_components::bootstrap::traits::types::chain_node_config::HasChainNodeConfigType;
use hermes_cosmos_test_components::chain::types::wallet::CosmosTestWallet;
use hermes_error::types::HermesError;
Expand All @@ -22,6 +23,7 @@ where
+ CanBuildRelayerChainConfig
+ HasCosmosBuilder
+ HasRuntime
+ HasDynamicGas
+ CanRaiseError<HermesError>,
Bootstrap::Runtime: CanSleep,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use core::str::FromStr;
use core::time::Duration;

use cgp::core::error::CanRaiseError;
use hermes_cosmos_chain_components::impls::types::config::CosmosChainConfig;
use hermes_cosmos_chain_components::impls::types::config::{CosmosChainConfig, EventSourceMode};
use hermes_cosmos_chain_components::types::config::gas::gas_config::GasConfig;
use hermes_cosmos_test_components::bootstrap::traits::fields::account_prefix::HasAccountPrefix;
use hermes_cosmos_test_components::bootstrap::traits::fields::dynamic_gas_fee::HasDynamicGas;
use hermes_cosmos_test_components::bootstrap::traits::types::chain_node_config::HasChainNodeConfigType;
Expand All @@ -12,12 +13,10 @@ use hermes_cosmos_test_components::bootstrap::types::genesis_config::CosmosGenes
use hermes_cosmos_test_components::chain::types::wallet::CosmosTestWallet;
use hermes_test_components::chain::traits::types::wallet::HasWalletType;
use hermes_test_components::chain_driver::traits::types::chain::HasChainType;
use ibc_relayer::chain::cosmos::config::CosmosSdkConfig;
use ibc_relayer::config::dynamic_gas::DynamicGasPrice;
use ibc_relayer::config::gas_multiplier::GasMultiplier;
use ibc_proto::cosmos::base::v1beta1::Coin;
use ibc_proto::cosmos::tx::v1beta1::Fee;
use ibc_relayer::config::{self, AddressType};
use ibc_relayer::keyring::Store;
use tendermint_rpc::{Error as TendermintRpcError, Url, WebSocketClientUrl};
use tendermint_rpc::{Error as TendermintRpcError, Url};

use crate::traits::bootstrap::compat_mode::HasCompatMode;
use crate::traits::bootstrap::relayer_chain_config::RelayerChainConfigBuilder;
Expand All @@ -41,63 +40,59 @@ where
chain_genesis_config: &CosmosGenesisConfig,
relayer_wallet: &CosmosTestWallet,
) -> Result<CosmosChainConfig, Bootstrap::Error> {
let dynamic_gas_price = if let Some(dynamic_gas_config) = bootstrap.dynamic_gas() {
DynamicGasPrice::unsafe_new(true, dynamic_gas_config.multiplier, dynamic_gas_config.max)
} else {
DynamicGasPrice::default()
let gas_multiplier = 1.3;
let gas_price = 1.0;
let fee_granter = "".to_owned();
let max_gas = 900000000;
let max_amount = (max_gas as f64 * gas_multiplier) * gas_price;
let max_gas_fee_in_coin = Coin {
denom: chain_genesis_config.staking_denom.to_string(),
amount: max_amount.to_string(),
};
let relayer_chain_config = CosmosSdkConfig {
id: chain_node_config.chain_id.clone(),

let max_fee = Fee {
amount: vec![max_gas_fee_in_coin],
gas_limit: max_gas,
payer: "".to_string(),
granter: fee_granter.clone(),
};

let gas_config = GasConfig {
default_gas: 400_000,
max_gas,
gas_multiplier,
gas_price: config::GasPrice::new(1.0, chain_genesis_config.staking_denom.to_string()),
max_fee,
fee_granter,
dynamic_gas_config: bootstrap.dynamic_gas().clone(),
};

let relayer_chain_config = CosmosChainConfig {
id: chain_node_config.chain_id.to_string(),
rpc_addr: Url::from_str(&format!("http://localhost:{}", chain_node_config.rpc_port))
.map_err(Bootstrap::raise_error)?,
grpc_addr: Url::from_str(&format!("http://localhost:{}", chain_node_config.grpc_port))
.map_err(Bootstrap::raise_error)?,
event_source: config::EventSourceMode::Push {
url: WebSocketClientUrl::from_str(&format!(
"ws://localhost:{}/websocket",
chain_node_config.rpc_port
))
.map_err(Bootstrap::raise_error)?,
batch_delay: config::default::batch_delay(),
event_source: EventSourceMode::Push {
url: format!("ws://localhost:{}/websocket", chain_node_config.rpc_port),
},
rpc_timeout: config::default::rpc_timeout(),
trusted_node: false,
genesis_restart: None,
account_prefix: bootstrap.account_prefix().into(),
key_name: relayer_wallet.id.clone(),
key_store_type: Store::Test,
key_store_folder: Some(chain_node_config.chain_home_dir.join("hermes_keyring")),
store_prefix: "ibc".to_string(),
default_gas: None,
max_gas: Some(900000000),
gas_adjustment: None,
gas_multiplier: Some(GasMultiplier::unsafe_new(1.3)),
dynamic_gas_price,
fee_granter: None,
max_msg_num: Default::default(),
max_tx_size: Default::default(),
max_grpc_decoding_size: config::default::max_grpc_decoding_size(),
query_packets_chunk_size: config::default::query_packets_chunk_size(),
max_block_time: Duration::from_secs(30),
clock_drift: Duration::from_secs(5),
trusting_period: Some(Duration::from_secs(14 * 24 * 3600)),
client_refresh_rate: config::default::client_refresh_rate(),
ccv_consumer_chain: false,
trust_threshold: Default::default(),
gas_price: config::GasPrice::new(1.0, chain_genesis_config.staking_denom.to_string()),
packet_filter: Default::default(),
address_type: AddressType::Cosmos,
memo_prefix: Default::default(),
memo_overwrite: None,
proof_specs: Default::default(),
gas_config,
address_type: AddressType::Cosmos.to_string(),
extension_options: Default::default(),
sequential_batch_tx: false,
compat_mode: bootstrap.compat_mode().cloned(),
clear_interval: None,
excluded_sequences: Default::default(),
allow_ccq: false,
compat_mode: bootstrap
.compat_mode()
.map(|compat_mode| compat_mode.to_string()),
};

Ok(relayer_chain_config.into())
Ok(relayer_chain_config)
}
}
Loading
Loading