Skip to content

Commit 4d5fc81

Browse files
committed
Create scafolding for "Predefined Abstain DRep" test
1 parent e155f27 commit 4d5fc81

File tree

3 files changed

+87
-2
lines changed

3 files changed

+87
-2
lines changed

cardano-testnet/cardano-testnet.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,13 @@ test-suite cardano-testnet-test
188188
Cardano.Testnet.Test.FoldBlocks
189189
Cardano.Testnet.Test.Misc
190190

191+
Cardano.Testnet.Test.LedgerEvents.Gov.DRepActivity
191192
Cardano.Testnet.Test.LedgerEvents.Gov.DRepDeposits
192193
Cardano.Testnet.Test.LedgerEvents.Gov.InfoAction
194+
Cardano.Testnet.Test.LedgerEvents.Gov.PredefinedAbstainDRep
193195
Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitution
194196
Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitutionSPO
195197
Cardano.Testnet.Test.LedgerEvents.Gov.TreasuryWithdrawal
196-
Cardano.Testnet.Test.LedgerEvents.Gov.DRepActivity
197198
Cardano.Testnet.Test.LedgerEvents.SanityCheck
198199
Cardano.Testnet.Test.LedgerEvents.TreasuryGrowth
199200

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{-# LANGUAGE DataKinds #-}
2+
{-# LANGUAGE NamedFieldPuns #-}
3+
{-# LANGUAGE OverloadedStrings #-}
4+
{-# LANGUAGE ScopedTypeVariables #-}
5+
6+
module Cardano.Testnet.Test.LedgerEvents.Gov.PredefinedAbstainDRep
7+
( hprop_check_predefined_abstain_drep
8+
) where
9+
10+
import Cardano.Api as Api
11+
12+
import Cardano.Testnet
13+
14+
import Prelude
15+
16+
import System.FilePath ((</>))
17+
18+
import Testnet.Components.Query (getEpochStateView)
19+
import qualified Testnet.Process.Run as H
20+
import qualified Testnet.Property.Utils as H
21+
import Testnet.Runtime
22+
23+
import Hedgehog
24+
import qualified Hedgehog.Extras as H
25+
import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as IO
26+
27+
-- | Execute me with:
28+
-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/Predefined Abstain DRep/"'@
29+
hprop_check_predefined_abstain_drep :: Property
30+
hprop_check_predefined_abstain_drep = H.integrationWorkspace "test-activity" $ \tempAbsBasePath' -> do
31+
-- Start a local test net
32+
conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath'
33+
let tempAbsPath' = unTmpAbsPath tempAbsPath
34+
tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath
35+
36+
work <- H.createDirectoryIfMissing $ tempAbsPath' </> "work"
37+
38+
-- Create default testnet with 3 DReps and 3 stake holders delegated, one to each DRep.
39+
let sbe = ShelleyBasedEraConway
40+
era = toCardanoEra sbe
41+
cEra = AnyCardanoEra era
42+
fastTestnetOptions = cardanoDefaultTestnetOptions
43+
{ cardanoEpochLength = 100
44+
, cardanoNodeEra = cEra
45+
, cardanoNumDReps = 3
46+
}
47+
48+
testnetRuntime@TestnetRuntime
49+
{ testnetMagic
50+
, poolNodes
51+
, wallets=_wallet0:_wallet1:_wallet2:_
52+
, configurationFile
53+
}
54+
<- cardanoTestnetDefault fastTestnetOptions conf
55+
56+
poolNode1 <- H.headM poolNodes
57+
poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1
58+
_execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic
59+
60+
let socketName' = IO.sprocketName poolSprocket1
61+
socketBase = IO.sprocketBase poolSprocket1 -- /tmp
62+
socketPath = socketBase </> socketName'
63+
64+
_epochStateView <- getEpochStateView (File configurationFile) (File socketPath)
65+
66+
startLedgerNewEpochStateLogging testnetRuntime tempAbsPath'
67+
68+
H.note_ $ "Sprocket: " <> show poolSprocket1
69+
H.note_ $ "Abs path: " <> tempAbsBasePath'
70+
H.note_ $ "Socketpath: " <> socketPath
71+
H.note_ $ "Foldblocks config file: " <> configurationFile
72+
73+
_gov <- H.createDirectoryIfMissing $ work </> "governance"
74+
75+
-- ToDo: Do some proposal and vote yes with the first DRep only.
76+
-- ToDo: ASSERT: Check that proposal does NOT pass.
77+
-- ToDo: Take the last two stake delegators and delegate them to "Abstain".
78+
-- ToDo: This can be done using cardano-cli conway stake-address vote-delegation-certificate --always-abstain
79+
-- ToDo: Do some other proposal and vote yes with first DRep only.
80+
-- ToDo: ASSERT: Check the new proposal passes now.
81+
82+
success

cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import qualified Cardano.Testnet.Test.Cli.QuerySlotNumber
1616
import qualified Cardano.Testnet.Test.FoldBlocks
1717
import qualified Cardano.Testnet.Test.LedgerEvents.Gov.DRepActivity
1818
import qualified Cardano.Testnet.Test.LedgerEvents.Gov.DRepDeposits
19+
import qualified Cardano.Testnet.Test.LedgerEvents.Gov.PredefinedAbstainDRep
1920
import qualified Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitution
2021
import qualified Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitutionSPO as LedgerEvents
2122
import qualified Cardano.Testnet.Test.LedgerEvents.Gov.TreasuryWithdrawal as LedgerEvents
@@ -48,7 +49,8 @@ tests = do
4849
, H.ignoreOnWindows "Treasury Growth" LedgerEvents.prop_check_if_treasury_is_growing
4950
-- TODO: Replace foldBlocks with checkLedgerStateCondition
5051
, T.testGroup "Governance"
51-
[ H.ignoreOnMacAndWindows "ProposeAndRatifyNewConstitution" Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitution.hprop_ledger_events_propose_new_constitution
52+
[ H.ignoreOnWindows "Predefined Abstain DRep" Cardano.Testnet.Test.LedgerEvents.Gov.PredefinedAbstainDRep.hprop_check_predefined_abstain_drep
53+
, H.ignoreOnMacAndWindows "ProposeAndRatifyNewConstitution" Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitution.hprop_ledger_events_propose_new_constitution
5254
, H.ignoreOnWindows "DRep Activity" Cardano.Testnet.Test.LedgerEvents.Gov.DRepActivity.hprop_check_drep_activity
5355
, H.ignoreOnWindows "DRep Deposits" Cardano.Testnet.Test.LedgerEvents.Gov.DRepDeposits.hprop_ledger_events_drep_deposits
5456
-- FIXME Those tests are flaky

0 commit comments

Comments
 (0)