Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Validate account logic schema - Closes #1210 #1244

Merged
merged 9 commits into from
Jan 15, 2018
Merged

Validate account logic schema - Closes #1210 #1244

merged 9 commits into from
Jan 15, 2018

Conversation

robladbrook
Copy link
Contributor

Closes #1210

I'm not sure if using anyOf introduces any side effects for any other areas of the code using model.filter? As far as I can tell it should be fine.

Note: there is a flakey test on test/unit/logic/account.js which I think was introduced as part of #1211
should throw error when a numeric field receives non numeric value

@LucasIsasmendi
Copy link
Contributor

Hi @robladbrook, thanks for your commits.
The way objectNormalize and schemas are been use in logic components is by defining an X.property.schema with properties and required fields and use it as second parameter when call library.schema.validate() inside of objectNormalize.
Also please note that we are not using es6 yet.

@robladbrook
Copy link
Contributor Author

@LucasIsasmendi understood. What changes would you like me to make given that the test currently passes?

@LucasIsasmendi
Copy link
Contributor

LucasIsasmendi commented Jan 11, 2018

Test pass, but is not align with what is being used in the rest of the code.
Instead of modify this.model, create Account.prototype.schema and use it for validations:

var report = this.scope.schema.validate(account, Account.prototype.schema);

Check Transaction.prototype.schema from logic/transaction.js as example

@robladbrook
Copy link
Contributor Author

@LucasIsasmendi do these changes align with what you were thinking?

Copy link
Contributor

@LucasIsasmendi LucasIsasmendi left a comment

Choose a reason for hiding this comment

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

Thanks @robladbrook, now this is aligned with all the others schema definitions. Some minor changes and it will be approved.

type: 'integer',
maximum: 32767
},
u_username: {
Copy link
Contributor

@LucasIsasmendi LucasIsasmendi Jan 12, 2018

Choose a reason for hiding this comment

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

username and u_username should have the same definition and be the same structure as in Delegate.prototype.schema

username: {
  type: 'string',
  format: 'username'
}

logic/account.js Outdated
maximum: 72
},
blockId: {
type: 'string',
Copy link
Contributor

@LucasIsasmendi LucasIsasmendi Jan 12, 2018

Choose a reason for hiding this comment

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

Add format: 'id'

logic/account.js Outdated
},
address: {
type: 'string',
case: 'upper',
Copy link
Contributor

@LucasIsasmendi LucasIsasmendi Jan 12, 2018

Choose a reason for hiding this comment

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

Replace case: 'upper' with format: 'address'

type: 'string',
format: 'publicKey'
},
secondPublicKey: {
Copy link
Contributor

Choose a reason for hiding this comment

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

secondPublicKey should be the same definition as publicKey

}
]
},
multisignatures: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Change related multisig fields to be same as Multisignature.prototype.schema

  • multisignatures, u_multisignatures is keygroup
  • multimin, u_ multimin is min
  • multilifetime, u_ multilifetime is lifetime

logic/account.js Outdated
maximum: 32767
},
fees: {
type: 'integer'
Copy link
Contributor

Choose a reason for hiding this comment

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

Add minimum: 0

logic/account.js Outdated
type: 'integer'
},
rewards: {
type: 'integer'
Copy link
Contributor

Choose a reason for hiding this comment

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

Add minimum: 0

@robladbrook
Copy link
Contributor Author

@LucasIsasmendi I've updated the schema, but the test now fails because the model now requires 1+ in the multisig fields.

Not sure if I should be updating the test model or allowing 0?

@LucasIsasmendi
Copy link
Contributor

@robladbrook please change all min values to 0 in schema definition multisig fields

@robladbrook
Copy link
Contributor Author

@LucasIsasmendi done!

@karmacoma karmacoma merged commit e9405c0 into LiskArchive:1.0.0 Jan 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants