diff --git a/cardano-testnet/cardano-testnet.cabal b/cardano-testnet/cardano-testnet.cabal index 2a2ac0f5cd9..d0b059dd223 100644 --- a/cardano-testnet/cardano-testnet.cabal +++ b/cardano-testnet/cardano-testnet.cabal @@ -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 diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/PredefinedAbstainDRep.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/PredefinedAbstainDRep.hs new file mode 100644 index 00000000000..7116fd7e9ce --- /dev/null +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/PredefinedAbstainDRep.hs @@ -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 diff --git a/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs b/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs index 764c2a78d0a..d9de09e5848 100644 --- a/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs +++ b/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs @@ -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 @@ -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