Skip to content

Commit

Permalink
Fixes required by rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Apr 23, 2024
1 parent 778f3c0 commit c300e9c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
16 changes: 9 additions & 7 deletions cardano-testnet/src/Testnet/Components/DReps.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ module Testnet.Components.DReps
, getLastPParamUpdateActionId
) where

import Cardano.Api (AnyCardanoEra (..), ConwayEra, EpochNo (EpochNo), FileDirection (In),
MonadIO, ShelleyBasedEra (..), ToCardanoEra (toCardanoEra), renderTxIn)
import Cardano.Api (AnyCardanoEra (..), ConwayEra, ConwayEraOnwards, EpochNo (EpochNo),
FileDirection (In), MonadIO, ShelleyBasedEra (..), ToCardanoEra (toCardanoEra),
conwayEraOnwardsToShelleyBasedEra, renderTxIn)

import Cardano.CLI.Types.Common (File (..))

Expand Down Expand Up @@ -366,7 +367,7 @@ retrieveTransactionId execConfig signedTxBody = do
-- using the 'getEpochStateView' function.
-- * 'configurationFile': Path to the node configuration file as returned by 'cardanoTestnetDefault'.
-- * 'socketPath': Path to the cardano-node unix socket file.
-- * 'sbe': The Shelley-based era (e.g., 'ShelleyBasedEraConway') in which the transaction will be constructed.
-- * 'sbe': The conway era onwards witness for the era in which the transaction will be constructed.
-- * 'work': Base directory path where the signed transaction file will be stored.
-- * 'prefix': Name for the subfolder that will be created under 'work' folder to store the output keys.
-- * 'wallet': Payment key information associated with the transaction,
Expand All @@ -376,16 +377,17 @@ retrieveTransactionId execConfig signedTxBody = do
registerDRep :: (MonadCatch m, MonadIO m, MonadTest m, H.MonadAssertion m)
=> H.ExecConfig
-> EpochStateView
-> ShelleyBasedEra ConwayEra
-> ConwayEraOnwards ConwayEra
-> FilePath
-> FilePath
-> PaymentKeyInfo
-> m PaymentKeyPair
registerDRep execConfig epochStateView sbe work prefix wallet = do
let era = toCardanoEra sbe
registerDRep execConfig epochStateView ceo work prefix wallet = do
let sbe = conwayEraOnwardsToShelleyBasedEra ceo
era = toCardanoEra sbe
cEra = AnyCardanoEra era

minDRepDeposit <- getMinDRepDeposit execConfig
minDRepDeposit <- getMinDRepDeposit execConfig ceo

baseDir <- H.createDirectoryIfMissing $ work </> prefix
drepKeyPair <- generateDRepKeyPair execConfig baseDir "keys"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ hprop_check_drep_activity = H.integrationWorkspace "test-activity" $ \tempAbsBas

work <- H.createDirectoryIfMissing $ tempAbsPath' </> "work"

let sbe = ShelleyBasedEraConway
let ceo = ConwayEraOnwardsConway
sbe = conwayEraOnwardsToShelleyBasedEra ceo
era = toCardanoEra sbe
cEra = AnyCardanoEra era
fastTestnetOptions = cardanoDefaultTestnetOptions
Expand Down Expand Up @@ -94,15 +95,15 @@ hprop_check_drep_activity = H.integrationWorkspace "test-activity" $ \tempAbsBas
gov <- H.createDirectoryIfMissing $ work </> "governance"

-- This proposal should pass
void $ activityChangeProposalTest execConfig epochStateView configurationFile socketPath sbe gov
void $ activityChangeProposalTest execConfig epochStateView configurationFile socketPath ceo gov
"firstProposal" wallet0 [(1, "yes")] 3 (Just 3) 3

-- Now we register two new DReps
drep2 <- registerDRep execConfig epochStateView sbe work "drep2" wallet1
drep2 <- registerDRep execConfig epochStateView ceo work "drep2" wallet1
delegateToDRep execConfig epochStateView configurationFile socketPath sbe work "drep2-delegation"
wallet2 (defaultDelegatorStakeKeyPair 2) drep2

drep3 <- registerDRep execConfig epochStateView sbe work "drep3" wallet0
drep3 <- registerDRep execConfig epochStateView ceo work "drep3" wallet0
delegateToDRep execConfig epochStateView configurationFile socketPath sbe work "drep3-delegation"
wallet1 (defaultDelegatorStakeKeyPair 3) drep3

Expand All @@ -112,14 +113,14 @@ hprop_check_drep_activity = H.integrationWorkspace "test-activity" $ \tempAbsBas

