Skip to content

Commit 257c995

Browse files
committed
Add test that forks to PV11
1 parent 095f251 commit 257c995

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ unitTests iom knownMigrations =
260260
, test "treasury withdrawal" Governance.treasuryWithdrawal
261261
, test "parameter change" Governance.parameterChange
262262
, test "hard fork" Governance.hardFork
263+
, test "hard fork post block" Governance.hardForkPostBlock
263264
, test "rollback hardfork" Governance.rollbackHardFork
264265
, test "info action" Governance.infoAction
265266
]

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

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module Test.Cardano.Db.Mock.Unit.Conway.Governance (
1717
parameterChange,
1818
chainedNewCommittee,
1919
hardFork,
20+
hardForkPostBlock,
2021
rollbackHardFork,
2122
infoAction,
2223
) where
@@ -478,6 +479,69 @@ hardFork =
478479
testLabel = "conwayGovernanceHardFork"
479480
getEpochNo = fmap unEpochNo . liftIO . getCurrentEpoch
480481

482+
-- | Tests that db-sync continues to sync correctly after an intra-era hard fork
483+
-- (PV 10 -> PV 11 within Conway). After enacting the HF, we forge additional blocks
484+
-- containing payment transactions and governance actions, then verify db-sync
485+
-- indexes them without errors.
486+
hardForkPostBlock :: IOManager -> [(Text, Text)] -> Assertion
487+
hardForkPostBlock =
488+
withFullConfigLog conwayConfigDir testLabel $ \interpreter server dbSync -> do
489+
startDBSync dbSync
490+
491+
-- Register SPOs, DReps, and committee to vote
492+
epoch1 <- initGovernance interpreter server
493+
-- Propose, ratify, and enact a hard fork (PV 10 -> 11)
494+
epoch3 <- enactHardFork interpreter server
495+
496+
-- Wait for it to sync
497+
assertBlockNoBackoff dbSync (length $ epoch1 <> epoch3)
498+
-- Verify the HF was enacted
499+
assertEqQuery
500+
dbSync
501+
( do
502+
epochNo <- getEpochNo interpreter
503+
mEpochParam <- DB.queryEpochParamWithEpochNo epochNo
504+
pure $ DB.epochParamProtocolMajor <$> mEpochParam
505+
)
506+
(Just 11)
507+
"Unexpected protocol major version after hard fork"
508+
509+
-- === Post-HF: forge blocks with transactions under PV 11 ===
510+
511+
-- 1. Simple payment transaction
512+
void $
513+
Api.withConwayFindLeaderAndSubmitTx interpreter server $
514+
Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10_000 500 0
515+
assertBlockNoBackoff dbSync (length (epoch1 <> epoch3) + 1)
516+
517+
-- 2. Forge a few empty blocks to ensure the chain progresses
518+
emptyBlks <- Api.forgeAndSubmitBlocks interpreter server 3
519+
assertBlockNoBackoff dbSync (length (epoch1 <> epoch3) + 1 + length emptyBlks)
520+
521+
-- 3. A governance info action to verify governance still works post-HF
522+
void $
523+
Api.withConwayFindLeaderAndSubmit interpreter server $ \_ ->
524+
pure [Conway.mkInfoTx]
525+
assertBlockNoBackoff dbSync (length (epoch1 <> epoch3) + 1 + length emptyBlks + 1)
526+
527+
-- 4. Fill to next epoch boundary to exercise epoch processing post-HF
528+
epochNext <- Api.fillUntilNextEpoch interpreter server
529+
let totalBlocks = length (epoch1 <> epoch3) + 1 + length emptyBlks + 1 + length epochNext
530+
assertBlockNoBackoff dbSync totalBlocks
531+
532+
-- Verify the HF governance action is still ratified/enacted
533+
assertEqQuery
534+
dbSync
535+
DB.queryGovActionCounts
536+
(1, 1, 0, 0)
537+
"Unexpected governance action counts after post-HF blocks"
538+
539+
-- Verify db-sync is still running (hasn't crashed)
540+
checkStillRuns dbSync
541+
where
542+
testLabel = "conwayGovernanceHardForkPostBlock"
543+
getEpochNo = fmap unEpochNo . liftIO . getCurrentEpoch
544+
481545
rollbackHardFork :: IOManager -> [(Text, Text)] -> Assertion
482546
rollbackHardFork =
483547
withFullConfig conwayConfigDir testLabel $ \interpreter server dbSync -> do
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +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,1005,1014,1019,1020,1026,1027,1031,1032,1033,1036,1037,1050,1057,1062,1067,1068,1070,1074,1083,1094,1102,1104,1107,1111,1115,1118,1120,1125,1137,1149,1151,1155,1161,1164,1167,1174,1187,1200,1201,1218,1221,1237,1242,1248,1263,1266,1272,1277,1283,1299,1304,1309,1313,1317,1336,1338,1343,1356,1366,1376,1377,1379,1390,1397,1401,1408,1410,1412,1418,1424,1429,1432,1435,1439,1442,1444,1449,1453,1462,1470,1473,1474,1481,1484,1486,1519,1524,1533,1534,1539,1547,1549,1551,1552,1554,1556,1560,1568,1571,1573,1577,1581,1600,1601,1605,1619,1620,1622,1624,1626,1629,1640,1645,1646,1657,1663,1665,1670,1675,1683,1690,1700,1704,1714,1716,1721,1736,1741,1746,1756,1762,1764,1765,1767,1772,1773,1786,1787,1810,1816,1819,1821,1822,1825,1831,1832,1833,1835,1849,1852,1853,1863,1873,1876,1882,1889,1891,1904,1908,1915,1929,1930,1932,1936,1937,1944,1951,1955,1956,1957,1958,1959,1961,1963,1971,1975,1985,1990,1993,1997,1998,2001]

0 commit comments

Comments
 (0)