8000 [refactor] Break chain/client/src/test_utils.rs into module by shreyan-gupta · Pull Request #9611 · near/nearcore · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[refactor] Break chain/client/src/test_utils.rs into module #9611

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

Merged
merged 7 commits into from
Sep 29, 2023

Conversation

shreyan-gupta
Copy link
Contributor
@shreyan-gupta shreyan-gupta commented Sep 29, 2023

Breaking a large test_utils.rs file into multiple parts.
Additionally shifting location of TestEnvNightshadeSetupExt to nearcore so that it can be used in other modules, specifically tools/state-viewer/src/state_dump.rs.

Note that we can't have TestEnvNightshadeSetupExt in chain/client/src/test_utils as it depends on NightshadeRuntime which is a part of nearcore module.

nearcore module depends on chain and would create a cyclic dependency.

10000
@shreyan-gupta shreyan-gupta marked this pull request as ready for review September 29, 2023 15:16
@shreyan-gupta shreyan-gupta requested a review from a team as a code owner September 29, 2023 15:16
@@ -0,0 +1,88 @@
use itertools::Itertools;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove. This file has nothing

Copy link
Member
@Longarithm Longarithm left a comment

Choose a reason for hiding this comment

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

Makes sense, thank you! Leaving couple nits.
Also general suggestion - please prepend largest files in test_utils with comments what logic is inside them. I never had complete understanding what are these 2.5k lines for, and you probably understand it better now :)

pub use test_env::*;
pub use test_env_builder::*;

const TEST_SEED: RngSeed = [3; 32];
Copy link
Member

Choose a reason for hiding this comment

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

nit: probably can be moved to setup.rs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's used in test_env.rs and test_env_builder.rs as well.

Copy link
Member

Choose a reason for hiding this comment

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

I understand, but they both depend on setup, right? And I'm assuming that the files don't have cyclic dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, will shift there!

Comment on lines +10 to +15
pub use block_stats::*;
pub use client::*;
pub use peer_manager_mock::*;
pub use setup::*;
pub use test_env::*;
pub use test_env_builder::*;
Copy link
Member

Choose a reason for hiding this comment

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

It feels like we can use only one of pub mod or pub use. But I can imagine that it can lead to more chore work, so no strong opinion here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had added in the use so that the current references to these functions doesn't change, otherwise we would need to write them as use near_client::test_utils::test_env_builder::TestEnvBuilder; instead of use near_client::test_utils::TestEnvBuilder;

@@ -8,7 +8,6 @@ pub(crate) mod test_builder;
mod ts_contract;
mod wasm_validation;

#[cfg(all(feature = "near_vm", target_arch = "x86_64"))]
Copy link
Member

Choose a reason for hiding this comment

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

Why is it needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, this, I can add back but I was getting build errors locally and rust-analyzer wasn't working.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's better to remove the feature compilation flag (keep the change) as I'm guessing this causes a problem for everyone using rust-analyzer, atleast in vscode. It doesn't cause too much of a difference in compiling.

Copy link
Member

Choose a reason for hiding this comment

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

I'd make this a separate PR even if it's one line, because @near/contract-runtime should have much better understanding why it is there

@shreyan-gupta shreyan-gupta added this pull request to the merge queue Sep 29, 2023
@shreyan-gupta shreyan-gupta removed this pull request from the merge queue due to a manual request Sep 29, 2023
@shreyan-gupta shreyan-gupta added this pull request to the merge queue Sep 29, 2023
Merged via the queue into master with commit e2f5fa5 Sep 29, 2023
@shreyan-gupta shreyan-gupta deleted the shreyan/refactor/client_test_utils branch September 29, 2023 19:49
nikurt pushed a commit that referenced this pull request Oct 2, 2023
Breaking a large test_utils.rs file into multiple parts.
Additionally shifting location of `TestEnvNightshadeSetupExt` to
nearcore so that it can be used in other modules, specifically
`tools/state-viewer/src/state_dump.rs`.

Note that we can't have `TestEnvNightshadeSetupExt` in
`chain/client/src/test_utils` as it depends on NightshadeRuntime which
is a part of `nearcore` module.

`nearcore` module depends on `chain` and would create a cyclic
dependency.
nikurt pushed a commit that referenced this pull request Oct 2, 2023
Breaking a large test_utils.rs file into multiple parts.
Additionally shifting location of `TestEnvNightshadeSetupExt` to
nearcore so that it can be used in other modules, specifically
`tools/state-viewer/src/state_dump.rs`.

Note that we can't have `TestEnvNightshadeSetupExt` in
`chain/client/src/test_utils` as it depends on NightshadeRuntime which
is a part of `nearcore` module.

`nearcore` module depends on `chain` and would create a cyclic
dependency.
nikurt pushed a commit that referenced this pull request Oct 2, 2023
Breaking a large test_utils.rs file into multiple parts.
Additionally shifting location of `TestEnvNightshadeSetupExt` to
nearcore so that it can be used in other modules, specifically
`tools/state-viewer/src/state_dump.rs`.

Note that we can't have `TestEnvNightshadeSetupExt` in
`chain/client/src/test_utils` as it depends on NightshadeRuntime which
is a part of `nearcore` module.

`nearcore` module depends on `chain` and would create a cyclic
dependency.
nikurt pushed a commit that referenced this pull request Oct 2, 2023
Breaking a large test_utils.rs file into multiple parts.
Additionally shifting location of `TestEnvNightshadeSetupExt` to
nearcore so that it can be used in other modules, specifically
`tools/state-viewer/src/state_dump.rs`.

Note that we can't have `TestEnvNightshadeSetupExt` in
`chain/client/src/test_utils` as it depends on NightshadeRuntime which
is a part of `nearcore` module.

`nearcore` module depends on `chain` and would create a cyclic
dependency.
nikurt pushed a commit that referenced this pull request Oct 11, 2023
Breaking a large test_utils.rs file into multiple parts.
Additionally shifting location of `TestEnvNightshadeSetupExt` to
nearcore so that it can be used in other modules, specifically
`tools/state-viewer/src/state_dump.rs`.

Note that we can't have `TestEnvNightshadeSetupExt` in
`chain/client/src/test_utils` as it depends on NightshadeRuntime which
is a part of `nearcore` module.

`nearcore` module depends on `chain` and would create a cyclic
dependency.
nikurt pushed a commit that referenced this pull request Oct 11, 2023
Breaking a large test_utils.rs file into multiple parts.
Additionally shifting location of `TestEnvNightshadeSetupExt` to
nearcore so that it can be used in other modules, specifically
`tools/state-viewer/src/state_dump.rs`.

Note that we can't have `TestEnvNightshadeSetupExt` in
`chain/client/src/test_utils` as it depends on NightshadeRuntime which
is a part of `nearcore` module.

`nearcore` module depends on `chain` and would create a cyclic
dependency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0