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

Add JSON marshalling to Result #1627

Merged
merged 1 commit into from
Oct 3, 2024
Merged

Add JSON marshalling to Result #1627

merged 1 commit into from
Oct 3, 2024

Conversation

aaronbuchwald
Copy link
Collaborator

This PR adds JSON marshalling support for chain.Result to improve JSON output per #1606 (comment)

resultJSON, err := json.Marshal(result)
require.NoError(err)

expectedJSON := fmt.Sprintf(`{"error":%q,"fee":4,"outputs":[%q],"success":true,"units":%s}`, codec.Bytes(errStrBytes), codec.Bytes(outputBytes), string(unitsJSON))
Copy link
Contributor

Choose a reason for hiding this comment

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

(No action required) Maybe just round trip the Result type and compare the original and the unmarshaled values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd prefer to include the expectedJSON check as well to make sure it's clear that it's returning reasonable JSON output. THis makes it more explicit that we don't have any unexpected values like JSON keys that start with capital letters because there are no annotations.

Certainly may remove this at some point, but I think this is reasonable to include as we are cleaning up the JSON output.

@aaronbuchwald aaronbuchwald merged commit f1bcc59 into main Oct 3, 2024
17 checks passed
joshua-kim added a commit that referenced this pull request Oct 10, 2024
commit fee360f
Author: Tsachi Herman <[email protected]>
Date:   Fri Oct 4 11:23:58 2024 -0400

    refactor marshalActions implementation (#1631)

commit 2cb5530
Author: aaronbuchwald <[email protected]>
Date:   Thu Oct 3 18:49:12 2024 -0400

    Add block indexing to Indexer API (#1606)

commit f1bcc59
Author: aaronbuchwald <[email protected]>
Date:   Thu Oct 3 18:31:39 2024 -0400

    Add JSON marshalling to Result (#1627)

commit 2ea784a
Author: Richard Pringle <[email protected]>
Date:   Thu Oct 3 12:54:10 2024 -0400

    Implement multisig example (#1581)

commit 6bbf236
Author: Richard Pringle <[email protected]>
Date:   Thu Oct 3 12:43:41 2024 -0400

    Update codeowners (#1629)

commit 47849d8
Author: aaronbuchwald <[email protected]>
Date:   Thu Oct 3 08:34:51 2024 -0400

    Re-mark pubsub tests as flaky (#1625)

commit d847132
Author: aaronbuchwald <[email protected]>
Date:   Wed Oct 2 14:23:24 2024 -0400

    Reduce tests.unit.sh timeout value less than CI job (#1623)

commit 404e74f
Author: aaronbuchwald <[email protected]>
Date:   Wed Oct 2 14:07:04 2024 -0400

    Add JSON marshalling for fee dimensions (#1622)

commit 7e53003
Author: Joshua Kim <[email protected]>
Date:   Wed Oct 2 12:38:34 2024 -0400

    Replace usage of `internal/network` with `p2p` (#1613)

    Signed-off-by: Joshua Kim <[email protected]>

commit 79f363e
Author: containerman17 <[email protected]>
Date:   Wed Oct 2 11:53:59 2024 +0900

    Standardize decimals (#1620)

commit e191c88
Author: Joshua Kim <[email protected]>
Date:   Tue Oct 1 20:02:30 2024 -0400

    Update to [email protected] (#1614)

    Signed-off-by: Joshua Kim <[email protected]>

commit 59c84d7
Author: aaronbuchwald <[email protected]>
Date:   Tue Oct 1 17:19:17 2024 -0400

    Add ExecutedBlock type (#1601)

commit 165a455
Author: Tsachi Herman <[email protected]>
Date:   Tue Oct 1 09:26:32 2024 -0400

    validate buffer length prior to calling Uint64 (#1588)

commit c24f0d8
Author: rodrigo <[email protected]>
Date:   Tue Oct 1 09:25:18 2024 -0400

    Fix VM-With-Contracts Unit Tests (#1602)

commit 8ab9d83
Author: aaronbuchwald <[email protected]>
Date:   Mon Sep 30 16:57:29 2024 -0400

    Minor nits on pubsub implementation (#1593)

commit 592cd7a
Author: rodrigo <[email protected]>
Date:   Mon Sep 30 12:46:35 2024 -0400

    Remove `StateKeysMaxChunks()` (#1607)

commit 3e358c1
Author: aaronbuchwald <[email protected]>
Date:   Mon Sep 30 12:46:20 2024 -0400

    Update ActionBenchmark to use single ExpectedOutput (#1608)

commit e78841e
Author: Franfran <[email protected]>
Date:   Mon Sep 30 16:42:00 2024 +0200

    Write FIFO cache unit tests (#1201)

    * write FIFO cache unit tests

    * invert expected / actual

    * add limit parameter and cache fail on 0 size

    * simplify test table and create new test for empty cache

    * simpler tests by having a limit of 2

    * fix test cases

    * typos

    * backout uselesss change

    * add a "not an LRU" test case

    * use switch in fifo unit tests

commit f1150a1
Author: aaronbuchwald <[email protected]>
Date:   Fri Sep 27 17:46:28 2024 -0400

    Update tx indexer to include tx action outputs (#1597)

commit 6a3fd63
Author: Joshua Kim <[email protected]>
Date:   Thu Sep 26 15:44:56 2024 -0400

    Remove usage of mockgen (#1591)

    Signed-off-by: Joshua Kim <[email protected]>

commit 49376bd
Author: rodrigo <[email protected]>
Date:   Thu Sep 26 14:39:59 2024 -0400

    Fix benchmarks (#1590)

commit 77a73ba
Author: Richard Pringle <[email protected]>
Date:   Tue Sep 24 12:38:27 2024 -0400

    Ignore gas on mock-function-call (#1585)

commit 1bbab7b
Author: containerman17 <[email protected]>
Date:   Tue Sep 24 23:19:18 2024 +0900

    Remove special cases for Bytes, add arrays support (#1587)

commit 3410599
Author: aaronbuchwald <[email protected]>
Date:   Mon Sep 23 12:34:55 2024 -0400

    Add spam cmd to morpheus readme (#1577)

commit dfefd27
Author: aaronbuchwald <[email protected]>
Date:   Mon Sep 23 12:34:32 2024 -0400

    Improve chain comments (#1579)

commit 6c15244
Author: Richard Pringle <[email protected]>
Date:   Fri Sep 20 16:10:21 2024 -0400

    Series of changes that improve development (#1583)

commit e0a3324
Author: Richard Pringle <[email protected]>
Date:   Fri Sep 20 13:12:58 2024 -0400

    Use repr(packed) with state-keys (#1580)

commit 75c6cfd
Author: aaronbuchwald <[email protected]>
Date:   Thu Sep 19 07:58:39 2024 -0400

    Separate proposer monitor from vm into internal package (#1574)

Signed-off-by: Joshua Kim <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants