Skip to content

Commit

Permalink
Finish implementation of 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 6abeb7f commit 282eef9
Show file tree
Hide file tree
Showing 3 changed files with 245 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ import GHC.Stack (callStack)
import Lens.Micro ((^?))
import System.FilePath ((</>))

import qualified Testnet.Components.DReps as DRep
import Testnet.Components.DReps (createCertificatePublicationTxBody, createVotingTxBody,
generateVoteFiles, retrieveTransactionId, signTx, submitTx)
retrieveTransactionId, signTx, submitTx)
import Testnet.Components.Query (EpochStateView, findLargestUtxoForPaymentKey,
getCurrentEpochNo, getEpochStateView, getMinDRepDeposit)
import Testnet.Defaults (defaultDRepKeyPair, defaultDelegatorStakeKeyPair)
import qualified Testnet.Components.SPO as SPO
import Testnet.Defaults (defaultDRepKeyPair, defaultDelegatorStakeKeyPair, defaultSPOKeys)
import qualified Testnet.Process.Cli as P
import qualified Testnet.Process.Run as H
import qualified Testnet.Property.Utils as H
Expand Down Expand Up @@ -209,7 +211,7 @@ desiredPoolNumberProposalTest execConfig epochStateView configurationFile socket
ceo baseDir "proposal" previousProposalInfo (fromIntegral change) wallet

voteChangeProposal execConfig epochStateView sbe baseDir "vote"
governanceActionTxId governanceActionIndex propVotes wallet
governanceActionTxId governanceActionIndex propVotes [] wallet

(EpochNo epochAfterProp) <- getCurrentEpochNo epochStateView
H.note_ $ "Epoch after \"" <> prefix <> "\" prop: " <> show epochAfterProp
Expand Down Expand Up @@ -319,26 +321,42 @@ voteChangeProposal :: (MonadTest m, MonadIO m, MonadCatch m, H.MonadAssertion m)
-> FilePath
-> String
-> Word32
-> [([Char], Int)]
-> [(String, Int)]
-> [(String, Int)]
-> PaymentKeyInfo
-> m ()
voteChangeProposal execConfig epochStateView sbe work prefix governanceActionTxId governanceActionIndex votes wallet = do
voteChangeProposal execConfig epochStateView sbe work prefix governanceActionTxId governanceActionIndex drepVotes spoVotes wallet = do
baseDir <- H.createDirectoryIfMissing $ work </> prefix

let era = toCardanoEra sbe
cEra = AnyCardanoEra era

voteFiles <- generateVoteFiles execConfig baseDir "vote-files"
governanceActionTxId governanceActionIndex
[(defaultDRepKeyPair idx, vote) | (vote, idx) <- votes]
drepVoteFiles <- DRep.generateVoteFiles execConfig baseDir "drep-vote-files"
governanceActionTxId governanceActionIndex
[(defaultDRepKeyPair idx, vote) | (vote, idx) <- drepVotes]

spoVoteFiles <- SPO.generateVoteFiles execConfig baseDir "spo-vote-files"
governanceActionTxId governanceActionIndex
[(defaultSPOKeys idx, vote) | (vote, idx) <- spoVotes]

let voteFiles = drepVoteFiles ++ spoVoteFiles

voteTxBodyFp <- createVotingTxBody execConfig epochStateView sbe baseDir "vote-tx-body"
voteFiles wallet

voteTxFp <- signTx execConfig cEra baseDir "signed-vote-tx" voteTxBodyFp
(paymentKeyInfoPair wallet:[defaultDRepKeyPair n | (_, n) <- votes])
(paymentKeyInfoPair wallet:
[defaultDRepKeyPair n | (_, n) <- drepVotes] ++
[defaultSPOColdKeyPair n | (_, n) <- drepVotes]
)
submitTx execConfig cEra voteTxFp

defaultSPOColdKeyPair :: Int -> PaymentKeyPair
defaultSPOColdKeyPair n = PaymentKeyPair { paymentVKey = poolNodeKeysColdVkey spoKeys
, paymentSKey = poolNodeKeysColdSkey spoKeys
}
where spoKeys = defaultSPOKeys n

getDesiredPoolNumberValue :: (MonadTest m, MonadCatch m, MonadIO m) => H.ExecConfig -> m Integer
getDesiredPoolNumberValue execConfig = do
govStateString <- H.execCli' execConfig
Expand Down

0 comments on commit 282eef9

Please sign in to comment.