Here's how we could avoid bugs like this in future:
We should add some unit tests that only work when this bug is fixed
This is hard to do rigth now in unit test because RelayList has controller has mandatory argument. [0]
I started to mock it to create a Relay instance, then realized that creating stem's RouterStatusEntryV3 and RelayDescriptor accept different formats for fingerprint and signing key, so have to do several conversions.
And leaving the raw data in bytes makes no difference for the V3BWFile tests.
We should work out how to check that our test bandwidth scanners are producing numbers that are the right size
Here are some things we might want to do. But they might not be worth the time:
all the variables should be labelled with units?
I started to do that in 514671ef and removed in 79693446 because i thought bs was not a clear name, but i could have named it bytes.
all the bandwidths in this file should be in the same units?
Do you mean in v3bwfile?, that's what i thought was the case :/
sbws should work in bytes, until it formats the file?
This sounds good. It was also my idea to do refactoring to separate the scaling logic from generating the text. Part of legacy/trac#28282 (moved)
[0] If descriptors are passed, it doesn't need the controller.
It has been my idea to change that as a refactor, but no need to wait for a big refactor, since it's enough to make that argument optional.
That would also allow having real cached-descriptors and cached-consensus for the unit tests.
I'll create a ticket for this.
Trac: Status: new to needs_review
By juga on 2019-03-09T13:06:47 (imported from GitLab project)
I opened legacy/trac#29712 (moved) to use 1024 to convert kilobytes to bytes.
but the difference between 1000 and 1024 is not very important, because bandwidth measurements are only 20-59% accurate anyway.
Trac: Status: needs_review to merge_ready
By teor on 2019-03-09T21:50:30 (imported from GitLab project)
Here's how we could avoid bugs like this in future:
We should add some unit tests that only work when this bug is fixed
This is hard to do rigth now in unit test because RelayList has controller has mandatory argument. [0]
I started to mock it to create a Relay instance, then realized that creating stem's RouterStatusEntryV3 and RelayDescriptor accept different formats for fingerprint and signing key, so have to do several conversions.