Write unit tests for all the encodings defined in SCORU in JSON and binary mode
let player_encoding =
let open Data_encoding in
union
~tag_size:`Uint8
[
case
~title:"Alice"
(Tag 0)
unit
(function Alice -> Some () | _ -> None)
(fun () -> Alice);
case
~title:"Bob"
(Tag 1)
unit
(function Bob -> Some () | _ -> None)
(fun () -> Bob);
]
is not a valid encoding when used in JSON but
let player_encoding =
let open Data_encoding in
union
~tag_size:`Uint8
[
case
~title:"Alice"
(Tag 0)
(constant "alice")
(function Alice -> Some () | _ -> None)
(fun () -> Alice);
case
~title:"Bob"
(Tag 1)
(constant "bob")
(function Bob -> Some () | _ -> None)
(fun () -> Bob);
]
is.
I spent 1h30 debugging the rollup node logic because of that issue: Alice was returned instead of Bob through the RPC from the Tezos node to the rollup node and then the rollup node was acting badly.
Given how critical the communication between the Tezos node and the rollup node is, we better make sure that all our encodings are compatible with JSON.
Thanks to @lthms that have shown me the bug in the data encoding of the player encoding.
@raphael-proust Could we add a well-formedness check to prevent this situation?
Edited by Yann Regis-Gianas