Skip to content

Commit b7e2f4e

Browse files
committed
test: Add another check to new committee rollback
1 parent b8d12a5 commit b7e2f4e

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

cardano-chain-gen/src/Cardano/Mock/Query.hs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module Cardano.Mock.Query (
1414
queryRewardRests,
1515
queryTreasuryDonations,
1616
queryVoteCounts,
17+
queryEpochStateCount,
1718
) where
1819

1920
import qualified Cardano.Db as Db
@@ -201,3 +202,15 @@ queryVoteCounts txHash idx = do
201202
&&. vote ^. Db.VotingProcedureIndex ==. val idx
202203
pure countRows
203204
pure (maybe 0 unValue res)
205+
206+
queryEpochStateCount ::
207+
MonadIO io =>
208+
Word64 ->
209+
ReaderT SqlBackend io Word64
210+
queryEpochStateCount epochNo = do
211+
res <- selectOne $ do
212+
epochState <- from (table @Db.EpochState)
213+
where_ (epochState ^. Db.EpochStateEpochNo ==. val epochNo)
214+
pure countRows
215+
216+
pure (maybe 0 unValue res)

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Governance.hs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ drepDistr =
5656

5757
-- Add stake
5858
void (Api.registerAllStakeCreds interpreter server)
59-
6059
-- Register DRep and delegate votes to it
6160
void (Api.registerDRepsAndDelegateVotes interpreter server)
62-
6361
-- DRep distribution is calculated at end of the current epoch
6462
epoch1 <- Api.fillUntilNextEpoch interpreter server
6563

@@ -124,13 +122,23 @@ rollbackNewCommittee =
124122
-- Rollback the last 2 blocks
125123
epoch1' <- rollbackBlocks interpreter server 2 epoch2
126124
-- Wait for it to sync
127-
assertBlockNoBackoff dbSync (length epoch1' + 4)
125+
assertBlockNoBackoff dbSync (length epoch1' + 3)
128126
-- Should not have a new committee member
129127
assertEqQuery
130128
dbSync
131129
Query.queryGovActionCounts
132130
(1, 0, 0, 0)
133131
"Unexpected governance action counts"
132+
133+
-- Fast forward to next epoch
134+
epoch2' <- Api.fillUntilNextEpoch interpreter server
135+
assertBlockNoBackoff dbSync (length (epoch1' <> epoch2') + 3)
136+
-- Should now have 2 identical committees
137+
assertEqQuery
138+
dbSync
139+
(Query.queryEpochStateCount 2)
140+
2
141+
"Unexpected epoch state count for epoch 2"
134142
where
135143
testLabel = "conwayRollbackNewCommittee"
136144

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[12,16,18,21,24,30,31,32,33,40,41,42,43,47,52,60,62,70,80,84,86,92,98,100,106,109,110,111,112,127,134,138,146,149,154,166,168,178,183,188,193,194,198,200,202,220,222,223,224,225,231,239,242,247,261,282,283,288,289,301,302,303,308,313,315,316,320,331,334,344,345,363,364,368,369,375,377,381,389,394,407,418,422,425,430,437,438,439,440,447,450,453,454,456,458,461,467,492,499,507,516,524,538,541,544,546,550,567,573,576,577,579,580,586,589,595,597,603,605,609,616,618,619,623,624,634,636,643,644,659,664,665,672,678,692,705,711,712,719,726,730,739,740,743,747,749,751,754,759,762,763,765,767,773,777,786,788,789,794,801,806,807,829,830,832,849,851,853,869,871,874,875,878,882,888,893,895,896,898,899,903,906,908,911,912,913,922,930,932,938,941,944,950,960,963,966,968,972,977,985,986,988,990,991,994,997,1001,997]
1+
[12,16,18,21,24,30,31,32,33,40,41,42,43,47,52,60,62,70,80,84,86,92,98,100,106,109,110,111,112,127,134,138,146,149,154,166,168,178,183,188,193,194,198,200,202,220,222,223,224,225,231,239,242,247,261,282,283,288,289,301,302,303,308,313,315,316,320,331,334,344,345,363,364,368,369,375,377,381,389,394,407,418,422,425,430,437,438,439,440,447,450,453,454,456,458,461,467,492,499,507,516,524,538,541,544,546,550,567,573,576,577,579,580,586,589,595,597,603,605,609,616,618,619,623,624,634,636,643,644,659,664,665,672,678,692,705,711,712,719,726,730,739,740,743,747,749,751,754,759,762,763,765,767,773,777,786,788,789,794,801,806,807,829,830,832,849,851,853,869,871,874,875,878,882,888,893,895,896,898,899,903,906,908,911,912,913,922,930,932,938,941,944,950,960,963,966,968,972,977,985,986,988,990,991,994,997,1001,997,1001]

0 commit comments

Comments
 (0)