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

Split out test framework from integration tests #1961

Merged
merged 4 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 33 additions & 19 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"telemetry",
"proto",
"tools/integration-test",
"tools/test-framework",
]

exclude = [
Expand Down
20 changes: 1 addition & 19 deletions tools/integration-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,11 @@ ibc = { path = "../../modules" }
ibc-relayer = { path = "../../relayer" }
ibc-relayer-cli = { path = "../../relayer-cli" }
ibc-proto = { path = "../../proto" }
ibc-test-framework = { path = "../test-framework" }
tendermint = { version = "=0.23.5" }
tendermint-rpc = { version = "=0.23.5", features = ["http-client", "websocket-client"] }

tokio = { version = "1.0", features = ["full"] }
tracing = "0.1.32"
tracing-subscriber = "0.3.9"
eyre = "0.6.7"
color-eyre = "0.6"
rand = "0.8.5"
env_logger = "0.9.0"
hex = "0.4.3"
serde = "1.0"
serde_json = "1"
serde_yaml = "0.8.23"
itertools = "0.10"
toml = "0.5"
subtle-encoding = "0.5.1"
sha2 = "0.10.2"
crossbeam-channel = "0.5.2"
prost = { version = "0.9", default-features = false }
prost-types = { version = "0.9", default-features = false }
semver = "1.0.6"
flex-error = "0.4.4"

[features]
default = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
```
*/

use ibc_integration_test::prelude::*;
use ibc_relayer::keyring::Store;
use ibc_test_framework::prelude::*;

struct Test;

Expand Down
20 changes: 0 additions & 20 deletions tools/integration-test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1 @@
// #![deny(warnings)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::type_complexity)]
#![allow(clippy::ptr_arg)]
#![doc = include_str!("../README.md")]

extern crate alloc;

pub mod bootstrap;
pub mod chain;
pub mod error;
pub mod framework;
pub mod ibc;
pub mod prelude;
pub mod relayer;
pub mod types;
pub mod util;

#[cfg(any(test, doc))]
#[macro_use]
pub mod tests;
6 changes: 3 additions & 3 deletions tools/integration-test/src/tests/clear_packet.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::ibc::denom::derive_ibc_denom;
use crate::prelude::*;
use crate::util::random::random_u64_range;
use ibc_test_framework::ibc::denom::derive_ibc_denom;
use ibc_test_framework::prelude::*;
use ibc_test_framework::util::random::random_u64_range;

#[test]
fn test_clear_packet() -> Result<(), Error> {
Expand Down
16 changes: 8 additions & 8 deletions tools/integration-test/src/tests/client_expiration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ use ibc_relayer::config::default::connection_delay as default_connection_delay;
use ibc_relayer::config::{self, Config, ModeConfig};
use std::thread::sleep;

use crate::bootstrap::binary::chain::bootstrap_foreign_client_pair;
use crate::bootstrap::binary::channel::{
use ibc_test_framework::bootstrap::binary::chain::bootstrap_foreign_client_pair;
use ibc_test_framework::bootstrap::binary::channel::{
bootstrap_channel_with_chains, bootstrap_channel_with_connection,
};
use crate::bootstrap::binary::connection::bootstrap_connection;
use crate::ibc::denom::derive_ibc_denom;
use crate::prelude::*;
use crate::relayer::channel::{
use ibc_test_framework::bootstrap::binary::connection::bootstrap_connection;
use ibc_test_framework::ibc::denom::derive_ibc_denom;
use ibc_test_framework::prelude::*;
use ibc_test_framework::relayer::channel::{
assert_eventually_channel_established, init_channel, query_channel_end,
};
use crate::relayer::connection::{
use ibc_test_framework::relayer::connection::{
assert_eventually_connection_established, init_connection, query_connection_end,
};
use crate::relayer::refresh::spawn_refresh_client_tasks;
use ibc_test_framework::relayer::refresh::spawn_refresh_client_tasks;

// The cosmos ChainHandle handles requests in serial, and a refresh client
// request may get blocked by other operations and cause the refresh to fail
Expand Down
12 changes: 6 additions & 6 deletions tools/integration-test/src/tests/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

We first define an empty struct [`ExampleTest`] to represent our test case.
We then implement the
[`BinaryChannelTest`](crate::framework::binary::channel::BinaryChannelTest)
[`BinaryChannelTest`](ibc_test_framework::framework::binary::channel::BinaryChannelTest)
trait so that the test framework sets up the relayer with two chains
running together with connected channels.

Expand All @@ -44,12 +44,12 @@

Finally, we define the `example_test` function with the `#[test]` pragma
as the entry point for Rust to execute the test. We call the runner function
[`run_binary_channel_test`](crate::framework::binary::channel::run_binary_channel_test),
[`run_binary_channel_test`](ibc_test_framework::framework::binary::channel::run_binary_channel_test),
which accepts a reference to any struct implementing
[`BinaryChannelTest`](crate::framework::binary::channel::BinaryChannelTest)
[`BinaryChannelTest`](ibc_test_framework::framework::binary::channel::BinaryChannelTest)
and run the test for us.

By convention, the tests written are placed in the [`tests`](crate::tests)
By convention, the tests written are placed in the [`tests`](ibc_test_framework::tests)
module. We can then run the test on the command line such as follows:

```bash
Expand All @@ -62,7 +62,7 @@
and `RUST_BACKTRACE` to display backtrace when errors occurred.
The test flag `--test-threads=1` is set so that Rust do not run multiple
tests in parallel, as it can make it difficult to follow the logs.
See [TestConfig](crate::types::config::TestConfig) for more information
See [TestConfig](ibc_test_framework::types::config::TestConfig) for more information
about configuring how the tests should be run.

For this example, we disable the test from running by default, since
Expand Down Expand Up @@ -112,7 +112,7 @@
same directory.
*/

use crate::prelude::*;
use ibc_test_framework::prelude::*;

#[test]
pub fn example_test() -> Result<(), Error> {
Expand Down
2 changes: 1 addition & 1 deletion tools/integration-test/src/tests/manual/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
are only enabled when the `"manual"` feature flag is enabled manually.

Any tests that require manual verification should be placed here.
It is also fine to use [`suspend`](crate::util::suspend::suspend)
It is also fine to use [`suspend`](ibc_test_framework::util::suspend::suspend)
inside the manual test, as the CI is not going to run the test.
*/

Expand Down
4 changes: 2 additions & 2 deletions tools/integration-test/src/tests/manual/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
use core::time::Duration;
use ibc_relayer::config::{types::MaxMsgNum, Config};

use crate::prelude::*;
use crate::relayer::transfer::tx_raw_ft_transfer;
use ibc_test_framework::prelude::*;
use ibc_test_framework::relayer::transfer::tx_raw_ft_transfer;

#[test]
fn test_simulation() -> Result<(), Error> {
Expand Down
6 changes: 3 additions & 3 deletions tools/integration-test/src/tests/memo.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use ibc_relayer::config::{types::Memo, Config};
use serde_json as json;

use crate::ibc::denom::derive_ibc_denom;
use crate::prelude::*;
use crate::util::random::{random_string, random_u64_range};
use ibc_test_framework::ibc::denom::derive_ibc_denom;
use ibc_test_framework::prelude::*;
use ibc_test_framework::util::random::{random_string, random_u64_range};

#[test]
fn test_memo() -> Result<(), Error> {
Expand Down
6 changes: 3 additions & 3 deletions tools/integration-test/src/tests/ordered_channel.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::ibc::denom::derive_ibc_denom;
use crate::prelude::*;
use crate::util::random::random_u64_range;
use ibc_test_framework::ibc::denom::derive_ibc_denom;
use ibc_test_framework::prelude::*;
use ibc_test_framework::util::random::random_u64_range;

#[test]
fn test_ordered_channel() -> Result<(), Error> {
Expand Down
8 changes: 4 additions & 4 deletions tools/integration-test/src/tests/supervisor.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::ibc::denom::derive_ibc_denom;
use ibc_test_framework::ibc::denom::derive_ibc_denom;
use ibc_relayer::config::{self, Config, ModeConfig};

use crate::prelude::*;
use crate::relayer::channel::{assert_eventually_channel_established, init_channel};
use crate::relayer::connection::{assert_eventually_connection_established, init_connection};
use ibc_test_framework::prelude::*;
use ibc_test_framework::relayer::channel::{assert_eventually_channel_established, init_channel};
use ibc_test_framework::relayer::connection::{assert_eventually_connection_established, init_connection};

#[test]
fn test_supervisor() -> Result<(), Error> {
Expand Down
4 changes: 2 additions & 2 deletions tools/integration-test/src/tests/ternary_transfer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::ibc::denom::derive_ibc_denom;
use crate::prelude::*;
use ibc_test_framework::ibc::denom::derive_ibc_denom;
use ibc_test_framework::prelude::*;

#[test]
fn test_ternary_ibc_transfer() -> Result<(), Error> {
Expand Down
6 changes: 3 additions & 3 deletions tools/integration-test/src/tests/transfer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::ibc::denom::derive_ibc_denom;
use crate::prelude::*;
use crate::util::random::random_u64_range;
use ibc_test_framework::ibc::denom::derive_ibc_denom;
use ibc_test_framework::prelude::*;
use ibc_test_framework::util::random::random_u64_range;

#[test]
fn test_ibc_transfer() -> Result<(), Error> {
Expand Down
File renamed without changes.
43 changes: 43 additions & 0 deletions tools/test-framework/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[package]
name = "ibc-test-framework"
version = "0.13.0-rc.0"
edition = "2021"
license = "Apache-2.0"
readme = "README.md"
keywords = ["blockchain", "consensus", "cosmos", "ibc", "tendermint"]
homepage = "https://hermes.informal.systems/"
repository = "https://github.com/informalsystems/ibc-rs"
authors = ["Informal Systems <hello@informal.systems>"]

description = """
Integration tests for IBC Relayer
"""

[dependencies]
ibc = { path = "../../modules" }
ibc-relayer = { path = "../../relayer" }
ibc-relayer-cli = { path = "../../relayer-cli" }
ibc-proto = { path = "../../proto" }
tendermint = { version = "=0.23.5" }
tendermint-rpc = { version = "=0.23.5", features = ["http-client", "websocket-client"] }

tokio = { version = "1.0", features = ["full"] }
tracing = "0.1.32"
tracing-subscriber = "0.3.9"
eyre = "0.6.7"
color-eyre = "0.6"
rand = "0.8.5"
env_logger = "0.9.0"
hex = "0.4.3"
serde = "1.0"
serde_json = "1"
serde_yaml = "0.8.23"
itertools = "0.10"
toml = "0.5"
subtle-encoding = "0.5.1"
sha2 = "0.10.2"
crossbeam-channel = "0.5.2"
prost = { version = "0.9", default-features = false }
prost-types = { version = "0.9", default-features = false }
semver = "1.0.6"
flex-error = "0.4.4"
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions tools/test-framework/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// #![deny(warnings)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::type_complexity)]
#![allow(clippy::ptr_arg)]
#![doc = include_str!("../README.md")]

extern crate alloc;

pub mod bootstrap;
pub mod chain;
pub mod error;
pub mod framework;
pub mod ibc;
pub mod prelude;
pub mod relayer;
pub mod types;
pub mod util;