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

chore(tests/stress): refactor compareBlocksByNumber #2370

Merged
merged 1 commit into from
Mar 16, 2022

Conversation

qdm12
Copy link
Contributor

@qdm12 qdm12 commented Mar 11, 2022

Changes

First in a serie of tests/ refactor PRs
The end goal is to move timeouts responsibility to the test instead of hidden in helpers.

  • Takes in context
  • Retry as long as context is not canceled
  • Assert errors and common values

Tests

make it-stress

Issues

Primary Reviewer

  • Anyone it's just a single function changed.

@qdm12 qdm12 marked this pull request as ready for review March 14, 2022 14:38
Copy link
Member

@edwardmack edwardmack left a comment

Choose a reason for hiding this comment

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

Great work!

wg.Add(len(nodes))
func compareBlocksByNumber(ctx context.Context, t *testing.T, nodes []*utils.Node,
num string) (hashToKeys map[common.Hash][]string) {
type resultContainer struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
type resultContainer struct {
type result struct {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I rename to result govet complains about shadowing with the result-named variable below.
And I know I could rename that variable below from result to r, but that defeats my crusade against single letter variable names ⚔️ (except i for indexes). If you have a better name, feel free to say it 😄

Also that's an inlined type so it won't pollute the API so it's not a big deal either.

Comment on lines +121 to +122
const comparisonTimeout = 5 * time.Second
compareCtx, cancel := context.WithTimeout(ctx, comparisonTimeout)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const comparisonTimeout = 5 * time.Second
compareCtx, cancel := context.WithTimeout(ctx, comparisonTimeout)
const comparisonTimeout = 5 * time.Second
compareCtx, cancel := context.WithTimeout(ctx, 5 * time.Second)

why not inline?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I got tortured by gomnd for years... So now I constant most of my various 'constant' numbers.

- Takes in context
- Retry as long as context is not canceled
- Assert errors and common values
@codecov
Copy link

codecov bot commented Mar 16, 2022

Codecov Report

Merging #2370 (209ac73) into development (9c30149) will decrease coverage by 0.04%.
The diff coverage is n/a.

@@               Coverage Diff               @@
##           development    #2370      +/-   ##
===============================================
- Coverage        58.06%   58.01%   -0.05%     
===============================================
  Files              214      214              
  Lines            28007    28007              
===============================================
- Hits             16261    16247      -14     
- Misses           10111    10121      +10     
- Partials          1635     1639       +4     
Flag Coverage Δ
unit-tests 58.01% <ø> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
dot/network/inbound.go 92.98% <0.00%> (-7.02%) ⬇️
dot/telemetry/mailer.go 56.71% <0.00%> (-4.48%) ⬇️
dot/network/notifications.go 67.27% <0.00%> (-1.46%) ⬇️
lib/blocktree/blocktree.go 53.62% <0.00%> (-1.09%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9c30149...209ac73. Read the comment docs.

@qdm12 qdm12 merged commit 9b7f35a into development Mar 16, 2022
@qdm12 qdm12 deleted the qdm12/tests-refactor-1 branch March 16, 2022 12:49
rrtti pushed a commit to polkadot-fellows/seeding that referenced this pull request Sep 29, 2022
I am Quentin Mc Gaw, a software engineer working the Go Polkadot host **Gossamer**.
I have been working full time on Gossamer since October 2021, mostly on the state trie and storage.
I have also made a [few minor pull requests](https://github.com/w3f/polkadot-spec/pulls?q=is%3Apr+is%3Aclosed+author%3Aqdm12) to the Polkadot specification repository.

I am requesting to join the Fellowship at rank 1.

## Main contributions

### Gossamer

- Fix memory leaks
  - Trie encoding buffer pools usage fixed [#2009](ChainSafe/gossamer#2009)
  - Fix state map of tries memory leak [#2286](ChainSafe/gossamer#2286)
  - Fix sync benchmark [#2234](ChainSafe/gossamer#2234)
- Trie proof fixes ([#2604](ChainSafe/gossamer#2604), [#2661](ChainSafe/gossamer#2661))
- Fix end to end tests orchestration ([#2470](ChainSafe/gossamer#2470), [#2452](ChainSafe/gossamer#2452), [#2385](ChainSafe/gossamer#2385), [#2370](ChainSafe/gossamer#2370))
- State trie statistics ([#2378](ChainSafe/gossamer#2378), [#2310](ChainSafe/gossamer#2310), [#2272](ChainSafe/gossamer#2272))
- State trie fixes and improvements
  - Only deep copy nodes when mutation is certain [#2352](ChainSafe/gossamer#2352) and [#2223](ChainSafe/gossamer#2223)
  - Only deep copy necessary fields of a node [#2384](ChainSafe/gossamer#2384)
  - Use Merkle values for database keys instead of always hash [#2725](ChainSafe/gossamer#2725)
  - Opportunistic parallel Merkle value commputing [#2081](ChainSafe/gossamer#2081)
- Grandpa capped number of tracked messages ([#2490](ChainSafe/gossamer#2490), [#2485](ChainSafe/gossamer#2485))
- Add pprof HTTP service for profiling [#1991](ChainSafe/gossamer#1991)

Ongoing work:

- State trie lazy loading and caching
- State trie v1 support ([#2736](ChainSafe/gossamer#2736), [#2747](ChainSafe/gossamer#2747), [#2687](ChainSafe/gossamer#2687), [#2686](ChainSafe/gossamer#2686), [#2685](ChainSafe/gossamer#2685), [#2673](ChainSafe/gossamer#2673), [#2611](ChainSafe/gossamer#2611), [#2530](ChainSafe/gossamer#2530))

### Polkadot specification

➡️ [Pull requests from qdm12](https://github.com/w3f/polkadot-spec/pulls?q=is%3Apr+is%3Aclosed+author%3Aqdm12)
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.

4 participants