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

Fix isAuthorized task by changing a test that check for empty hex #926

Merged
merged 2 commits into from
May 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion systemservices/marketplace/src/tasks/isAuthorized.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default (
versionHash = inputs.versionHash
// get service from version hash
const sidHash = await contract.methods.versionHashToService(hashToHex(versionHash)).call()
if (hexToString(sidHash) === "") {
if (Number(sidHash) === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

throw new Error('service with hash ' + versionHash + ' does not exist')
}
const service = await contract.methods.services(sidHash).call()
Expand Down