Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed May 7, 2024
1 parent 557d56a commit 1982762
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
1 change: 1 addition & 0 deletions cardano-testnet/src/Testnet/Components/DReps.hs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ signTx execConfig cEra work prefix txBody signatoryKeyPairs = do
]
return signedTx

-- TODO: Move me to Testnet.Property.Utils
-- | Submits a signed transaction using @cardano-cli@.
submitTx
:: (MonadTest m, MonadCatch m, MonadIO m)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{-# LANGUAGE TypeApplications #-}

module Cardano.Testnet.Test.Gov.UpdateCommittee
( hprop_epoch_state_update_committee
( hprop_gov_update_committee
) where

import Cardano.Api as Api
Expand All @@ -22,9 +22,11 @@ import Control.Monad
import Data.Bifunctor
import qualified Data.ByteString.Char8 as BSC
import qualified Data.Map.Strict as Map
import qualified Data.Text as Text
import System.FilePath ((</>))

import Testnet.Components.Configuration
import Testnet.Components.DReps
import Testnet.Components.Query
import Testnet.Components.TestWatchdog
import Testnet.Defaults
Expand All @@ -42,8 +44,8 @@ import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as IO
-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/UpdateCommittee/"'@
-- Generate a testnet with a committee defined in the Conway genesis. Add and remove members from the committee
-- in a single governance proposal.
hprop_epoch_state_update_committee :: Property
hprop_epoch_state_update_committee = H.integrationWorkspace "update-committee" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do
hprop_gov_update_committee :: Property
hprop_gov_update_committee = H.integrationWorkspace "update-committee" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do
-- Start a local test net
conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath'
let tempAbsPath' = unTmpAbsPath tempAbsPath
Expand Down Expand Up @@ -114,7 +116,7 @@ hprop_epoch_state_update_committee = H.integrationWorkspace "update-committee" $
TestnetRuntime
{ testnetMagic
, poolNodes
, wallets=_wallet0:_wallet1:_
, wallets=wallet0:_wallet1:_
, configurationFile
} <- cardanoTestnet
fastTestnetOptions
Expand Down Expand Up @@ -159,13 +161,37 @@ hprop_epoch_state_update_committee = H.integrationWorkspace "update-committee" $
}
void $ H.execCli' execConfig $
[ eraToString era, "governance", "action", "update-committee"
, "--testnet"
, "--governance-action-deposit", show @Integer 1_000_000 --- TODO: Get from protocol parameters
, "--deposit-return-stake-verification-key-file", stakeVkeyFp
, "--anchor-url", "https://tinyurl.com/3wrwb2as"
, "--anchor-data-hash", proposalAnchorDataHash
, "--add-cc-cold-verification-key-file", committeeVkey3Fp
, "--epoch", "1000"
, "--threshold", "0.5"
, "--out-file", proposalFile
]

txbodyFp <- H.note $ work </> "tx.body"
epochStateView <- getEpochStateView (File configurationFile) (File socketPath)

txin1 <- findLargestUtxoForPaymentKey epochStateView sbe wallet0

void $ H.execCli' execConfig
[ eraToString era, "transaction", "build"
, "--change-address", Text.unpack $ paymentKeyInfoAddr wallet0
, "--tx-in", Text.unpack $ renderTxIn txin1
, "--tx-out", Text.unpack (paymentKeyInfoAddr wallet0) <> "+" <> show @Int 5_000_000
, "--proposal-file", proposalFile
, "--out-file", txbodyFp
]

signedProposalTx <- signTx execConfig cEra work "signed-proposal"
(File txbodyFp) [paymentKeyInfoPair wallet0]

submitTx execConfig cEra signedProposalTx

-- Confirm the proposal has been ratified

return ()

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import qualified Cardano.Testnet.Test.Gov.ProposeNewConstitution
import qualified Cardano.Testnet.Test.Gov.ProposeNewConstitutionSPO as LedgerEvents
import qualified Cardano.Testnet.Test.Gov.TreasuryGrowth as LedgerEvents
import qualified Cardano.Testnet.Test.Gov.TreasuryWithdrawal as LedgerEvents
import qualified Cardano.Testnet.Test.Gov.UpdateCommittee
import qualified Cardano.Testnet.Test.Node.Shutdown
import qualified Cardano.Testnet.Test.SanityCheck as LedgerEvents
import qualified Cardano.Testnet.Test.SubmitApi.Babbage.Transaction
Expand Down Expand Up @@ -47,7 +48,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.Gov.ProposeNewConstitution.hprop_ledger_events_propose_new_constitution
[ H.ignoreOnMacAndWindows "UpdateCommittee" Cardano.Testnet.Test.Gov.UpdateCommittee.hprop_gov_update_committee
, H.ignoreOnMacAndWindows "ProposeAndRatifyNewConstitution" Cardano.Testnet.Test.Gov.ProposeNewConstitution.hprop_ledger_events_propose_new_constitution
-- 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" Cardano.Testnet.Test.Gov.DRepDeposits.hprop_ledger_events_drep_deposits
Expand Down

0 comments on commit 1982762

Please sign in to comment.