-- This proposal should fail because there is 2 DReps that don't vote (out of 3)
-- and we have the stake distributed evenly
void $ activityChangeProposalTest execConfig epochStateView configurationFile socketPath sbe gov
void $ activityChangeProposalTest execConfig epochStateView configurationFile socketPath ceo gov
"failingProposal" wallet2 [(1, "yes")] 4 (Just 3) 3

-- We now send a bunch of proposals to make sure that the 2 new DReps expire.
-- because DReps won't expire if there is not enough activity (opportunites to participate).
-- This is accounted for by the dormant epoch count
sequence_
[activityChangeProposalTest execConfig epochStateView configurationFile socketPath sbe gov
[activityChangeProposalTest execConfig epochStateView configurationFile socketPath ceo gov
("fillerProposalNum" ++ show proposalNum) wallet [(1, "yes")]
(fromIntegral $ 4 + proposalNum) Nothing 3
| (proposalNum, wallet) <- zip [1..(4 :: Int)] (cycle [wallet0, wallet1, wallet2])]
Expand All @@ -129,7 +130,7 @@ hprop_check_drep_activity = H.integrationWorkspace "test-activity" $ \tempAbsBas

-- Last proposal (set activity to something else again and it should pass, because of inactivity)
-- Because 2 out of 3 DReps were inactive, prop should pass
void $ activityChangeProposalTest execConfig epochStateView configurationFile socketPath sbe gov
void $ activityChangeProposalTest execConfig epochStateView configurationFile socketPath ceo gov
"lastProposal" wallet0 [(1, "yes")] 9 (Just 9) 3

activityChangeProposalTest
Expand All @@ -138,7 +139,7 @@ activityChangeProposalTest
-> EpochStateView
-> FilePath
-> FilePath
-> ShelleyBasedEra ConwayEra
-> ConwayEraOnwards ConwayEra
-> FilePath
-> FilePath
-> PaymentKeyInfo
Expand All @@ -147,8 +148,11 @@ activityChangeProposalTest
-> Maybe Integer
-> Word64
-> m (String, Word32)
activityChangeProposalTest execConfig epochStateView configurationFile socketPath sbe work prefix
activityChangeProposalTest execConfig epochStateView configurationFile socketPath ceo work prefix
wallet votes change mExpected epochsToWait = do

let sbe = conwayEraOnwardsToShelleyBasedEra ceo

mPreviousProposalInfo <- getLastPParamUpdateActionId execConfig

baseDir <- H.createDirectoryIfMissing $ work </> prefix
Expand All @@ -161,7 +165,7 @@ activityChangeProposalTest execConfig epochStateView configurationFile socketPat

thisProposal@(governanceActionTxId, governanceActionIndex) <-
makeActivityChangeProposal execConfig epochStateView (File configurationFile) (File socketPath)
sbe baseDir "proposal" mPreviousProposalInfo change wallet
ceo baseDir "proposal" mPreviousProposalInfo change wallet

voteChangeProposal execConfig epochStateView sbe baseDir "vote"
governanceActionTxId governanceActionIndex propVotes wallet
Expand All @@ -183,17 +187,18 @@ makeActivityChangeProposal
-> EpochStateView
-> NodeConfigFile 'In
-> SocketPath
-> ShelleyBasedEra ConwayEra
-> ConwayEraOnwards ConwayEra
-> FilePath
-> String
-> Maybe (String, Word32)
-> Word32
-> PaymentKeyInfo
-> m (String, Word32)
makeActivityChangeProposal execConfig epochStateView configurationFile socketPath
sbe work prefix prevGovActionInfo drepActivity wallet = do
ceo work prefix prevGovActionInfo drepActivity wallet = do

let era = toCardanoEra sbe
let sbe = conwayEraOnwardsToShelleyBasedEra ceo
era = toCardanoEra sbe
cEra = AnyCardanoEra era

baseDir <- H.createDirectoryIfMissing $ work </> prefix
Expand All @@ -214,7 +219,7 @@ makeActivityChangeProposal execConfig epochStateView configurationFile socketPat
, "hash", "anchor-data", "--file-text", proposalAnchorFile
]

minDRepDeposit <- getMinDRepDeposit execConfig
minDRepDeposit <- getMinDRepDeposit execConfig ceo

proposalFile <- H.note $ baseDir </> "sample-proposFal-anchor"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ hprop_ledger_events_drep_deposits = H.integrationWorkspace "drep-deposits" $ \te

-- DRep 2 (enough deposit)

void $ registerDRep execConfig epochStateView sbe work "drep2" wallet1
void $ registerDRep execConfig epochStateView ceo work "drep2" wallet1

checkDRepState sbe (File configurationFile) (File socketPath) execConfig
(\m -> if map L.drepDeposit (Map.elems m) == [L.Coin minDRepDeposit] then Just () else Nothing)
Expand Down

0 comments on commit c300e9c

Please sign in to comment.