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(lib/trie): refactor and accelerate existing end to end tests #2211

Merged
merged 11 commits into from
Feb 7, 2022

Conversation

qdm12
Copy link
Contributor

@qdm12 qdm12 commented Jan 19, 2022

Changes

ℹ️ Essentially a bunch of our existing 'fuzzing-like' tests simplifications and make them faster (went from 2s to a few ms).
I'll change those to be proper fuzzing tests once Go 1.18 is stable in February, but these should not be run as unit tests if we leave them as slow as they were. Also a bit of helper tests code duplication to reduce API noise + remove package dependencies due to tests.

  • refactor some end to end tests
    • Test_Trie_PutAndGet writes failed trie key values to trie_putandget_failed_test_data_UNIXNANO.tsv (.gitignored)
    • TestEncodeRoot moved from node_test.go to trie_endtoend_test.go as Test_encodeRoot_fuzz
    • Always use the PRNG from math/rand seeded with time.Now().UnixNano() instead of the cryptographically secured source (because it's slow
    • TestFailingTests refactored to just re-run the the test with the data written to file as tsv.
    • Lowercase operation constant names
  • refactor test_utils.go
  • Move content of test_utils.go to helpers_test.go
  • Make end to end tests (aka fuzz tests) faster

Tests

go test -race ./internal/trie/... ./lib/trie/...

Issues

Primary Reviewer

@qdm12 qdm12 force-pushed the qdm12-trie-tests-3 branch 2 times, most recently from d8c996c to 09df55a Compare January 20, 2022 20:56
@qdm12 qdm12 marked this pull request as ready for review January 20, 2022 21:13
@qdm12 qdm12 force-pushed the qdm12-trie-tests-3 branch 2 times, most recently from bc04392 to bd28f5d Compare January 21, 2022 14:22
@codecov
Copy link

codecov bot commented Jan 21, 2022

Codecov Report

Merging #2211 (3a08b71) into development (a90a6e0) will increase coverage by 0.15%.
The diff coverage is 97.61%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #2211      +/-   ##
===============================================
+ Coverage        59.52%   59.68%   +0.15%     
===============================================
  Files              210      209       -1     
  Lines            27540    27522      -18     
===============================================
+ Hits             16394    16426      +32     
+ Misses            9447     9401      -46     
+ Partials          1699     1695       -4     
Flag Coverage Δ
unit-tests 59.68% <97.61%> (+0.15%) ⬆️

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

Impacted Files Coverage Δ
dot/sync/chain_sync.go 53.76% <50.00%> (+0.07%) ⬆️
dot/sync/benchmark.go 100.00% <100.00%> (+82.60%) ⬆️
internal/trie/node/branch.go 100.00% <100.00%> (ø)
internal/trie/node/copy.go 100.00% <100.00%> (ø)
internal/trie/node/decode.go 100.00% <100.00%> (ø)
internal/trie/node/hash.go 85.71% <100.00%> (ø)
internal/trie/node/leaf.go 100.00% <100.00%> (ø)
lib/trie/trie.go 96.30% <100.00%> (+5.47%) ⬆️
dot/network/inbound.go 92.85% <0.00%> (-7.15%) ⬇️
lib/blocktree/leaves.go 88.09% <0.00%> (-3.58%) ⬇️
... and 8 more

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 6fb057e...3a08b71. Read the comment docs.

@qdm12 qdm12 force-pushed the qdm12-trie-tests-2 branch 3 times, most recently from 6d9205c to 9c89821 Compare January 27, 2022 20:45
Base automatically changed from qdm12-trie-tests-2 to development January 27, 2022 21:37
@qdm12 qdm12 changed the title chore(lib/trie): refactor existing end to end tests chore(lib/trie): refactor and accelerate existing end to end tests Feb 7, 2022
@qdm12 qdm12 merged commit 133fd78 into development Feb 7, 2022
@qdm12 qdm12 deleted the qdm12-trie-tests-3 branch February 7, 2022 20:38
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.

3 participants