Fix isAuthorized task by changing a test that check for empty hex#926
Merged
Fix isAuthorized task by changing a test that check for empty hex#926
Conversation
krhubert
reviewed
Apr 30, 2019
| // get service from version hash | ||
| const sidHash = await contract.methods.versionHashToService(hashToHex(versionHash)).call() | ||
| if (hexToString(sidHash) === "") { | ||
| if (Number(sidHash) === 0) { |
Contributor
There was a problem hiding this comment.
what type sidHash is? what about Number overflow? are you 100% sure that there is not a signel sidHash that give 0 during the cast?
Member
Author
There was a problem hiding this comment.
I tried with multiple values and it worked correctly:
> Number('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff') === 0 ? "nok" : "ok"
'ok'
> Number('0x0000000000000000000000000000000000000000000000000000000000000001') === 0 ? "nok" : "ok"
'ok'
> Number('0x164475976c7f1b9abeee539b6fc35097c31148be1957c0746f30069b4ad022a4') === 0 ? "nok" : "ok"
'ok'
> Number('0x0000000000000000000000000000000000000000000000000000000000000000') === 0 ? "nok" : "ok"
'nok'
The function versionHashToService returns 0x0000000000000000000000000000000000000000000000000000000000000000 when the versionHash is not found.
krhubert
approved these changes
May 1, 2019
antho1404
approved these changes
May 1, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The function
hexToStringneeds a valid utf8 to not throw an error.It was used to test if the
sidHashwas empty or not. The sidHash is not an utf8 but a keccak.I replaced it by a conversion to number to make the same test.