Skip to content

Commit 0e9b91e

Browse files
committed
cardano-testnet | Refactor: remove remaining hardcoded key deposits
1 parent f557aeb commit 0e9b91e

File tree

5 files changed

+17
-21
lines changed

5 files changed

+17
-21
lines changed

cardano-testnet/src/Testnet/Components/Query.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import Cardano.Ledger.Api (ConwayGovState)
4949
import qualified Cardano.Ledger.Api as L
5050
import qualified Cardano.Ledger.Coin as L
5151
import qualified Cardano.Ledger.Conway.Governance as L
52-
import Cardano.Ledger.Conway.PParams (ConwayEraPParams)
5352
import qualified Cardano.Ledger.Conway.PParams as L
5453
import qualified Cardano.Ledger.Shelley.LedgerState as L
5554
import qualified Cardano.Ledger.UTxO as L

cardano-testnet/src/Testnet/Process/Cli/SPO.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,10 @@ createStakeKeyRegistrationCertificate
180180
=> TmpAbsolutePath
181181
-> AnyShelleyBasedEra
182182
-> File (VKey StakeKey) In -- ^ Stake verification key file
183-
-> Int -- ^ deposit amount used only in Conway
183+
-> L.Coin -- ^ deposit amount used only in Conway
184184
-> FilePath -- ^ Output file path
185185
-> m ()
186-
createStakeKeyRegistrationCertificate tempAbsP asbe (File stakeVerKey) deposit outputFp = GHC.withFrozenCallStack $ do
187-
AnyShelleyBasedEra sbe <- return asbe
186+
createStakeKeyRegistrationCertificate tempAbsP (AnyShelleyBasedEra sbe) (File stakeVerKey) (L.Coin deposit) outputFp = GHC.withFrozenCallStack $ do
188187
let tempAbsPath' = unTmpAbsPath tempAbsP
189188
extraArgs = monoidForEraInEon @ConwayEraOnwards (toCardanoEra sbe) $
190189
const ["--key-reg-deposit-amt", show deposit]
@@ -221,11 +220,11 @@ createStakeKeyDeregistrationCertificate
221220
:: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack)
222221
=> TmpAbsolutePath
223222
-> ShelleyBasedEra era
224-
-> FilePath -- ^ Stake verification key file
223+
-> File (VKey StakeKey) In -- ^ Stake verification key file
225224
-> Int -- ^ deposit amount used only in Conway
226225
-> FilePath -- ^ Output file path
227226
-> m ()
228-
createStakeKeyDeregistrationCertificate tempAbsP sbe stakeVerKey deposit outputFp =
227+
createStakeKeyDeregistrationCertificate tempAbsP sbe (File stakeVerKey) deposit outputFp =
229228
GHC.withFrozenCallStack $ do
230229
let tempAbsPath' = unTmpAbsPath tempAbsP
231230
extraArgs = monoidForEraInEon @ConwayEraOnwards (toCardanoEra sbe) $
@@ -248,17 +247,18 @@ registerSingleSpo
248247
-> SocketPath
249248
-> EpochNo -- ^ Termination epoch
250249
-> Int -- ^ Testnet magic
250+
-> L.Coin -- ^ key deposit
251251
-> ExecConfig
252-
-> (TxIn, FilePath, String)
252+
-> (TxIn, File (SKey PaymentKey) In, String)
253253
-> m ( String
254254
, KeyPair StakeKey
255255
, KeyPair VrfKey
256256
) -- ^ Result tuple:
257257
-- 1. String: Registered stake pool ID
258258
-- 2. Stake pool cold keys
259259
-- 3. Stake pool VRF keys
260-
registerSingleSpo asbe identifier tap@(TmpAbsolutePath tempAbsPath') nodeConfigFile socketPath termEpoch testnetMag execConfig
261-
(fundingInput, fundingSigninKey, changeAddr) = GHC.withFrozenCallStack $ do
260+
registerSingleSpo asbe identifier tap@(TmpAbsolutePath tempAbsPath') nodeConfigFile socketPath termEpoch testnetMag keyDeposit execConfig
261+
(fundingInput, File fundingSigninKey, changeAddr) = GHC.withFrozenCallStack $ do
262262
workDir <- H.note tempAbsPath'
263263

264264
-- In order to register a stake pool we need two certificates:
@@ -344,7 +344,7 @@ registerSingleSpo asbe identifier tap@(TmpAbsolutePath tempAbsPath') nodeConfigF
344344
-- Create pledger registration certificate
345345
createStakeKeyRegistrationCertificate tap asbe
346346
(verificationKey poolOwnerStakeKeys)
347-
400_000
347+
keyDeposit
348348
(workDir </> "pledger.regcert")
349349

350350
void $ execCli' execConfig

cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/KesPeriodInfo.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ module Cardano.Testnet.Test.Cli.KesPeriodInfo
1212
) where
1313

1414
import Cardano.Api as Api
15-
import Cardano.Api.Ledger (Coin (..))
1615

1716
import Cardano.CLI.Types.Output
1817
import Cardano.Node.Configuration.Topology
@@ -79,7 +78,7 @@ hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbs
7978

8079
-- We get our UTxOs from here
8180
let utxoAddr = Text.unpack $ paymentKeyInfoAddr wallet0
82-
utxoSKeyFile = signingKeyFp $ paymentKeyInfoPair wallet0
81+
utxoSKeyFile = signingKey $ paymentKeyInfoPair wallet0
8382
void $ execCli' execConfig
8483
[ eraString, "query", "utxo"
8584
, "--address", utxoAddr
@@ -94,12 +93,14 @@ hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbs
9493
let node1SocketPath = Api.File $ IO.sprocketSystemName node1sprocket
9594
termEpoch = EpochNo 3
9695
epochStateView <- getEpochStateView configurationFile node1SocketPath
96+
keyDeposit <- getKeyDeposit epochStateView ceo
9797
(stakePoolId, KeyPair{signingKey=File stakePoolColdSigningKey, verificationKey=File stakePoolColdVKey}, _)
9898
<- registerSingleSpo asbe 1 tempAbsPath
9999
configurationFile
100100
node1SocketPath
101101
termEpoch
102102
testnetMagic
103+
keyDeposit
103104
execConfig
104105
(txin1, utxoSKeyFile, utxoAddr)
105106

@@ -141,7 +142,6 @@ hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbs
141142
, "--testnet-magic", show @Int testnetMagic
142143
]
143144

144-
keyDeposit <- fromIntegral . unCoin <$> getKeyDeposit epochStateView ceo
145145
-- Test stake address registration cert
146146
createStakeKeyRegistrationCertificate
147147
tempAbsPath
@@ -193,7 +193,7 @@ hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbs
193193
[ "latest", "transaction", "sign"
194194
, "--tx-body-file", delegRegTestDelegatorTxBodyFp
195195
, "--testnet-magic", show @Int testnetMagic
196-
, "--signing-key-file", utxoSKeyFile
196+
, "--signing-key-file", unFile utxoSKeyFile
197197
, "--signing-key-file", signingKeyFp testDelegatorKeys
198198
, "--out-file", delegRegTestDelegatorTxFp
199199
]

cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/LeadershipSchedule.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module Cardano.Testnet.Test.Cli.LeadershipSchedule
1515

1616
import Cardano.Api
1717
import qualified Cardano.Api as Api
18-
import Cardano.Api.Ledger (Coin (..))
1918

2019
import Cardano.Node.Configuration.Topology
2120
import Cardano.Testnet
@@ -87,7 +86,7 @@ hprop_leadershipSchedule = integrationRetryWorkspace 2 "leadership-schedule" $ \
8786

8887
----------------Need to register an SPO------------------
8988
let utxoAddr = Text.unpack $ paymentKeyInfoAddr wallet0
90-
utxoSKeyFile = signingKeyFp $ paymentKeyInfoPair wallet0
89+
utxoSKeyFile = signingKey $ paymentKeyInfoPair wallet0
9190
void $ execCli' execConfig
9291
[ eraString, "query", "utxo"
9392
, "--address", utxoAddr
@@ -101,12 +100,14 @@ hprop_leadershipSchedule = integrationRetryWorkspace 2 "leadership-schedule" $ \
101100
let node1SocketPath = Api.File $ IO.sprocketSystemName node1sprocket
102101
termEpoch = EpochNo 15
103102
epochStateView <- getEpochStateView configurationFile node1SocketPath
103+
keyDeposit <- getKeyDeposit epochStateView ceo
104104
(stakePoolIdNewSpo, KeyPair{signingKey=File stakePoolColdSigningKey, verificationKey=File stakePoolColdVKey}, KeyPair{signingKey=File vrfSkey})
105105
<- registerSingleSpo asbe 1 tempAbsPath
106106
configurationFile
107107
node1SocketPath
108108
(EpochNo 10)
109109
testnetMagic
110+
keyDeposit
110111
execConfig
111112
(txin1, utxoSKeyFile, utxoAddr)
112113

@@ -146,7 +147,6 @@ hprop_leadershipSchedule = integrationRetryWorkspace 2 "leadership-schedule" $ \
146147
, "--testnet-magic", show @Int testnetMagic
147148
]
148149

149-
keyDeposit <- fromIntegral . unCoin <$> getKeyDeposit epochStateView ceo
150150
-- Test stake address registration cert
151151
createStakeKeyRegistrationCertificate
152152
tempAbsPath
@@ -198,7 +198,7 @@ hprop_leadershipSchedule = integrationRetryWorkspace 2 "leadership-schedule" $ \
198198
[ "latest", "transaction", "sign"
199199
, "--tx-body-file", delegRegTestDelegatorTxBodyFp
200200
, "--testnet-magic", show @Int testnetMagic
201-
, "--signing-key-file", utxoSKeyFile
201+
, "--signing-key-file", unFile utxoSKeyFile
202202
, "--signing-key-file", signingKeyFp testDelegatorKeys
203203
, "--out-file", delegRegTestDelegatorTxFp
204204
]

cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Transaction/RegisterDeregisterStakeAddress.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ hprop_tx_register_deregister_stake_address = integrationWorkspace "register-dere
5959

6060
let ceo = ConwayEraOnwardsConway
6161
sbe = conwayEraOnwardsToShelleyBasedEra ceo
62-
era = toCardanoEra sbe
63-
cEra = AnyCardanoEra era
6462
eraName = eraToString sbe
6563
fastTestnetOptions = def { cardanoNodeEra = AnyShelleyBasedEra sbe }
6664
shelleyOptions = def { genesisEpochLength = 200 }
@@ -144,7 +142,6 @@ hprop_tx_register_deregister_stake_address = integrationWorkspace "register-dere
144142
]
145143

146144
H.noteShowM_ $ waitForBlocks epochStateView 1
147-
-- H.noteShowM_ $ waitForEpochs epochStateView (EpochInterval 2)
148145

149146
do
150147
(_, stdout', stderr') <- execCliAny execConfig

0 commit comments

Comments
 (0)