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

feat: restructure mock module and separate its codebase into a new crate #954

Merged
merged 26 commits into from
Nov 10, 2023

Conversation

Farhad-Shabani
Copy link
Member

@Farhad-Shabani Farhad-Shabani commented Nov 8, 2023

Closes: #953
Closes: #952
Closes: #951

Description

The mock implementation has undergone a comprehensive restructuring aimed at achieving complete decoupling of its various components and organizing them under relevant categories. This should facilitate future enhancements, particularly the addition of new implementations for components such as relayers and mock chains.

This restructuring results in four distinct top-level groups as follows:

  • hosts: Encompasses code related to chains, with a particular focus on definitions related to the consensus layer of these chains.
  • testapp: Codebases relevant to the application end (state transition machine) of a chain. It may contain various modules, including IBC.
  • relayer: Houses types and functionalities required for simulating the role of a mock relayer, facilitating IBC talk between our testing chains.
  • utils: Contains utility types, functions, and other tools that assist in writing tests.

By the way, this is the first iteration and we might improve it in the future as we refactor our testing kits.

The new crate is named ibc-testkit, and here is an overview of its directory structure:

.
├── hosts
│   ├── block.rs
│   └── mod.rs
├── lib.rs
├── relayer
│   ├── context.rs
│   ├── error.rs
│   └── mod.rs
├── testapp
│   ├── ibc
│   │   ├── applications
│   │   │   ├── mod.rs
│   │   │   └── transfer
│   │   ├── clients
│   │   │   ├── mock
│   │   │   └── mod.rs
│   │   ├── core
│   │   │   ├── client_ctx.rs
│   │   │   ├── core_ctx.rs
│   │   │   ├── mod.rs
│   │   │   ├── router
│   │   │   └── types.rs
│   │   └── mod.rs
│   └── mod.rs
└── utils
    ├── dummies
    │   ├── applications
    │   │   ├── mod.rs
    │   │   └── transfer.rs
    │   ├── clients
    │   │   ├── mock.rs
    │   │   ├── mod.rs
    │   │   └── tendermint.rs
    │   ├── core
    │   │   ├── channel
    │   │   ├── client
    │   │   ├── commitment.rs
    │   │   ├── connection
    │   │   ├── context.rs
    │   │   ├── mod.rs
    │   │   └── signer.rs
    │   ├── json
    │   │   ├── client_state.json
    │   │   ├── client_state_proof.json
    │   │   ├── consensus_state.json
    │   │   ├── consensus_state_proof.json
    │   │   └── signed_header.json
    │   └── mod.rs
    ├── fixture.rs
    └── mod.rs

Remark


PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests.
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).
  • Tagged one reviewer who will be the one responsible for shepherding this PR.

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

Copy link

codecov bot commented Nov 8, 2023

Codecov Report

Attention: 156 lines in your changes are missing coverage. Please review.

Comparison is base (527bb14) 67.72% compared to head (3f5741e) 66.39%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #954      +/-   ##
==========================================
- Coverage   67.72%   66.39%   -1.33%     
==========================================
  Files         130      161      +31     
  Lines       16491    15770     -721     
==========================================
- Hits        11168    10470     -698     
+ Misses       5323     5300      -23     
Files Coverage Δ
crates/ibc-derive/src/utils.rs 95.38% <100.00%> (ø)
crates/ibc-testkit/src/hosts/block.rs 92.72% <100.00%> (ø)
crates/ibc-testkit/src/relayer/context.rs 73.07% <100.00%> (ø)
crates/ibc-testkit/src/relayer/error.rs 0.00% <ø> (ø)
...it/src/testapp/ibc/applications/transfer/module.rs 100.00% <100.00%> (ø)
...stkit/src/testapp/ibc/clients/mock/client_state.rs 94.86% <100.00%> (ø)
...it/src/testapp/ibc/clients/mock/consensus_state.rs 93.10% <100.00%> (ø)
...ibc-testkit/src/testapp/ibc/clients/mock/header.rs 77.21% <100.00%> (ø)
...stkit/src/testapp/ibc/clients/mock/misbehaviour.rs 88.88% <ø> (ø)
...tes/ibc-testkit/src/testapp/ibc/core/client_ctx.rs 87.19% <100.00%> (ø)
... and 88 more

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Farhad-Shabani Farhad-Shabani changed the title imp: separate mock module into a dedicated crate feat: restructure mock module and separate its codebase into a new crate Nov 8, 2023
@Farhad-Shabani Farhad-Shabani marked this pull request as ready for review November 8, 2023 19:39
Copy link
Collaborator

@rnbguy rnbguy left a comment

Choose a reason for hiding this comment

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

Thanks @Farhad-Shabani for taking care of this big PR. Just a few suggestions and questions.

README.md Outdated Show resolved Hide resolved
crates/ibc-testkit/Cargo.toml Outdated Show resolved Hide resolved
crates/ibc/Cargo.toml Outdated Show resolved Hide resolved
crates/ibc/src/clients/ics07_tendermint/header.rs Outdated Show resolved Hide resolved
crates/ibc/src/mock/header.rs Outdated Show resolved Hide resolved
crates/ibc-testkit/src/testapp/ibc/core/client_ctx.rs Outdated Show resolved Hide resolved
crates/ibc-testkit/src/testapp/ibc/core/types.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@rnbguy rnbguy left a comment

Choose a reason for hiding this comment

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

Just few more comments 🙂 Otherwise, I approved the PR.

This was a huge effort ! Thanks @Farhad-Shabani 🙏

crates/ibc/src/clients/ics07_tendermint/client_state.rs Outdated Show resolved Hide resolved
crates/ibc/src/clients/ics07_tendermint/consensus_state.rs Outdated Show resolved Hide resolved
@Farhad-Shabani Farhad-Shabani merged commit 046901f into main Nov 10, 2023
13 checks passed
@Farhad-Shabani Farhad-Shabani deleted the farhad/split-organize-mocks branch November 10, 2023 16:37
@Farhad-Shabani Farhad-Shabani mentioned this pull request Nov 14, 2023
2 tasks
Farhad-Shabani added a commit that referenced this pull request Sep 9, 2024
…ate (#954)

* imp: separate mock module into a dedicated crate

* fix: clippy, fmt, no-std

* imp: restructure second iteration

* chore: add unclogs + update READMEs

* deps: bump typed-builder

* fix: move client_ctx under core

* fix: cargo fmt

* fix: remove tracing dep from ibc

* deps: remove parking_lot from ibc

* deps: remove num-traits from ibc

* fix: apply suggestions from code review

Co-authored-by: Rano | Ranadeep <[email protected]>
Signed-off-by: Farhad Shabani <[email protected]>

* nit: apply feedback

* fix: introduce with_current_timestamp()

* fix: cargo test

* imp: move test_utils.rs into utils

* imp: move test-utils + mock into the ibc-testkit

* imp: add deny attr for tests

* chore: cleanups

* chore: add comment for ibc dep in ibc-testkit

* chore: adjust paths for types imported from ibc_testkit::utils

* chore: move tendermint::client_state::test_utils under the tests module

* imp: replace json files under the src/data dir

* chore: replace data/json under tests

* imp: use concat! for paths

---------

Signed-off-by: Farhad Shabani <[email protected]>
Co-authored-by: Rano | Ranadeep <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
2 participants