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

Improve lisk-codec protocol specs to be more deterministic #6589

Closed
Tracked by #6653
nazarhussain opened this issue Jul 19, 2021 · 0 comments · Fixed by #6650
Closed
Tracked by #6653

Improve lisk-codec protocol specs to be more deterministic #6589

nazarhussain opened this issue Jul 19, 2021 · 0 comments · Fixed by #6650

Comments

@nazarhussain
Copy link
Contributor

Description

The protocol specs of any component in the system must be deterministic, means input and output must defined explicitly for every case. And there must not be any modifications/mutations to output/input runtime to pass the tests.

Currently we have protocol specs for lisk-codec encoding behaviour, but we don't have it for decoding behaviour. And as per our implementation of lisk-codec and by specification of the LIP the encoding and decoding may not turn out be same as always. e.g. Its a viable chance that in example below data and reverseData may not match strictly because of the default values for properties which are not defined in the data object.

const data = {a: 1, b: 2}
const binary = codec.encode(schema, data);
const reverseData = codec.decode(schema, binary);

To cover this part we had a lot of custom manipulation of protocol specs in test suites, which does not fulfil the purpose of having protocol specs. e.g. few of reference mentioned below. We need to improve these and protocol specs must define the decoding specs and we should avoid runtime mutation of specs input/output in our tests

https://github.com/LiskHQ/lisk-sdk/blob/2db69cdd52b2ea8461525a34c388619921481c64/elements/lisk-codec/test/decode.spec.ts#L67-L71

https://github.com/LiskHQ/lisk-sdk/blob/2db69cdd52b2ea8461525a34c388619921481c64/elements/lisk-codec/test/decode.spec.ts#L113-L117

https://github.com/LiskHQ/lisk-sdk/blob/2db69cdd52b2ea8461525a34c388619921481c64/elements/lisk-codec/test/decode.spec.ts#L161-L167

Motivation

The protocol specs for Lisk-Codec must deterministic and cover both encoding and decoding behaviours.

Additional Information

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants