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

Field order is different in expected and actual JSON #27

Open
rkapka opened this issue May 14, 2021 · 0 comments
Open

Field order is different in expected and actual JSON #27

rkapka opened this issue May 14, 2021 · 0 comments

Comments

@rkapka
Copy link

rkapka commented May 14, 2021

Hey there!

I would really like to use your tool, but I encountered an issue with comparing output.

This is the result I get from /eth/v1/beacon/genesis:

{
    "data": {
        "genesis_time": "1606824023",
        "genesis_validators_root": "0x4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95",
        "genesis_fork_version": "0x00000000"
    }
}

This is my test:

{
  "method": "GET",
  "route": "/eth/v1/beacon/genesis",
  "expectedRespStatus": 200,
  "expectedRespBody": {
    "data": {
      "genesis_time": "1606824023",
      "genesis_validators_root": "0x4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95",
      "genesis_fork_version": "0x00000000"
    }
  }
}

This test fails

sRoot ./prysm --target http://localhost:4500
GET /eth/v1/beacon/genesis ❌
Expected response body:
{"data":{"genesis_fork_version":"0x00002009","genesis_time":"2020-11-18T12:00:07Z","genesis_validators_root":"0x9436e8a630e3162b7ed4f449b12b8a5a368a4b95bc46b941ae65c11613bfa4c1"}}

Received response body:
{"data":{"genesis_time":"1606824023","genesis_validators_root":"0x4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95","genesis_fork_version":"0x00000000"}}

It seems that only the expected JSON got canonicalized. I found information that struct field declaration order is preserved when marshalling into JSON, which may be the reason why field order is different between expected and actual.

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

No branches or pull requests

1 participant