near / nearcore

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

refactor(resharding) - Make some tests compatible with arbitrary ShardIds #12468

Closed wacban closed 6 days ago

wacban commented 1 week ago

A bunch of tests have hardcoded ShardId::new(0). That doesn't work with arbitrary shard ids because there typically isn't a shard with shard id 0. This PR fixes a bunch of tests to get the shard id from the current shard layout rather than hardcoding it.

codecov[bot] commented 6 days ago

Codecov Report

Attention: Patch coverage is 93.49593% with 8 lines in your changes missing coverage. Please review.

Project coverage is 71.44%. Comparing base (fecce01) to head (04e68df). Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
chain/chain/src/runtime/tests.rs 80.48% 8 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #12468 +/- ## ======================================= Coverage 71.44% 71.44% ======================================= Files 838 838 Lines 169339 169363 +24 Branches 169339 169363 +24 ======================================= + Hits 120985 121003 +18 - Misses 43006 43010 +4 - Partials 5348 5350 +2 ``` | [Flag](https://app.codecov.io/gh/near/nearcore/pull/12468/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/12468/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `0.16% <0.00%> (ø)` | | | [db-migration](https://app.codecov.io/gh/near/nearcore/pull/12468/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `0.16% <0.00%> (ø)` | | | [genesis-check](https://app.codecov.io/gh/near/nearcore/pull/12468/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `1.29% <0.00%> (+<0.01%)` | :arrow_up: | | [integration-tests](https://app.codecov.io/gh/near/nearcore/pull/12468/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `39.31% <18.69%> (-0.04%)` | :arrow_down: | | [linux](https://app.codecov.io/gh/near/nearcore/pull/12468/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `70.78% <93.49%> (-0.01%)` | :arrow_down: | | [linux-nightly](https://app.codecov.io/gh/near/nearcore/pull/12468/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `71.00% <93.49%> (+<0.01%)` | :arrow_up: | | [macos](https://app.codecov.io/gh/near/nearcore/pull/12468/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `51.02% <93.16%> (+0.01%)` | :arrow_up: | | [pytests](https://app.codecov.io/gh/near/nearcore/pull/12468/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `1.60% <0.00%> (+<0.01%)` | :arrow_up: | | [sanity-checks](https://app.codecov.io/gh/near/nearcore/pull/12468/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `1.40% <0.00%> (+<0.01%)` | :arrow_up: | | [unittests](https://app.codecov.io/gh/near/nearcore/pull/12468/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `63.98% <93.16%> (+0.01%)` | :arrow_up: | | [upgradability](https://app.codecov.io/gh/near/nearcore/pull/12468/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `0.21% <0.00%> (+<0.01%)` | :arrow_up: | 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.