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

Enable logging in tests and fix error log flooding from mock chain runtime #1017

Merged
merged 1 commit into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --no-fail-fast
args: --all-features --no-fail-fast -- --nocapture

# test-coverage:
# runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ data
# Ignore Python artifacts
.mypy_cache/
__pycache__/

.modelator
30 changes: 30 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions modules/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ version = "=0.19.0"
optional = true

[dev-dependencies]
env_logger = "0.8.3"
tracing-subscriber = "0.2.18"
test-env-log = { version = "0.2.7", features = ["trace"] }
modelator = { git = "https://github.com/informalsystems/modelator", rev = "99f656fa8b3cf46a2aa0b6513e4e140d1778c4bd" }
tendermint-rpc = { version = "=0.19.0", features = ["http-client", "websocket-client"] }
tendermint-testgen = { version = "=0.19.0" } # Needed for generating (synthetic) light blocks.
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics02_client/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ impl From<IdentifiedAnyClientState> for IdentifiedClientState {
#[cfg(test)]
mod tests {
use std::convert::TryFrom;
use test_env_log::test;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should keep this around. Do you think it would be valuable to have logging enabled in tests going forward?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think they help especially when the tests are failing. Not having them enabled would only make it more inconvenient for contributors to write new tests and fix failing tests. The logging setup for Rust is not very straightforward, and just figuring out how to enable that can waste minutes to hour of a contributor's time.


use prost_types::Any;

Expand Down
1 change: 1 addition & 0 deletions modules/src/ics02_client/client_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ impl std::str::FromStr for ClientType {
#[cfg(test)]
mod tests {
use std::str::FromStr;
use test_env_log::test;

use super::ClientType;

Expand Down
1 change: 1 addition & 0 deletions modules/src/ics02_client/handler/create_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub fn process(
mod tests {
use std::convert::TryInto;
use std::time::Duration;
use test_env_log::test;

use tendermint::trust_threshold::TrustThresholdFraction as TrustThreshold;

Expand Down
1 change: 1 addition & 0 deletions modules/src/ics02_client/handler/update_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub fn process(
#[cfg(test)]
mod tests {
use std::str::FromStr;
use test_env_log::test;

use crate::events::IbcEvent;
use crate::handler::HandlerOutput;
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics02_client/msgs/create_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ impl From<MsgCreateAnyClient> for RawMsgCreateClient {
#[cfg(test)]
mod tests {
use std::convert::{TryFrom, TryInto};
use test_env_log::test;

use ibc_proto::ibc::core::client::v1::MsgCreateClient;

Expand Down
1 change: 1 addition & 0 deletions modules/src/ics02_client/msgs/update_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ impl From<MsgUpdateAnyClient> for RawMsgUpdateClient {
#[cfg(test)]
mod tests {
use std::convert::TryFrom;
use test_env_log::test;

use ibc_proto::ibc::core::client::v1::MsgUpdateClient;

Expand Down
1 change: 1 addition & 0 deletions modules/src/ics03_connection/handler/conn_open_ack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ pub(crate) fn process(
mod tests {
use std::convert::TryFrom;
use std::str::FromStr;
use test_env_log::test;

use crate::events::IbcEvent;
use crate::ics03_connection::connection::{ConnectionEnd, Counterparty, State};
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics03_connection/handler/conn_open_confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub(crate) fn process(
mod tests {
use std::convert::TryFrom;
use std::str::FromStr;
use test_env_log::test;

use crate::events::IbcEvent;
use crate::ics03_connection::connection::{ConnectionEnd, Counterparty, State};
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics03_connection/handler/conn_open_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub(crate) fn process(
#[cfg(test)]
mod tests {
use std::convert::TryFrom;
use test_env_log::test;

use crate::events::IbcEvent;
use crate::ics03_connection::connection::State;
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics03_connection/handler/conn_open_try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub(crate) fn process(
#[cfg(test)]
mod tests {
use std::convert::TryFrom;
use test_env_log::test;

use crate::events::IbcEvent;
use crate::ics03_connection::connection::State;
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics03_connection/msgs/conn_open_ack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ pub mod test_util {
#[cfg(test)]
mod tests {
use std::convert::TryFrom;
use test_env_log::test;

use ibc_proto::ibc::core::client::v1::Height;
use ibc_proto::ibc::core::connection::v1::MsgConnectionOpenAck as RawMsgConnectionOpenAck;
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics03_connection/msgs/conn_open_confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ pub mod test_util {
#[cfg(test)]
mod tests {
use std::convert::TryFrom;
use test_env_log::test;

use ibc_proto::ibc::core::client::v1::Height;
use ibc_proto::ibc::core::connection::v1::MsgConnectionOpenConfirm as RawMsgConnectionOpenConfirm;
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics03_connection/msgs/conn_open_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub mod test_util {
#[cfg(test)]
mod tests {
use std::convert::TryFrom;
use test_env_log::test;

use ibc_proto::ibc::core::connection::v1::Counterparty as RawCounterparty;
use ibc_proto::ibc::core::connection::v1::MsgConnectionOpenInit as RawMsgConnectionOpenInit;
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics03_connection/msgs/conn_open_try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ pub mod test_util {
#[cfg(test)]
mod tests {
use std::convert::TryFrom;
use test_env_log::test;

use ibc_proto::ibc::core::client::v1::Height;
use ibc_proto::ibc::core::connection::v1::Counterparty as RawCounterparty;
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics03_connection/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ pub fn pick_version(
#[cfg(test)]
mod tests {
use std::convert::{TryFrom, TryInto};
use test_env_log::test;

use ibc_proto::ibc::core::connection::v1::Version as RawVersion;

Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ pub mod test_util {
mod tests {
use std::convert::TryFrom;
use std::str::FromStr;
use test_env_log::test;

use ibc_proto::ibc::core::channel::v1::Channel as RawChannel;

Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/handler/acknowledgement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ mod tests {
use crate::ics24_host::identifier::{ChannelId, ClientId, ConnectionId, PortId};
use crate::mock::context::MockContext;
use crate::timestamp::ZERO_DURATION;
use test_env_log::test;

use std::convert::TryFrom;

Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/handler/chan_open_ack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pub(crate) fn process(
mod tests {
use std::convert::TryFrom;
use std::str::FromStr;
use test_env_log::test;

use crate::events::IbcEvent;
use crate::ics03_connection::connection::ConnectionEnd;
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/handler/chan_open_confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pub(crate) fn process(
#[cfg(test)]
mod tests {
use std::convert::TryFrom;
use test_env_log::test;

use crate::events::IbcEvent;
use crate::ics02_client::client_type::ClientType;
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/handler/chan_open_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ pub(crate) fn process(
#[cfg(test)]
mod tests {
use std::convert::TryFrom;
use test_env_log::test;

use crate::events::IbcEvent;
use crate::ics03_connection::connection::ConnectionEnd;
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/handler/chan_open_try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ pub(crate) fn process(
#[cfg(test)]
mod tests {
use std::convert::TryFrom;
use test_env_log::test;

use crate::events::IbcEvent;
use crate::ics02_client::client_type::ClientType;
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/handler/recv_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ pub fn process(ctx: &dyn ChannelReader, msg: MsgRecvPacket) -> HandlerResult<Pac
#[cfg(test)]
mod tests {
use std::convert::TryFrom;
use test_env_log::test;

use crate::ics03_connection::connection::ConnectionEnd;
use crate::ics03_connection::connection::Counterparty as ConnectionCounterparty;
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/handler/send_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ pub fn send_packet(ctx: &dyn ChannelReader, packet: Packet) -> HandlerResult<Pac
#[cfg(test)]
mod tests {
use std::convert::TryInto;
use test_env_log::test;

use crate::events::IbcEvent;
use crate::ics02_client::height::Height;
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/handler/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ mod tests {
use crate::mock::context::MockContext;

use std::convert::TryFrom;
use test_env_log::test;

#[test]
fn timeout_packet_processing() {
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/handler/timeout_on_close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ mod tests {
use crate::mock::context::MockContext;

use std::convert::TryFrom;
use test_env_log::test;

#[test]
fn timeout_on_close_packet_processing() {
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/handler/write_acknowledgement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ pub fn process(
#[cfg(test)]
mod tests {
use std::convert::TryInto;
use test_env_log::test;

use crate::ics02_client::height::Height;
use crate::ics03_connection::connection::ConnectionEnd;
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/msgs/acknowledgement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ pub mod test_util {
#[cfg(test)]
mod test {
use std::convert::TryInto;
use test_env_log::test;

use ibc_proto::ibc::core::channel::v1::MsgAcknowledgement as RawMsgAcknowledgement;

Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/msgs/chan_close_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ pub mod test_util {
#[cfg(test)]
mod tests {
use std::convert::TryFrom;
use test_env_log::test;

use ibc_proto::ibc::core::channel::v1::MsgChannelCloseInit as RawMsgChannelCloseInit;

Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/msgs/chan_open_ack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ pub mod test_util {
#[cfg(test)]
mod tests {
use ibc_proto::ibc::core::channel::v1::MsgChannelOpenAck as RawMsgChannelOpenAck;
use test_env_log::test;

use crate::ics04_channel::msgs::chan_open_ack::test_util::get_dummy_raw_msg_chan_open_ack;
use crate::ics04_channel::msgs::chan_open_ack::MsgChannelOpenAck;
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/msgs/chan_open_confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ pub mod test_util {
#[cfg(test)]
mod tests {
use ibc_proto::ibc::core::channel::v1::MsgChannelOpenConfirm as RawMsgChannelOpenConfirm;
use test_env_log::test;

use crate::ics04_channel::msgs::chan_open_confirm::test_util::get_dummy_raw_msg_chan_open_confirm;
use crate::ics04_channel::msgs::chan_open_confirm::MsgChannelOpenConfirm;
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/msgs/chan_open_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ mod tests {
use crate::ics04_channel::msgs::chan_open_init::MsgChannelOpenInit;
use ibc_proto::ibc::core::channel::v1::MsgChannelOpenInit as RawMsgChannelOpenInit;
use std::convert::TryFrom;
use test_env_log::test;

#[test]
fn channel_open_init_from_raw() {
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/msgs/chan_open_try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ mod tests {
use ibc_proto::ibc::core::channel::v1::MsgChannelOpenTry as RawMsgChannelOpenTry;
use ibc_proto::ibc::core::client::v1::Height;
use std::convert::TryFrom;
use test_env_log::test;

#[test]
fn channel_open_try_from_raw() {
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/msgs/recv_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ pub mod test_util {
#[cfg(test)]
mod test {
use std::convert::{TryFrom, TryInto};
use test_env_log::test;

use ibc_proto::ibc::core::channel::v1::MsgRecvPacket as RawMsgRecvPacket;

Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/msgs/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ pub mod test_util {
#[cfg(test)]
mod test {
use std::convert::{TryFrom, TryInto};
use test_env_log::test;

use ibc_proto::ibc::core::channel::v1::MsgTimeout as RawMsgTimeout;

Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ pub mod test_utils {
#[cfg(test)]
mod tests {
use std::convert::TryFrom;
use test_env_log::test;

use ibc_proto::ibc::core::channel::v1::Packet as RawPacket;

Expand Down
1 change: 1 addition & 0 deletions modules/src/ics07_tendermint/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ impl From<ClientState> for RawClientState {
#[cfg(test)]
mod tests {
use std::time::Duration;
use test_env_log::test;

use tendermint::trust_threshold::TrustThresholdFraction as TrustThreshold;
use tendermint_rpc::endpoint::abci_query::AbciQuery;
Expand Down
Loading