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

gcs: Overhaul tests and benchmarks. #1845

Merged
merged 1 commit into from
Aug 20, 2019
Merged

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Aug 20, 2019

This requires PRs #1843 and #1844.

This rewrites the tests to make them more consistent with the rest of the code base and significantly increases their coverage of the code.

It also reworks the benchmarks to actually benchmark what their names claim, renames them for consistency, and make them more stable by ensuring the same prng seed is used each run to eliminate variance introduced by different values.

Finally, it removes an impossible to hit condition from the bit reader and adds a couple of additional checks to harden the filters against potential misuse.

This is part of the ongoing process to cleanup and improve the gcs module to the quality level required by consensus code for ultimate inclusion in header commitments.

@davecgh davecgh added this to the 1.5.0 milestone Aug 20, 2019
@davecgh
Copy link
Member Author

davecgh commented Aug 20, 2019

$ go test -coverprofile=cov.out && go tool cover -func=cov.out
PASS
coverage: 93.8% of statements
ok      github.com/decred/dcrd/gcs/v2   0.422s
github.com/decred/dcrd/gcs/v2/bits.go:18:       writeOne                100.0%
github.com/decred/dcrd/gcs/v2/bits.go:31:       writeZero               100.0%
github.com/decred/dcrd/gcs/v2/bits.go:44:       writeNBits              95.7%
github.com/decred/dcrd/gcs/v2/bits.go:93:       newBitReader            100.0%
github.com/decred/dcrd/gcs/v2/bits.go:102:      readUnary               100.0%
github.com/decred/dcrd/gcs/v2/bits.go:126:      readNBits               97.1%
github.com/decred/dcrd/gcs/v2/gcs.go:43:        Len                     100.0%
github.com/decred/dcrd/gcs/v2/gcs.go:44:        Less                    100.0%
github.com/decred/dcrd/gcs/v2/gcs.go:45:        Swap                    100.0%
github.com/decred/dcrd/gcs/v2/gcs.go:64:        NewFilter               96.9%
github.com/decred/dcrd/gcs/v2/gcs.go:141:       FromBytes               100.0%
github.com/decred/dcrd/gcs/v2/gcs.go:163:       FromNBytes              100.0%
github.com/decred/dcrd/gcs/v2/gcs.go:182:       Bytes                   100.0%
github.com/decred/dcrd/gcs/v2/gcs.go:191:       NBytes                  100.0%
github.com/decred/dcrd/gcs/v2/gcs.go:197:       P                       100.0%
github.com/decred/dcrd/gcs/v2/gcs.go:202:       N                       100.0%
github.com/decred/dcrd/gcs/v2/gcs.go:208:       Match                   100.0%
github.com/decred/dcrd/gcs/v2/gcs.go:250:       MatchAny                100.0%
github.com/decred/dcrd/gcs/v2/gcs.go:314:       readFullUint64          85.7%
github.com/decred/dcrd/gcs/v2/gcs.go:330:       Hash                    100.0%
github.com/decred/dcrd/gcs/v2/gcs.go:346:       MakeHeaderForFilter     0.0%
total:                                          (statements)            93.8%

Note that no coverage was added for MakeHeaderForFilter because it will removed in upcoming commits.

gcs/gcs_test.go Outdated Show resolved Hide resolved
gcs/gcs_test.go Outdated Show resolved Hide resolved
gcs/gcs_test.go Outdated Show resolved Hide resolved
gcs/bench_test.go Outdated Show resolved Hide resolved
gcs/bench_test.go Outdated Show resolved Hide resolved
gcs/gcs_test.go Outdated Show resolved Hide resolved
This rewrites the tests to make them more consistent with the rest of
the code base and significantly increases their coverage of the code.

It also reworks the benchmarks to actually benchmark what their names
claim, renames them for consistency, and make them more stable by
ensuring the same prng seed is used each run to eliminate variance
introduced by different values.

Finally, it removes an impossible to hit condition from the bit reader
and adds a couple of additional checks to harden the filters against
potential misuse.

This is part of the ongoing process to cleanup and improve the gcs
module to the quality level required by consensus code for ultimate
inclusion in header commitments.
@davecgh davecgh merged commit 2a8856d into decred:master Aug 20, 2019
@davecgh davecgh deleted the gcs_rework_tests branch August 20, 2019 14:51
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