Skip to content

Commit 29462f1

Browse files
committed
Add golden tests for queryCommitteeMembersState
1 parent 2510f22 commit 29462f1

6 files changed

Lines changed: 232 additions & 1 deletion

File tree

Binary file not shown.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
[
2+
{
3+
"committee": {},
4+
"epoch": 0,
5+
"threshold": null
6+
},
7+
{
8+
"committee": {
9+
"keyHash-58e1b65718531b42494610c506cef10ff031fa817a8ff75c0ab180e7": {
10+
"expiration": 250,
11+
"hotCredsAuthStatus": {
12+
"contents": {
13+
"scriptHash": "4bb4efce5b9566c44aafce0437573d28d6b226cbb15cf8ff3601293c"
14+
},
15+
"tag": "MemberAuthorized"
16+
},
17+
"nextEpochChange": {
18+
"tag": "ToBeExpired"
19+
},
20+
"status": "Active"
21+
},
22+
"keyHash-65fc709a5e019b8aba76f6977c1c8770e4b36fa76f434efc588747b7": {
23+
"expiration": 300,
24+
"hotCredsAuthStatus": {
25+
"contents": null,
26+
"tag": "MemberResigned"
27+
},
28+
"nextEpochChange": {
29+
"contents": 350,
30+
"tag": "TermAdjusted"
31+
},
32+
"status": "Active"
33+
},
34+
"keyHash-a646474b8f5431261506b6c273d307c7569a4eb6c96b42dd4a29520a": {
35+
"expiration": 100,
36+
"hotCredsAuthStatus": {
37+
"tag": "MemberNotAuthorized"
38+
},
39+
"nextEpochChange": {
40+
"tag": "ToBeRemoved"
41+
},
42+
"status": "Expired"
43+
},
44+
"keyHash-e0a714319812c3f773ba04ec5d6b3ffcd5aad85006805b047b082541": {
45+
"expiration": 200,
46+
"hotCredsAuthStatus": {
47+
"contents": {
48+
"keyHash": "92bf8969a49623af689a49861adf7639b25fd663c95733f147f44e71"
49+
},
50+
"tag": "MemberAuthorized"
51+
},
52+
"nextEpochChange": {
53+
"tag": "NoChangeExpected"
54+
},
55+
"status": "Active"
56+
},
57+
"scriptHash-b16b56f5ec064be6ac3cab6035efae86b366cc3dc4a0d571603d70e5": {
58+
"expiration": null,
59+
"hotCredsAuthStatus": {
60+
"contents": {
61+
"dataHash": "03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314",
62+
"url": "https://example.com"
63+
},
64+
"tag": "MemberResigned"
65+
},
66+
"nextEpochChange": {
67+
"tag": "ToBeEnacted"
68+
},
69+
"status": "Unrecognized"
70+
}
71+
},
72+
"epoch": 150,
73+
"threshold": {
74+
"denominator": 3,
75+
"numerator": 2
76+
}
77+
}
78+
]
Binary file not shown.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
[
2+
{
3+
"committee": {},
4+
"epoch": 0,
5+
"threshold": null
6+
},
7+
{
8+
"committee": {
9+
"keyHash-58e1b65718531b42494610c506cef10ff031fa817a8ff75c0ab180e7": {
10+
"expiration": 250,
11+
"hotCredsAuthStatus": {
12+
"contents": {
13+
"scriptHash": "4bb4efce5b9566c44aafce0437573d28d6b226cbb15cf8ff3601293c"
14+
},
15+
"tag": "MemberAuthorized"
16+
},
17+
"nextEpochChange": {
18+
"tag": "ToBeExpired"
19+
},
20+
"status": "Active"
21+
},
22+
"keyHash-65fc709a5e019b8aba76f6977c1c8770e4b36fa76f434efc588747b7": {
23+
"expiration": 300,
24+
"hotCredsAuthStatus": {
25+
"contents": null,
26+
"tag": "MemberResigned"
27+
},
28+
"nextEpochChange": {
29+
"contents": 350,
30+
"tag": "TermAdjusted"
31+
},
32+
"status": "Active"
33+
},
34+
"keyHash-a646474b8f5431261506b6c273d307c7569a4eb6c96b42dd4a29520a": {
35+
"expiration": 100,
36+
"hotCredsAuthStatus": {
37+
"tag": "MemberNotAuthorized"
38+
},
39+
"nextEpochChange": {
40+
"tag": "ToBeRemoved"
41+
},
42+
"status": "Expired"
43+
},
44+
"keyHash-e0a714319812c3f773ba04ec5d6b3ffcd5aad85006805b047b082541": {
45+
"expiration": 200,
46+
"hotCredsAuthStatus": {
47+
"contents": {
48+
"keyHash": "92bf8969a49623af689a49861adf7639b25fd663c95733f147f44e71"
49+
},
50+
"tag": "MemberAuthorized"
51+
},
52+
"nextEpochChange": {
53+
"tag": "NoChangeExpected"
54+
},
55+
"status": "Active"
56+
},
57+
"scriptHash-b16b56f5ec064be6ac3cab6035efae86b366cc3dc4a0d571603d70e5": {
58+
"expiration": null,
59+
"hotCredsAuthStatus": {
60+
"contents": {
61+
"dataHash": "03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314",
62+
"url": "https://example.com"
63+
},
64+
"tag": "MemberResigned"
65+
},
66+
"nextEpochChange": {
67+
"tag": "ToBeEnacted"
68+
},
69+
"status": "Unrecognized"
70+
}
71+
},
72+
"epoch": 150,
73+
"threshold": {
74+
"denominator": 3,
75+
"numerator": 2
76+
}
77+
}
78+
]

