Skip to content

Commit

Permalink
Create scafolding for "Predefined No Confidence DRep" test
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Apr 30, 2024
1 parent f7deb3d commit ac8752f
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions cardano-testnet/cardano-testnet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ test-suite cardano-testnet-test
Cardano.Testnet.Test.LedgerEvents.Gov.DRepDeposits
Cardano.Testnet.Test.LedgerEvents.Gov.InfoAction
Cardano.Testnet.Test.LedgerEvents.Gov.PredefinedAbstainDRep
Cardano.Testnet.Test.LedgerEvents.Gov.PredefinedNoConfidenceDRep
Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitution
Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitutionSPO
Cardano.Testnet.Test.LedgerEvents.Gov.TreasuryWithdrawal
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Cardano.Testnet.Test.LedgerEvents.Gov.PredefinedNoConfidenceDRep
( hprop_check_predefined_no_confidence_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 No Confidence DRep/"'@
hprop_check_predefined_no_confidence_drep :: Property
hprop_check_predefined_no_confidence_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 all the DReps.
-- ToDo: ASSERT: that proposal passes.
-- ToDo: Take the last two stake delegators and delegate them to "No Confidence".
-- ToDo: This can be done using cardano-cli conway stake-address vote-delegation-certificate --always-no-confidence
-- ToDo: Do some other proposal and vote yes with all the DReps.
-- ToDo: ASSERT: the new proposal does NOT pass.
-- ToDo: Create a no confidence proposal.
-- ToDo: This can be done using cardano-cli conway governance action create-no-confidence
-- ToDo: Vote no to the no confidence proposal with all DReps.
-- ToDo: ASSERT: the no confidence proposal passes.

success
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import Test.Tasty (TestTree)
import qualified Test.Tasty.Ingredients as T
import qualified Test.Tasty.Options as T
import qualified Test.Tasty.Runners as T
import qualified Cardano.Testnet.Test.LedgerEvents.Gov.PredefinedNoConfidenceDRep

tests :: IO TestTree
tests = do
Expand All @@ -50,6 +51,7 @@ tests = do
-- TODO: Replace foldBlocks with checkLedgerStateCondition
, T.testGroup "Governance"
[ H.ignoreOnWindows "Predefined Abstain DRep" Cardano.Testnet.Test.LedgerEvents.Gov.PredefinedAbstainDRep.hprop_check_predefined_abstain_drep
, H.ignoreOnWindows "Predefined No Confidence DRep" Cardano.Testnet.Test.LedgerEvents.Gov.PredefinedNoConfidenceDRep.hprop_check_predefined_no_confidence_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
Expand Down

0 comments on commit ac8752f

Please sign in to comment.