near / nearcore

Reference client for NEAR Protocol
https://near.org
GNU General Public License v3.0
2.32k stars 623 forks source link

feat: Add view client actor to test loop #11830

Closed tayfunelmas closed 3 months ago

tayfunelmas commented 3 months ago

We introduce ViewClientActorInner to testloop environment. For this we add a field to TestData to contain the view client actor and initialize it in the TestLoopBuilder. The new view client field allows to send messages via ViewClientSenderForRpc. These messages are used when answering to JSON-RPC methods via the view client.

The goal is to be able to issue RPC requests to the view client and write tests to exercise RPC methods that are executed through the view client. Such tests are left for upcoming PRs. Instead, to demonstrate that the view client works, we change multinode_stateless_validators.rs to call GetValidatorInfo on view client instead of read the validator info directly from the internal epoch manager.

This task is part of #11827, where we want to write testloop tests that run the chain and then call certain RPC methods (here instead of HTTP interface, the methods will be invoked directly through the ViewClient since we want to exercise the implementation of the RPC methods, instead of the HTTP/RPC layer).

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 93.22034% with 4 lines in your changes missing coverage. Please review.

Project coverage is 71.82%. Comparing base (f29029a) to head (7621d81).

Files Patch % Lines
integration-tests/src/test_loop/env.rs 0.00% 3 Missing :warning:
chain/client/src/view_client_actor.rs 97.50% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #11830 +/- ## ========================================== + Coverage 71.81% 71.82% +0.01% ========================================== Files 796 796 Lines 163231 163270 +39 Branches 163231 163270 +39 ========================================== + Hits 117224 117274 +50 + Misses 40959 40950 -9 + Partials 5048 5046 -2 ``` | [Flag](https://app.codecov.io/gh/near/nearcore/pull/11830/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | Coverage Δ | | |---|---|---| | [backward-compatibility](https://app.codecov.io/gh/near/nearcore/pull/11830/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `0.23% <0.00%> (-0.01%)` | :arrow_down: | | [db-migration](https://app.codecov.io/gh/near/nearcore/pull/11830/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `0.23% <0.00%> (-0.01%)` | :arrow_down: | | [genesis-check](https://app.codecov.io/gh/near/nearcore/pull/11830/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `1.35% <0.00%> (-0.01%)` | :arrow_down: | | [integration-tests](https://app.codecov.io/gh/near/nearcore/pull/11830/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `37.82% <93.22%> (+0.01%)` | :arrow_up: | | [linux](https://app.codecov.io/gh/near/nearcore/pull/11830/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `71.57% <93.22%> (-0.01%)` | :arrow_down: | | [linux-nightly](https://app.codecov.io/gh/near/nearcore/pull/11830/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `71.41% <93.22%> (+0.01%)` | :arrow_up: | | [macos](https://app.codecov.io/gh/near/nearcore/pull/11830/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `54.71% <97.50%> (+<0.01%)` | :arrow_up: | | [pytests](https://app.codecov.io/gh/near/nearcore/pull/11830/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `1.62% <0.00%> (-0.01%)` | :arrow_down: | | [sanity-checks](https://app.codecov.io/gh/near/nearcore/pull/11830/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `1.42% <0.00%> (-0.01%)` | :arrow_down: | | [unittests](https://app.codecov.io/gh/near/nearcore/pull/11830/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `66.27% <97.50%> (+<0.01%)` | :arrow_up: | | [upgradability](https://app.codecov.io/gh/near/nearcore/pull/11830/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `0.28% <0.00%> (-0.01%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.