Skip to content

Commit

Permalink
Create scafolding for "Predefined Abstain DRep" test
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed May 9, 2024
1 parent b8c8695 commit e6c9fdd
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cardano-testnet/cardano-testnet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ test-suite cardano-testnet-test
Cardano.Testnet.Test.Gov.TreasuryGrowth
Cardano.Testnet.Test.Gov.TreasuryWithdrawal
Cardano.Testnet.Test.Misc
Cardano.Testnet.Test.Gov.DRepActivity
Cardano.Testnet.Test.Gov.PredefinedAbstainDRep
Cardano.Testnet.Test.Node.Shutdown
Cardano.Testnet.Test.SanityCheck
Cardano.Testnet.Test.SubmitApi.Babbage.Transaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ hprop_check_drep_activity = H.integrationWorkspace "test-activity" $ \tempAbsBas

work <- H.createDirectoryIfMissing $ tempAbsPath' </> "work"

-- Create default testnet with 3 DReps and 3 stake holders delegated, one to each DRep.
let ceo = ConwayEraOnwardsConway
sbe = conwayEraOnwardsToShelleyBasedEra ceo
era = toCardanoEra sbe
cEra = AnyCardanoEra era
fastTestnetOptions = cardanoDefaultTestnetOptions
{ cardanoEpochLength = 100
, cardanoNodeEra = cEra
, cardanoNumDReps = 1
, cardanoNumDReps = 3
}

TestnetRuntime
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Cardano.Testnet.Test.Gov.PredefinedAbstainDRep
( hprop_check_predefined_abstain_drep
) where

import Cardano.Api as Api

import Cardano.Testnet

import Prelude

import System.FilePath ((</>))

import Testnet.Components.Query (getEpochStateView)
import qualified Testnet.Process.Run as H
import qualified Testnet.Property.Util as H
import Testnet.Runtime
import Testnet.Types (PoolNode (..), TestnetRuntime (..), nodeSocketPath)

import Hedgehog
import qualified Hedgehog.Extras as H

-- | Execute me with:
-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/Predefined Abstain DRep/"'@
hprop_check_predefined_abstain_drep :: Property
hprop_check_predefined_abstain_drep = H.integrationWorkspace "test-activity" $ \tempAbsBasePath' -> do
-- Start a local test net
conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath'
let tempAbsPath' = unTmpAbsPath tempAbsPath
tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath
work <- H.createDirectoryIfMissing $ tempAbsPath' </> "work"

let ceo = ConwayEraOnwardsConway
sbe = conwayEraOnwardsToShelleyBasedEra ceo
era = toCardanoEra sbe
cEra = AnyCardanoEra era
fastTestnetOptions = cardanoDefaultTestnetOptions
{ cardanoEpochLength = 100
, cardanoNodeEra = cEra
, cardanoNumDReps = 1
}

testnetRuntime@TestnetRuntime
{ testnetMagic
, poolNodes
, wallets=_wallet0:_wallet1:_wallet2:_
, configurationFile
}
<- cardanoTestnetDefault fastTestnetOptions conf

PoolNode{poolRuntime} <- H.headM poolNodes
poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime
_execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic
let socketPath = nodeSocketPath poolRuntime

_epochStateView <- getEpochStateView configurationFile socketPath

startLedgerNewEpochStateLogging testnetRuntime tempAbsPath'

H.note_ $ "Sprocket: " <> show poolSprocket1
H.note_ $ "Abs path: " <> tempAbsBasePath'
H.note_ $ "Socketpath: " <> unFile socketPath
H.note_ $ "Foldblocks config file: " <> unFile configurationFile

_gov <- H.createDirectoryIfMissing $ work </> "governance"

-- ToDo: Do some proposal and vote yes with the first DRep only.
-- ToDo: ASSERT: Check that proposal does NOT pass.
-- ToDo: Take the last two stake delegators and delegate them to "Abstain".
-- ToDo: This can be done using cardano-cli conway stake-address vote-delegation-certificate --always-abstain
-- ToDo: Do some other proposal and vote yes with first DRep only.
-- ToDo: ASSERT: Check the new proposal passes now.

success
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import qualified Cardano.Testnet.Test.Cli.QuerySlotNumber
import qualified Cardano.Testnet.Test.FoldEpochState
import qualified Cardano.Testnet.Test.Gov.DRepDeposit as Gov
import qualified Cardano.Testnet.Test.Gov.DRepRetirement as Gov
import qualified Cardano.Testnet.Test.Gov.PredefinedAbstainDRep as Gov
import qualified Cardano.Testnet.Test.Gov.ProposeNewConstitution as Gov
import qualified Cardano.Testnet.Test.Gov.ProposeNewConstitutionSPO as Gov
import qualified Cardano.Testnet.Test.Gov.TreasuryGrowth as Gov
Expand Down Expand Up @@ -47,10 +48,10 @@ tests = do
, H.ignoreOnWindows "Treasury Growth" Gov.prop_check_if_treasury_is_growing
-- TODO: Replace foldBlocks with checkLedgerStateCondition
, T.testGroup "Governance"
[
[ H.ignoreOnWindows "Predefined Abstain DRep" Gov.hprop_check_predefined_abstain_drep
-- TODO: "DRep Activity" is too flaky at the moment. Disabling until we can fix it.
-- , H.ignoreOnWindows "DRep Activity" Cardano.Testnet.Test.LedgerEvents.Gov.DRepActivity.hprop_check_drep_activity
H.ignoreOnWindows "DRep Deposits" Gov.hprop_ledger_events_drep_deposits
, H.ignoreOnWindows "DRep Deposits" Gov.hprop_ledger_events_drep_deposits
-- FIXME Those tests are flaky
-- , H.ignoreOnWindows "InfoAction" LedgerEvents.hprop_ledger_events_info_action
, H.ignoreOnWindows "DRep Retirement" Gov.hprop_drep_retirement
Expand Down

0 comments on commit e6c9fdd

Please sign in to comment.