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 Apr 29, 2024
1 parent e155f27 commit 4d5fc81
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cardano-testnet/cardano-testnet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,13 @@ test-suite cardano-testnet-test
Cardano.Testnet.Test.FoldBlocks
Cardano.Testnet.Test.Misc

Cardano.Testnet.Test.LedgerEvents.Gov.DRepActivity
Cardano.Testnet.Test.LedgerEvents.Gov.DRepDeposits
Cardano.Testnet.Test.LedgerEvents.Gov.InfoAction
Cardano.Testnet.Test.LedgerEvents.Gov.PredefinedAbstainDRep
Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitution
Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitutionSPO
Cardano.Testnet.Test.LedgerEvents.Gov.TreasuryWithdrawal
Cardano.Testnet.Test.LedgerEvents.Gov.DRepActivity
Cardano.Testnet.Test.LedgerEvents.SanityCheck
Cardano.Testnet.Test.LedgerEvents.TreasuryGrowth

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

module Cardano.Testnet.Test.LedgerEvents.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.Utils as H
import Testnet.Runtime

import Hedgehog
import qualified Hedgehog.Extras as H
import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as IO

-- | 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"

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

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

poolNode1 <- H.headM poolNodes
poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1
_execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic

let socketName' = IO.sprocketName poolSprocket1
socketBase = IO.sprocketBase poolSprocket1 -- /tmp
socketPath = socketBase </> socketName'

_epochStateView <- getEpochStateView (File configurationFile) (File socketPath)

startLedgerNewEpochStateLogging testnetRuntime tempAbsPath'

H.note_ $ "Sprocket: " <> show poolSprocket1
H.note_ $ "Abs path: " <> tempAbsBasePath'
H.note_ $ "Socketpath: " <> socketPath
H.note_ $ "Foldblocks config file: " <> 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 @@ -16,6 +16,7 @@ import qualified Cardano.Testnet.Test.Cli.QuerySlotNumber
import qualified Cardano.Testnet.Test.FoldBlocks
import qualified Cardano.Testnet.Test.LedgerEvents.Gov.DRepActivity
import qualified Cardano.Testnet.Test.LedgerEvents.Gov.DRepDeposits
import qualified Cardano.Testnet.Test.LedgerEvents.Gov.PredefinedAbstainDRep
import qualified Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitution
import qualified Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitutionSPO as LedgerEvents
import qualified Cardano.Testnet.Test.LedgerEvents.Gov.TreasuryWithdrawal as LedgerEvents
Expand Down Expand Up @@ -48,7 +49,8 @@ tests = do
, H.ignoreOnWindows "Treasury Growth" LedgerEvents.prop_check_if_treasury_is_growing
-- TODO: Replace foldBlocks with checkLedgerStateCondition
, T.testGroup "Governance"
[ H.ignoreOnMacAndWindows "ProposeAndRatifyNewConstitution" Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitution.hprop_ledger_events_propose_new_constitution
[ H.ignoreOnWindows "Predefined Abstain DRep" Cardano.Testnet.Test.LedgerEvents.Gov.PredefinedAbstainDRep.hprop_check_predefined_abstain_drep
, H.ignoreOnMacAndWindows "ProposeAndRatifyNewConstitution" Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitution.hprop_ledger_events_propose_new_constitution
, H.ignoreOnWindows "DRep Activity" Cardano.Testnet.Test.LedgerEvents.Gov.DRepActivity.hprop_check_drep_activity
, H.ignoreOnWindows "DRep Deposits" Cardano.Testnet.Test.LedgerEvents.Gov.DRepDeposits.hprop_ledger_events_drep_deposits
-- FIXME Those tests are flaky
Expand Down

0 comments on commit 4d5fc81

Please sign in to comment.