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

Increase test coverage of accounting and improve some test packages #590

Merged
merged 7 commits into from
Jul 5, 2024

Conversation

cthulhu-rider
Copy link
Contributor

No description provided.

It teaches what a regular user should be freed from.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
require.NoError(tb, err)
// Signature returns random neofscrypto.Signature.
func Signature() neofscrypto.Signature {
sig := make([]byte, 64)
Copy link
Contributor

Choose a reason for hiding this comment

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

It was a question which I forget to ask many time. Do we want to move such magic numbers inside packages they are belongs to? I mean this 64 to neofscrypto.SignatureBytesLength for example.

Another example of magic numbers, this 33 would be perfect to has a public const, because in the code in projects we have a lot of pubKey = make([]byte, 33)
pubKey = make([]byte, ecdsa.PublicKeyLength) looks much better for me.

Yes, in some cases it could be inconvenient to export one more package, but in general case it would ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

code should not do pubKey = make([]byte, 33): https://pkg.go.dev/github.com/nspcc-dev/neofs-sdk-go@v1.0.0-rc.12/crypto#PublicKey has method to get len

actually i dont wanna make it const, forgot to add some randomness, thx anyway

accounting/decimal.go Outdated Show resolved Hide resolved
accounting/decimal_test.go Show resolved Hide resolved
audit/example_test.go Show resolved Hide resolved
audit/result.go Outdated
err = oID.ReadFromV2(oidV2)
if err != nil {
return fmt.Errorf("invalid passed storage group ID: %w", err)
return fmt.Errorf("invalid passed storage group ID #%d: %w", i, err)
Copy link
Member

Choose a reason for hiding this comment

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

we have an exact ID we could not read here, why not add it? same below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cuz it can be few MB len. We could make a cut for overlen values abc...def but code'd become more complex

container/id/test/id.go Outdated Show resolved Hide resolved
Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

I should admit though that audit is less of a problem wrt API changes (nothing outside the node cares).

accounting/decimal.go Outdated Show resolved Hide resolved
audit/example_test.go Show resolved Hide resolved
audit/result.go Outdated
// SetCompleted sets data audit completion flag.
//
// See also [Result.Completed].
func (r *Result) SetCompleted(completed bool) {
Copy link
Member

Choose a reason for hiding this comment

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

Do you have any use case for SetCompleted(false)? Why are we changing the API here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no more relevant #590 (comment)

- split units tests for value and precision fields
- add test for randomizing func

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
Data audit is completely closed in the NeoFS Inner Ring, so there is no
point in having its implementation in the SDK.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
@carpawell
Copy link
Member

@cthulhu-rider, linter died. What about tests btw?

This is very inconvenient. The only current failure cases are private
key randomization or signing with it: panic is pretty normal for them.
Overall, nobody expects that generating in-memory data could fail.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
It is often needed to get another ID, as well as a list of random ones.
With new functions, `cidtest.IDWithChecksum` becomes redundant, so it
marked as deprecated.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
Summary:
 * get rid of `Random` wording, it is implied everywhere;
 * provide single `Signer` function returning all potentially needed
   cryptographic components;
 * do not import `user` package into `neofscryptotest`, there is
   `usertest` for this;
 * provide test signer's wrapper which always failing signing.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
@cthulhu-rider
Copy link
Contributor Author

@cthulhu-rider, linter died. What about tests btw?

fixed linter, AIO tests fail for some reason unrelated to the changes. I'll take a closer look, maybe create a separate issue

@cthulhu-rider cthulhu-rider changed the title Increase test coverage of accounting+audit and improve some test packages Increase test coverage of accounting and improve some test packages Jul 4, 2024
@carpawell
Copy link
Member

AIO tests fail for some reason unrelated to the changes. I'll take a closer look, maybe create a separate issue

@cthulhu-rider, yes, have not found issues about it and do not know when they appeared first (to me this PR is the first one), so lets create an issue (if cannot be fixed fast) or fix it here (if possible).

ENV var containing listen endpoint of the REST GW differs b/w two tested
versions. The easiest way is to set both.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
Copy link

codecov bot commented Jul 4, 2024

Codecov Report

Attention: Patch coverage is 73.01587% with 34 lines in your changes missing coverage. Please review.

Project coverage is 68.78%. Comparing base (11ca22b) to head (b069242).
Report is 5 commits behind head on master.

Files Patch % Lines
user/test/id.go 75.00% 9 Missing and 1 partial ⚠️
eacl/test/generate.go 0.00% 5 Missing ⚠️
object/id/test/generate.go 86.20% 2 Missing and 2 partials ⚠️
bearer/test/generate.go 0.00% 3 Missing ⚠️
crypto/test/tests.go 85.71% 2 Missing and 1 partial ⚠️
reputation/test/generate.go 0.00% 3 Missing ⚠️
container/id/test/id.go 87.50% 1 Missing and 1 partial ⚠️
container/test/generate.go 0.00% 2 Missing ⚠️
object/test/generate.go 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #590      +/-   ##
==========================================
+ Coverage   68.18%   68.78%   +0.60%     
==========================================
  Files         122      120       -2     
  Lines       10035    10043       +8     
==========================================
+ Hits         6842     6908      +66     
+ Misses       2814     2759      -55     
+ Partials      379      376       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cthulhu-rider
Copy link
Contributor Author

AIO tests fail for some reason unrelated to the changes. I'll take a closer look, maybe create a separate issue

@cthulhu-rider, yes, have not found issues about it and do not know when they appeared first (to me this PR is the first one), so lets create an issue (if cannot be fixed fast) or fix it here (if possible).

added fix commit

@carpawell carpawell merged commit 6d3ce31 into master Jul 5, 2024
12 checks passed
@carpawell carpawell deleted the accounting branch July 5, 2024 10:30
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