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

[Merged by Bors] - Fix misleading error #4725

Closed
wants to merge 4 commits into from
Closed

Conversation

poszu
Copy link
Contributor

@poszu poszu commented Jul 19, 2023

Motivation

Users often get confused by the log message when the nipost_challenge.bin doesn't exist. This is a normal situation, yet the log includes "errormsg".

Changes

Don't log an error in case the file is not found.

Additionally, includes a fix for a bug discovered during testing. The code panicked when the file was too small (for example empty).

Test Plan

  • UT
  • manual test

@codecov
Copy link

codecov bot commented Jul 19, 2023

Codecov Report

Merging #4725 (5e22282) into develop (c418ee5) will decrease coverage by 0.3%.
The diff coverage is 100.0%.

@@            Coverage Diff            @@
##           develop   #4725     +/-   ##
=========================================
- Coverage     77.2%   76.9%   -0.3%     
=========================================
  Files          255     255             
  Lines        28805   28844     +39     
=========================================
- Hits         22246   22197     -49     
- Misses        5171    5261     +90     
+ Partials      1388    1386      -2     
Impacted Files Coverage Δ
activation/activation.go 77.5% <100.0%> (-0.3%) ⬇️
activation/nipost_state.go 58.7% <100.0%> (+1.1%) ⬆️

... and 15 files with indirect coverage changes

Comment on lines +66 to 71
}, {
name: "file empty",
data: []byte(""),
crc: []byte{0xC6, 0x10, 0x72, 0xDF, 0x52, 0xD7, 0x74, 0x0E},
errMsg: "wrong checksum 0xC61072DF52D7740E, computed 0x0",
},
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused by this test. The CRC64 of an empty file should be 0x0000000000000000 and if the file only contains those bytes it will pass reading & CRC validation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is confusing? It's exactly as you said. CRC of nothing is 0. The test file contains a wrong CRC and no data hence it should fail with "wrong checksum 0xC61072DF52D7740E, computed 0x0" message.

Copy link
Member

Choose a reason for hiding this comment

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

but isn't this just a repetition of the "badCRC" testcase?

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, it's an edge case when the input is empty.

Copy link
Member

Choose a reason for hiding this comment

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

Again back to my first comment: an empty input is not an error, it has a valid checksum. This test does not check if empty input is handled correctly (that would be "" and 0x0), it checks if a wrong checksum is detected (as does the "badCRC" testcase)

activation/activation.go Outdated Show resolved Hide resolved
@poszu
Copy link
Contributor Author

poszu commented Jul 19, 2023

bors merge

bors bot pushed a commit that referenced this pull request Jul 19, 2023
## Motivation
Users often get confused by the log message when the nipost_challenge.bin doesn't exist. This is a normal situation, yet the log includes "errormsg".

## Changes
Don't log an error in case the file is not found.

Additionally, includes a fix for a bug discovered during testing. The code panicked when the file was too small (for example empty).

## Test Plan
- UT
- [x] manual test
@bors
Copy link

bors bot commented Jul 19, 2023

Build failed:

@poszu
Copy link
Contributor Author

poszu commented Jul 19, 2023

bors merge

bors bot pushed a commit that referenced this pull request Jul 19, 2023
## Motivation
Users often get confused by the log message when the nipost_challenge.bin doesn't exist. This is a normal situation, yet the log includes "errormsg".

## Changes
Don't log an error in case the file is not found.

Additionally, includes a fix for a bug discovered during testing. The code panicked when the file was too small (for example empty).

## Test Plan
- UT
- [x] manual test
@bors
Copy link

bors bot commented Jul 19, 2023

Build failed:

@poszu
Copy link
Contributor Author

poszu commented Jul 19, 2023

flake in TestNodesUsingDifferentPoets, unrelated to this change.

bors merge

bors bot pushed a commit that referenced this pull request Jul 19, 2023
## Motivation
Users often get confused by the log message when the nipost_challenge.bin doesn't exist. This is a normal situation, yet the log includes "errormsg".

## Changes
Don't log an error in case the file is not found.

Additionally, includes a fix for a bug discovered during testing. The code panicked when the file was too small (for example empty).

## Test Plan
- UT
- [x] manual test
@bors
Copy link

bors bot commented Jul 19, 2023

Build failed:

@poszu
Copy link
Contributor Author

poszu commented Jul 19, 2023

bors merge

bors bot pushed a commit that referenced this pull request Jul 19, 2023
## Motivation
Users often get confused by the log message when the nipost_challenge.bin doesn't exist. This is a normal situation, yet the log includes "errormsg".

## Changes
Don't log an error in case the file is not found.

Additionally, includes a fix for a bug discovered during testing. The code panicked when the file was too small (for example empty).

## Test Plan
- UT
- [x] manual test
@bors
Copy link

bors bot commented Jul 19, 2023

Pull request successfully merged into develop.

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot changed the title Fix misleading error [Merged by Bors] - Fix misleading error Jul 19, 2023
@bors bors bot closed this Jul 19, 2023
@bors bors bot deleted the fix-misleading-error branch July 19, 2023 13:40
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.

None yet

3 participants