libs/cardano-ledger-api/test/Test/Cardano/Ledger/Api/State/QuerySpec.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import Test.Cardano.Ledger.Api.Arbitrary ()
4949
import Test.Cardano.Ledger.Api.State.Query.Examples (
5050
queryAccountsDepositsExamples,
5151
queryChainAccountStateExamples,
52+
queryCommitteeMembersStateExamples,
5253
queryConstitutionExamples,
5354
queryConstitutionHashExamples,
5455
queryCurrentEpochNoExamples,
@@ -140,6 +141,9 @@ latestErasSpec =
140141
eraLedgerStateQueryNoFromJSONGoldenSpec @era
141142
"queryChainAccountState"
142143
queryChainAccountStateExamples
144+
eraLedgerStateQueryNoFromJSONGoldenSpec @era
145+
"queryCommitteeMembersState"
146+
queryCommitteeMembersStateExamples
143147
eraLedgerStateQueryGoldenSpec @era "queryConstitution" (queryConstitutionExamples @era)
144148
eraLedgerStateQueryGoldenSpec @era "queryConstitutionHash" queryConstitutionHashExamples
145149
eraLedgerStateQueryGoldenSpec @era "queryCurrentEpochNo" queryCurrentEpochNoExamples

libs/cardano-ledger-api/testlib/Test/Cardano/Ledger/Api/State/Query/Examples.hs

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
module Test.Cardano.Ledger.Api.State.Query.Examples (
77
queryAccountsDepositsExamples,
88
queryChainAccountStateExamples,
9+
queryCommitteeMembersStateExamples,
910
queryConstitutionExamples,
1011
queryConstitutionHashExamples,
1112
queryCurrentEpochNoExamples,
@@ -27,12 +28,24 @@ module Test.Cardano.Ledger.Api.State.Query.Examples (
2728
import Cardano.Base.IP (toIPv4, toIPv6)
2829
import Cardano.Ledger.Api.Governance (Constitution (..))
2930
import Cardano.Ledger.Api.State.Query (
31+
CommitteeMemberState (..),
32+
CommitteeMembersState (..),
3033
DefaultVote (..),
34+
HotCredAuthStatus (..),
35+
MemberStatus (..),
36+
NextEpochChange (..),
3137
QueryPoolStateResult (..),
3238
StakeSnapshot (..),
3339
StakeSnapshots (..),
3440
)
35-
import Cardano.Ledger.BaseTypes (AnchorData, EpochNo (..), Port (..), StrictMaybe (..), textToDns)
41+
import Cardano.Ledger.BaseTypes (
42+
AnchorData,
43+
EpochNo (..),
44+
Port (..),
45+
StrictMaybe (..),
46+
UnitInterval,
47+
textToDns,
48+
)
3649
import Cardano.Ledger.Coin (Coin (..), CompactForm (..), knownNonZeroCoin)
3750
import Cardano.Ledger.Credential (Credential (..))
3851
import Cardano.Ledger.DRep (DRep (..), DRepState (..))
@@ -55,6 +68,7 @@ import qualified Data.Sequence.Strict as StrictSeq
5568
import Data.Set (Set)
5669
import qualified Data.Set as Set
5770
import Test.Cardano.Ledger.Conway.Examples (exampleAnchor)
71+
import Test.Cardano.Ledger.Core.Rational (unsafeBoundRational)
5872
import Test.Cardano.Ledger.Core.Utils (mkDummySafeHash)
5973
import Test.Cardano.Ledger.Shelley.Examples (
6074
examplePoolDistr,
@@ -105,6 +119,63 @@ queryChainAccountStateExamples =
105119
, ChainAccountState (Coin 1_500_000_000_000_000) (Coin 8_000_000_000_000_000)
106120
]
107121

122+
queryCommitteeMembersStateExamples :: [CommitteeMembersState]
123+
queryCommitteeMembersStateExamples =
124+
[ CommitteeMembersState Map.empty Nothing (EpochNo 0)
125+
, CommitteeMembersState
126+
{ csCommittee =
127+
Map.fromList
128+
[
129+
( KeyHashObj (mkKeyHash 1)
130+
, CommitteeMemberState
131+
{ cmsHotCredAuthStatus = MemberAuthorized (KeyHashObj (mkKeyHash 11))
132+
, cmsStatus = Active
133+
, cmsExpiration = Just (EpochNo 200)
134+
, cmsNextEpochChange = NoChangeExpected
135+
}
136+
)
137+
,
138+
( KeyHashObj (mkKeyHash 2)
139+
, CommitteeMemberState
140+
{ cmsHotCredAuthStatus = MemberNotAuthorized
141+
, cmsStatus = Expired
142+
, cmsExpiration = Just (EpochNo 100)
143+
, cmsNextEpochChange = ToBeRemoved
144+
}
145+
)
146+
,
147+
( ScriptHashObj (mkScriptHash 3)
148+
, CommitteeMemberState
149+
{ cmsHotCredAuthStatus = MemberResigned (Just exampleAnchor)
150+
, cmsStatus = Unrecognized
151+
, cmsExpiration = Nothing
152+
, cmsNextEpochChange = ToBeEnacted
153+
}
154+
)
155+
,
156+
( KeyHashObj (mkKeyHash 4)
157+
, CommitteeMemberState
158+
{ cmsHotCredAuthStatus = MemberResigned Nothing
159+
, cmsStatus = Active
160+
, cmsExpiration = Just (EpochNo 300)
161+
, cmsNextEpochChange = TermAdjusted (EpochNo 350)
162+
}
163+
)
164+
,
165+
( KeyHashObj (mkKeyHash 5)
166+
, CommitteeMemberState
167+
{ cmsHotCredAuthStatus = MemberAuthorized (ScriptHashObj (mkScriptHash 50))
168+
, cmsStatus = Active
169+
, cmsExpiration = Just (EpochNo 250)
170+
, cmsNextEpochChange = ToBeExpired
171+
}
172+
)
173+
]
174+
, csThreshold = Just (unsafeBoundRational (2 % 3) :: UnitInterval)
175+
, csEpochNo = EpochNo 150
176+
}
177+
]
178+
108179
querySPOStakeDistrExamples :: [Map (KeyHash StakePool) Coin]
109180
querySPOStakeDistrExamples =
110181
[ Map.empty

0 commit comments

Comments
 (0)