Skip to content

Commit

Permalink
Apply suggestions from code review by @carbolymer
Browse files Browse the repository at this point in the history
Co-authored-by: Mateusz Galazyn <[email protected]>
  • Loading branch information
palas and carbolymer committed Aug 7, 2024
1 parent 7b6f3f9 commit a43008d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions cardano-testnet/src/Testnet/Process/Cli/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{-# LANGUAGE ScopedTypeVariables #-}

module Testnet.Process.Cli.Transaction
( simpleSpendOutputsOnlyTx
, spendOutputsOnlyTx
( mkSimpleSpendOutputsOnlyTx
, mkSpendOutputsOnlyTx
, signTx
, submitTx
, failToSubmitTx
Expand Down Expand Up @@ -57,7 +57,7 @@ data TxOutAddress = PubKeyAddress PaymentKeyInfo
--
-- Returns the generated @File TxBody In@ file path to the created unsigned
-- transaction file.
spendOutputsOnlyTx
mkSpendOutputsOnlyTx
:: HasCallStack
=> Typeable era
=> H.MonadAssertion m
Expand All @@ -73,7 +73,7 @@ spendOutputsOnlyTx
-> PaymentKeyInfo -- ^ Payment key pair used for paying the transaction.
-> [(TxOutAddress, Coin)] -- ^ List of pairs of transaction output addresses and amounts.
-> m (File TxBody In)
spendOutputsOnlyTx execConfig epochStateView sbe work prefix srcWallet txOutputs = do
mkSpendOutputsOnlyTx execConfig epochStateView sbe work prefix srcWallet txOutputs = do

txIn <- findLargestUtxoForPaymentKey epochStateView sbe srcWallet
fixedTxOuts :: [String] <- computeTxOuts
Expand Down Expand Up @@ -109,7 +109,7 @@ spendOutputsOnlyTx execConfig epochStateView sbe work prefix srcWallet txOutputs
--
-- Returns the generated @File TxBody In@ file path to the created unsigned
-- transaction file.
simpleSpendOutputsOnlyTx
mkSimpleSpendOutputsOnlyTx
:: HasCallStack
=> Typeable era
=> H.MonadAssertion m
Expand All @@ -126,8 +126,8 @@ simpleSpendOutputsOnlyTx
-> PaymentKeyInfo -- ^ Payment key of the recipient of the transaction.
-> Coin -- ^ Amount of ADA to transfer (in Lovelace).
-> m (File TxBody In)
simpleSpendOutputsOnlyTx execConfig epochStateView sbe work prefix srcWallet dstWallet amount =
spendOutputsOnlyTx execConfig epochStateView sbe work prefix srcWallet [(PubKeyAddress dstWallet, amount)]
mkSimpleSpendOutputsOnlyTx execConfig epochStateView sbe work prefix srcWallet dstWallet amount =
mkSpendOutputsOnlyTx execConfig epochStateView sbe work prefix srcWallet [(PubKeyAddress dstWallet, amount)]

-- | Calls @cardano-cli@ to signs a transaction body using the specified key pairs.
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import Testnet.Components.Query (checkDRepsNumber, getEpochStateView,
watchEpochStateUpdate, EpochStateView)
import qualified Testnet.Defaults as Defaults
import Testnet.Process.Cli.Transaction (TxOutAddress (ReferenceScriptAddress),
retrieveTransactionId, signTx, simpleSpendOutputsOnlyTx, spendOutputsOnlyTx,
retrieveTransactionId, signTx, mkSimpleSpendOutputsOnlyTx, mkSpendOutputsOnlyTx,
submitTx)
import Testnet.Process.Run (execCli', execCliStdoutToJson, mkExecConfig)
import Testnet.Property.Assert (assertErasEqual)
Expand Down Expand Up @@ -112,7 +112,7 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H.

checkDRepsNumber epochStateView sbe 3

-- If we don't wait, the leadershi-schedule test will say SPO has no stake
-- If we don't wait, the leadership-schedule test will say SPO has no stake
_ <- waitForEpochs epochStateView (EpochInterval 1)

forallQueryCommands $ \case
Expand Down Expand Up @@ -247,7 +247,7 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H.
H.noteM_ $ execCli' execConfig [ eraName, "query", "tx-mempool", "next-tx" ]
-- Now we create a transaction and check if it exists in the mempool
mempoolWork <- H.createDirectoryIfMissing $ work </> "mempool-test"
txBody <- simpleSpendOutputsOnlyTx execConfig epochStateView sbe mempoolWork "tx-body" wallet0 wallet1 10_000_000
txBody <- mkSimpleSpendOutputsOnlyTx execConfig epochStateView sbe mempoolWork "tx-body" wallet0 wallet1 10_000_000
signedTx <- signTx execConfig cEra mempoolWork "signed-tx" txBody [SomeKeyPair $ paymentKeyInfoPair wallet0]
submitTx execConfig cEra signedTx
txId <- retrieveTransactionId execConfig signedTx
Expand All @@ -267,7 +267,7 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H.
plutusV3Script <- File <$> liftIO (makeAbsolute "test/cardano-testnet-test/files/plutus/v3/always-succeeds.plutus")
let transferAmount = Coin 10_000_000
-- Submit a transaction to publish the reference script
txBody <- spendOutputsOnlyTx execConfig epochStateView sbe refScriptSizeWork "tx-body" wallet1
txBody <- mkSpendOutputsOnlyTx execConfig epochStateView sbe refScriptSizeWork "tx-body" wallet1
[(ReferenceScriptAddress plutusV3Script, transferAmount)]
signedTx <- signTx execConfig cEra refScriptSizeWork "signed-tx" txBody [SomeKeyPair $ paymentKeyInfoPair wallet1]
submitTx execConfig cEra signedTx
Expand Down Expand Up @@ -364,7 +364,7 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H.
minSlotInThisEpochToWaitTo = firstSlotOfEpoch + slotsInEpochToWaitOut + 1
in slotNo >= minSlotInThisEpochToWaitTo

readVerificationKeyFromFile :: (MonadIO m, MonadCatch m, MonadTest m, HasTextEnvelope (VerificationKey keyrole), SerialiseAsBech32 (VerificationKey keyrole))
readVerificationKeyFromFile :: (HasCallStack, MonadIO m, MonadCatch m, MonadTest m, HasTextEnvelope (VerificationKey keyrole), SerialiseAsBech32 (VerificationKey keyrole))
=> AsType keyrole
-> FilePath
-> File content direction
Expand All @@ -376,7 +376,7 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H.
verificationStakeKeyToStakeAddress testnetMagic delegatorVKey =
makeStakeAddress (fromNetworkMagic $ NetworkMagic $ fromIntegral testnetMagic) (StakeCredentialByKey $ verificationKeyHash delegatorVKey)

getTxIx :: forall m era. MonadTest m => ShelleyBasedEra era -> String -> Coin -> (AnyNewEpochState, SlotNo, BlockNo) -> m (Maybe Int)
getTxIx :: forall m era. HasCallStack => MonadTest m => ShelleyBasedEra era -> String -> Coin -> (AnyNewEpochState, SlotNo, BlockNo) -> m (Maybe Int)
getTxIx sbe txId amount (AnyNewEpochState sbe' newEpochState, _, _) = do
Refl <- H.leftFail $ assertErasEqual sbe sbe'
shelleyBasedEraConstraints sbe' (do
Expand Down

0 comments on commit a43008d

Please sign in to comment.