Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.
This repository was archived by the owner on May 14, 2025. It is now read-only.

Fix serialization issues for Forest RPC untagged enums. #58

Description

@elmattic

Reproduce by using #57 and uncomment one of the EthGetBalance tests:

cargo run -q --bin cna-test-suite run src/test-suite/config.json.ignoreme
0	ChainHead with no authorization token	passed
1	EthAccounts with no authorization token	passed
2	EthAddressToFilecoinAddress with no authorization token	passed
3	EthBlockNumber with no authorization token	passed
4	EthChainId with no authorization token	passed
5	EthGasPrice with no authorization token	passed
6	EthGetBalance with no authorization token and subtype_2	failed
	0	err
	couldn't serialize params
	can only flatten structs and maps (got a string)
	1	src/test-suite/src/tests.rs:158:9
7	EthGetBalance with no authorization token and subtype_3	passed
8	EthGetBalance with no authorization token and subtype_4	passed
9	EthNewBlockFilter with no authorization token	passed
10	EthNewPendingTransactionFilter with no authorization token	passed
11	EthProtocolVersion with no authorization token	passed
12	EthSyncing with no authorization token	passed
failure 0 (EthGetBalance with no authorization token and subtype_2)
	0	err
	couldn't serialize params
	can only flatten structs and maps (got a string)
	1	src/test-suite/src/tests.rs:158:9
0 skipped, 12 succeeded, 1 failed

Activity

  1. elmattic commented on Oct 30, 2024

    @elmattic
    ContributorAuthor

    Maybe one approach would be to guide code generation to use an enum:

    So instead of having:

    #[derive(Clone, Debug, Deserialize, Serialize)]
    pub struct BlockNumberOrHash {
        #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
        pub subtype_0: Option<String>,
        ...
    }
    

    We would like:

    #[derive(Clone, Debug, Deserialize, Serialize)]
    #[serde(untagged)]
    pub enum BlockNumberOrHash {
        Subtype0(String),
        ...
    }
    
  2. moved this from New to In progress in Forest Backlog 🌲on Oct 30, 2024
  3. self-assigned this
    on Oct 30, 2024
  4. elmattic commented on Dec 5, 2024

    @elmattic
    ContributorAuthor

    update: I've created an issue on the typify repository to ask if there's an easy workaround.

  5. moved this from In progress to Ready in Forest Backlog 🌲on Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions