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

Fixed info_get_status response parsing #132

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions rpc/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,14 +489,22 @@ type InfoGetStatusResult struct {
High uint64 `json:"high"`
} `json:"available_block_range"`
// Indicating the state of the block synchronizer component
BlockSync struct {
Historical string `json:"historical,omitempty"`
Forward string `json:"forward,omitempty"`
} `json:"block_sync"`
BlockSync BlockSynchronizerStatus `json:"block_sync"`

rawJSON json.RawMessage
}

type BlockSynchronizerStatus struct {
Historical *BlockSyncStatus `json:"historical,omitempty"`
Forward *BlockSyncStatus `json:"forward,omitempty"`
}

type BlockSyncStatus struct {
BlockHash key.Hash `json:"block_hash"`
BlockHeight *uint64 `json:"block_height,omitempty"`
AcquisitionState string `json:"acquisition_state"`
}

// NodeNextUpgrade contains the information about the next protocol upgrade.
type NodeNextUpgrade struct {
//The first era to which the associated protocol version applies.
Expand Down
14 changes: 11 additions & 3 deletions tests/data/rpc_response/get_status.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@
"high": 170022
},
"block_sync": {
"historical": null,
"forward": null
"historical": {
"block_hash": "16ddf28e2b3d2e17f4cef36f8b58827eca917af225d139b0c77df3b4a67dc55e",
"block_height": 40,
"acquisition_state": "have strict finality(40) for: block hash 16dd..c55e"
},
"forward": {
"block_hash": "59907b1e32a9158169c4d89d9ce5ac9164fc31240bfcfb0969227ece06d74983",
"block_height": 6701,
"acquisition_state": "have block body(6701) for: block hash 5990..4983"
}
},
"latest_switch_block_hash": "099cc3232b04ebb556c73328597c0b8c518fa4565c7d1f7981bc251414ce8c2f"
}
}
}
8 changes: 8 additions & 0 deletions tests/rpc/rpc_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,14 @@ func Test_DefaultClient_GetStatus(t *testing.T) {
require.NoError(t, err)
assert.NotEmpty(t, result.ChainSpecName)
assert.NotEmpty(t, result.LatestSwitchBlockHash)
assert.NotNil(t, result.BlockSync.Forward)
assert.NotEmpty(t, result.BlockSync.Forward.BlockHash)
assert.NotEmpty(t, result.BlockSync.Forward.AcquisitionState)
assert.NotNil(t, result.BlockSync.Forward.BlockHeight)
assert.NotNil(t, result.BlockSync.Historical)
assert.NotEmpty(t, result.BlockSync.Historical.BlockHash)
assert.NotEmpty(t, result.BlockSync.Historical.AcquisitionState)
assert.NotNil(t, result.BlockSync.Historical.BlockHeight)
}

func Test_DefaultClient_GetPeers(t *testing.T) {
Expand Down
Loading