Skip to content

Make honest Aeson Eq instance #7

@bladyjoker

Description

@bladyjoker

I'm having tests that rely on semantical equality of Json objects, however I'm having issues with Aeson

{"hash":"16574b0f9130f157ccb452cebc00faccfe411b932a2be4fe6e6069cb893d596e","plutusData":{"constr":0,"fields":[{"constr":0,"fields":["",""]},{"constr":0,"fields":["b8aa6f60b48ad4cb0f623edc96eb4dffb652b3a2384287b22c8814ac","5659464974"]},{"constr":0,"fields":["6304d06da03652264996015f08e6d2770ed9a0e57a105ea2c918f05c","56594649745f414441745f6e6674"]},995,7670125982969789,1e+17,"184ff44840c8c0ad71d39e356511660f84e321915bbf76d90bd1969f",{"constr":0,"fields":["6d620e702133d0d4f2273246a36f895b0015c4d385c7cab1aa7c02fd"]},15000000,26075191]}}



{"hash":"16574b0f9130f157ccb452cebc00faccfe411b932a2be4fe6e6069cb893d596e","plutusData":{"constr":0,"fields":[{"constr":0,"fields":["",""]},{"constr":0,"fields":["b8aa6f60b48ad4cb0f623edc96eb4dffb652b3a2384287b22c8814ac","5659464974"]},{"constr":0,"fields":["6304d06da03652264996015f08e6d2770ed9a0e57a105ea2c918f05c","56594649745f414441745f6e6674"]},995,7670125982969789,100000000000000000,"184ff44840c8c0ad71d39e356511660f84e321915bbf76d90bd1969f",{"constr":0,"fields":["6d620e702133d0d4f2273246a36f895b0015c4d385c7cab1aa7c02fd"]},15000000,26075191]}}

Seems like upon reading into Aeons we the BigInt stringified as 1e+17 and then when writing to Aeson we get 100000000000000000.

Since Aeson implements the Eq instance using a stringified form of Json, for semantically the same Json objects we get 2 different textual representations (see above). Let's rather make this right and implement a proper equality instance that captures the semantics of what it means for 2 Json objects to be the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions