Skip to content

Commit

Permalink
status tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CreatureDev committed May 17, 2023
1 parent 7116704 commit fbf1f22
Show file tree
Hide file tree
Showing 5 changed files with 318 additions and 12 deletions.
7 changes: 6 additions & 1 deletion model/client/admin/status/consensus_info_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ type ConsensusInfo struct {
LedgerSeq common.LedgerIndex `json:"ledger_seq,omitempty"`
OurPosition Position `json:"our_position"`
PeerPositions map[string]Position `json:"peer_positions,omitempty"`
PreviousMseconds uint `json:"previous_mseconds,omitempty"`
PreviousProposers int `json:"previous_proposers,omitempty"`
Proposers int `json:"proposers,omitempty"`
Proposing bool `json:"proposing,omitempty"`
State string `json:"state,omitempty"`
Synched bool `json:"synched,omitempty"`
Validating bool `json:"validating,omitempty"`
}

type Position struct {
CloseTime uint `json:"close_time"`
PeerId string `json:"peer_id"`
PeerId string `json:"peer_id,omitempty"`
PreviousLedger common.LedgerHash `json:"previous_ledger"`
ProposeSeq int `json:"propose_seq"`
TransactionHash string `json:"transaction_hash"`
Expand Down
145 changes: 145 additions & 0 deletions model/client/admin/status/consensus_info_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
package status

import (
"testing"

"github.com/xyield/xrpl-go/test"
)

func TestConsensusInfoResponse(t *testing.T) {
s := ConsensusInfoResponse{
Info: ConsensusInfo{
Acquired: map[string]string{
"4BC2CE596CBD1321775320E2067F9C06D3862826212C16EF42ABB6A2B0414306": "acquired",
},
CloseGranularity: 10,
ClosePercent: 50,
CloseResolution: 10,
CloseTimes: map[string]int{
"486082972": 1,
"486082973": 4,
},
CurrentMs: 1003,
HaveTimeConsensus: false,
LedgerSeq: 13701086,
OurPosition: Position{
CloseTime: 486082973,
PreviousLedger: "0BB01379B51234BAAF501A71C7AB147F595460B689BB9E8252A0B87B5A483623",
ProposeSeq: 0,
TransactionHash: "4BC2CE596CBD1321775320E2067F9C06D3862826212C16EF42ABB6A2B0414306",
},
PeerPositions: map[string]Position{
"0A2EAF919033A036D363D4E5610A66209DDBE8EE": {
CloseTime: 486082972,
PeerId: "n9KiYM9CgngLvtRCQHZwgC2gjpdaZcCcbt3VboxiNFcKuwFVujzS",
PreviousLedger: "0BB01379B51234BAAF501A71C7AB147F595460B689BB9E8252A0B87B5A483623",
ProposeSeq: 0,
TransactionHash: "4BC2CE596CBD1321775320E2067F9C06D3862826212C16EF42ABB6A2B0414306",
},
"1567A8C953A86F8428C7B01641D79BBF2FD508F3": {
CloseTime: 486082973,
PeerId: "n9LdgEtkmGB9E2h3K4Vp7iGUaKuq23Zr32ehxiU8FWY7xoxbWTSA",
PreviousLedger: "0BB01379B51234BAAF501A71C7AB147F595460B689BB9E8252A0B87B5A483623",
ProposeSeq: 0,
TransactionHash: "4BC2CE596CBD1321775320E2067F9C06D3862826212C16EF42ABB6A2B0414306",
},
"202397A81F20B44CF44EA99AF761295E5A8397D2": {
CloseTime: 486082973,
PeerId: "n9MD5h24qrQqiyBC8aeqqCWvpiBiYQ3jxSr91uiDvmrkyHRdYLUj",
PreviousLedger: "0BB01379B51234BAAF501A71C7AB147F595460B689BB9E8252A0B87B5A483623",
ProposeSeq: 0,
TransactionHash: "4BC2CE596CBD1321775320E2067F9C06D3862826212C16EF42ABB6A2B0414306",
},
"5C29005CF4FB479FC49EEFB4A5B075C86DD963CC": {
CloseTime: 486082973,
PeerId: "n9L81uNCaPgtUJfaHh89gmdvXKAmSt5Gdsw2g1iPWaPkAHW5Nm4C",
PreviousLedger: "0BB01379B51234BAAF501A71C7AB147F595460B689BB9E8252A0B87B5A483623",
ProposeSeq: 0,
TransactionHash: "4BC2CE596CBD1321775320E2067F9C06D3862826212C16EF42ABB6A2B0414306",
},
"EFC49EB648E557CC50A72D715249B80E071F7705": {
CloseTime: 486082973,
PeerId: "n949f75evCHwgyP4fPVgaHqNHxUVN15PsJEZ3B3HnXPcPjcZAoy7",
PreviousLedger: "0BB01379B51234BAAF501A71C7AB147F595460B689BB9E8252A0B87B5A483623",
ProposeSeq: 0,
TransactionHash: "4BC2CE596CBD1321775320E2067F9C06D3862826212C16EF42ABB6A2B0414306",
},
},
PreviousMseconds: 2005,
PreviousProposers: 5,
Proposers: 5,
State: "consensus",
Synched: true,
},
}

j := `{
"info": {
"acquired": {
"4BC2CE596CBD1321775320E2067F9C06D3862826212C16EF42ABB6A2B0414306": "acquired"
},
"close_granularity": 10,
"close_percent": 50,
"close_resolution": 10,
"close_times": {
"486082972": 1,
"486082973": 4
},
"current_ms": 1003,
"have_time_consensus": false,
"ledger_seq": 13701086,
"our_position": {
"close_time": 486082973,
"previous_ledger": "0BB01379B51234BAAF501A71C7AB147F595460B689BB9E8252A0B87B5A483623",
"propose_seq": 0,
"transaction_hash": "4BC2CE596CBD1321775320E2067F9C06D3862826212C16EF42ABB6A2B0414306"
},
"peer_positions": {
"0A2EAF919033A036D363D4E5610A66209DDBE8EE": {
"close_time": 486082972,
"peer_id": "n9KiYM9CgngLvtRCQHZwgC2gjpdaZcCcbt3VboxiNFcKuwFVujzS",
"previous_ledger": "0BB01379B51234BAAF501A71C7AB147F595460B689BB9E8252A0B87B5A483623",
"propose_seq": 0,
"transaction_hash": "4BC2CE596CBD1321775320E2067F9C06D3862826212C16EF42ABB6A2B0414306"
},
"1567A8C953A86F8428C7B01641D79BBF2FD508F3": {
"close_time": 486082973,
"peer_id": "n9LdgEtkmGB9E2h3K4Vp7iGUaKuq23Zr32ehxiU8FWY7xoxbWTSA",
"previous_ledger": "0BB01379B51234BAAF501A71C7AB147F595460B689BB9E8252A0B87B5A483623",
"propose_seq": 0,
"transaction_hash": "4BC2CE596CBD1321775320E2067F9C06D3862826212C16EF42ABB6A2B0414306"
},
"202397A81F20B44CF44EA99AF761295E5A8397D2": {
"close_time": 486082973,
"peer_id": "n9MD5h24qrQqiyBC8aeqqCWvpiBiYQ3jxSr91uiDvmrkyHRdYLUj",
"previous_ledger": "0BB01379B51234BAAF501A71C7AB147F595460B689BB9E8252A0B87B5A483623",
"propose_seq": 0,
"transaction_hash": "4BC2CE596CBD1321775320E2067F9C06D3862826212C16EF42ABB6A2B0414306"
},
"5C29005CF4FB479FC49EEFB4A5B075C86DD963CC": {
"close_time": 486082973,
"peer_id": "n9L81uNCaPgtUJfaHh89gmdvXKAmSt5Gdsw2g1iPWaPkAHW5Nm4C",
"previous_ledger": "0BB01379B51234BAAF501A71C7AB147F595460B689BB9E8252A0B87B5A483623",
"propose_seq": 0,
"transaction_hash": "4BC2CE596CBD1321775320E2067F9C06D3862826212C16EF42ABB6A2B0414306"
},
"EFC49EB648E557CC50A72D715249B80E071F7705": {
"close_time": 486082973,
"peer_id": "n949f75evCHwgyP4fPVgaHqNHxUVN15PsJEZ3B3HnXPcPjcZAoy7",
"previous_ledger": "0BB01379B51234BAAF501A71C7AB147F595460B689BB9E8252A0B87B5A483623",
"propose_seq": 0,
"transaction_hash": "4BC2CE596CBD1321775320E2067F9C06D3862826212C16EF42ABB6A2B0414306"
}
},
"previous_mseconds": 2005,
"previous_proposers": 5,
"proposers": 5,
"state": "consensus",
"synched": true
}
}`

if err := test.SerializeAndDeserialize(t, s, j); err != nil {
t.Error(err)
}
}
83 changes: 83 additions & 0 deletions model/client/admin/status/feature_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package status

import (
"testing"

"github.com/xyield/xrpl-go/test"
)

func TestFeatureResponse(t *testing.T) {
s := FeatureResponse{
Features: map[string]Feature{
"42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE": {
Enabled: false,
Name: "FeeEscalation",
Supported: true,
Vetoed: false,
},
"4C97EBA926031A7CF7D7B36FDE3ED66DDA5421192D63DE53FFB46E43B9DC8373": {
Enabled: false,
Name: "MultiSign",
Supported: true,
Vetoed: false,
},
"6781F8368C4771B83E8B821D88F580202BCB4228075297B19E4FDC5233F1EFDC": {
Enabled: false,
Name: "TrustSetAuth",
Supported: true,
Vetoed: false,
},
"C1B8D934087225F509BEB5A8EC24447854713EE447D277F69545ABFA0E0FD490": {
Enabled: false,
Name: "Tickets",
Supported: true,
Vetoed: false,
},
"DA1BD556B42D85EA9C84066D028D355B52416734D3283F85E216EA5DA6DB7E13": {
Enabled: false,
Name: "SusPay",
Supported: true,
Vetoed: false,
},
},
}

j := `{
"features": {
"42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE": {
"enabled": false,
"name": "FeeEscalation",
"supported": true,
"vetoed": false
},
"4C97EBA926031A7CF7D7B36FDE3ED66DDA5421192D63DE53FFB46E43B9DC8373": {
"enabled": false,
"name": "MultiSign",
"supported": true,
"vetoed": false
},
"6781F8368C4771B83E8B821D88F580202BCB4228075297B19E4FDC5233F1EFDC": {
"enabled": false,
"name": "TrustSetAuth",
"supported": true,
"vetoed": false
},
"C1B8D934087225F509BEB5A8EC24447854713EE447D277F69545ABFA0E0FD490": {
"enabled": false,
"name": "Tickets",
"supported": true,
"vetoed": false
},
"DA1BD556B42D85EA9C84066D028D355B52416734D3283F85E216EA5DA6DB7E13": {
"enabled": false,
"name": "SusPay",
"supported": true,
"vetoed": false
}
}
}`

if err := test.SerializeAndDeserialize(t, s, j); err != nil {
t.Error(err)
}
}
73 changes: 73 additions & 0 deletions model/client/admin/status/fetch_info_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package status

import (
"testing"

"github.com/xyield/xrpl-go/test"
)

func TestFetchInfoResponse(t *testing.T) {
s := FetchInfoResponse{
Info: map[string]FetchInfo{
"348928": {
Hash: "C26D432B06F84861BCACD7942EDC3FE0B2E1DEB966A9E516A0FD275A375C2010",
HaveHeader: true,
HaveTransactions: true,
NeededStateHashes: []string{
"BF8DC6B1E10D1D3565BF0649075D22EBFD34F751AFCC0E53E81D74786BC88922",
"34E37A71CB51A12C73A435250E6A6349F7884C7EEBA6B88FA31F0244E967E88F",
"BFB7D3008A7D61FD6A0538D1C2E70CFB94CE8DC66606319C372F278A48629765",
"41C0C61D701FB1EA586F0EF1FC7A91FEC476D979589DA60507F05C13F7C21975",
"6DDE8840A2C3C7FF05E5FFEE4D06408694C16A8357338FE0C4581DC3D8A00BBA",
"6C69D833B582C849917806FA009518832BB50E900E43716FD7CC1966428DD0CF",
"1EDC020CFC4AF19B625C52E20B66D6AE672821CCC461E8A9C457A3B2955657F7",
"FC0616A66A2B0589CA513F3341D4EA51E782C4601E5072308478E3CC19264640",
"19FC607B5DE1B64681A676EC1ED5507B9555B0E098CD9D898320297DE1A64033",
"5E128D3FC990074E35687387A14AA12D9FD287E5AB57CB9B2FD83DE635DF5CA9",
"DE72820F3981770F2AA8770BC233B80661F1A452819D8529008875FF8DED87A9",
"3ACB84BEE2C45556351FF60FD787D235C9CF5623FB8A35B01446B773598E7CC0",
"0DD3A8DF69874148057F1F2BF305442FF2E89A76A08B4CC8C051E2ED69B874F3",
"4AE9A9C4F12A5BD0355037DA40A0B145420A2168A9FEDE43E643BD13062F8ECE",
"08CBF8CFFEC207F5AC4E4F24BC447011FD8C79D25B344281FBFB4732D7058ED4",
"779B2577C5C4BAED6657421448EA506BBF50F86BE363E0924127C4EA17A58BBE",
},
Peers: 2,
Timeouts: 0,
},
},
}

j := `{
"info": {
"348928": {
"hash": "C26D432B06F84861BCACD7942EDC3FE0B2E1DEB966A9E516A0FD275A375C2010",
"have_header": true,
"have_transactions": true,
"needed_state_hashes": [
"BF8DC6B1E10D1D3565BF0649075D22EBFD34F751AFCC0E53E81D74786BC88922",
"34E37A71CB51A12C73A435250E6A6349F7884C7EEBA6B88FA31F0244E967E88F",
"BFB7D3008A7D61FD6A0538D1C2E70CFB94CE8DC66606319C372F278A48629765",
"41C0C61D701FB1EA586F0EF1FC7A91FEC476D979589DA60507F05C13F7C21975",
"6DDE8840A2C3C7FF05E5FFEE4D06408694C16A8357338FE0C4581DC3D8A00BBA",
"6C69D833B582C849917806FA009518832BB50E900E43716FD7CC1966428DD0CF",
"1EDC020CFC4AF19B625C52E20B66D6AE672821CCC461E8A9C457A3B2955657F7",
"FC0616A66A2B0589CA513F3341D4EA51E782C4601E5072308478E3CC19264640",
"19FC607B5DE1B64681A676EC1ED5507B9555B0E098CD9D898320297DE1A64033",
"5E128D3FC990074E35687387A14AA12D9FD287E5AB57CB9B2FD83DE635DF5CA9",
"DE72820F3981770F2AA8770BC233B80661F1A452819D8529008875FF8DED87A9",
"3ACB84BEE2C45556351FF60FD787D235C9CF5623FB8A35B01446B773598E7CC0",
"0DD3A8DF69874148057F1F2BF305442FF2E89A76A08B4CC8C051E2ED69B874F3",
"4AE9A9C4F12A5BD0355037DA40A0B145420A2168A9FEDE43E643BD13062F8ECE",
"08CBF8CFFEC207F5AC4E4F24BC447011FD8C79D25B344281FBFB4732D7058ED4",
"779B2577C5C4BAED6657421448EA506BBF50F86BE363E0924127C4EA17A58BBE"
],
"peers": 2,
"timeouts": 0
}
}
}`

if err := test.SerializeAndDeserialize(t, s, j); err != nil {
t.Error(err)
}
}
22 changes: 11 additions & 11 deletions model/client/admin/status/get_counts_response.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package status

type GetCountsResponse struct {
Transaction int
Ledger int
NodeObject int
Uptime string `json:"uptime"`
LedgerHitRate float32 `json:"ledger_hit_rate"`
NodeHitRate float32 `json:"node_hit_rate"`
NodeReadBytes int `json:"node_read_bytes"`
NodeReadsHit int `json:"node_reads_hit"`
NodeReadsTotal int `json:"node_reads_total"`
NodeWrites int `json:"node_writes"`
NodeWrittenBytes int `json:"node_written_bytes"`
Transaction int `json:",omitempty"`
Ledger int `json:",omitempty"`
NodeObject int `json:",omitempty"`
Uptime string `json:"uptime,omitempty"`
LedgerHitRate float32 `json:"ledger_hit_rate,omitempty"`
NodeHitRate float32 `json:"node_hit_rate,omitempty"`
NodeReadBytes int `json:"node_read_bytes,omitempty"`
NodeReadsHit int `json:"node_reads_hit,omitempty"`
NodeReadsTotal int `json:"node_reads_total,omitempty"`
NodeWrites int `json:"node_writes,omitempty"`
NodeWrittenBytes int `json:"node_written_bytes,omitempty"`
}

0 comments on commit fbf1f22

Please sign in to comment.