Skip to content

Commit

Permalink
SCP-4465 refactor attribute names for ScriptTest
Browse files Browse the repository at this point in the history
  • Loading branch information
ladamesny committed Sep 23, 2022
1 parent 6391534 commit 8501085
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
14 changes: 7 additions & 7 deletions marlowe-cli/src/Language/Marlowe/CLI/Test.hs
Expand Up @@ -42,7 +42,7 @@ import Control.Monad.Reader (ReaderT(runReaderT), runReader)
import Language.Marlowe.CLI.Cardano.Api (toPlutusProtocolVersion)
import Language.Marlowe.CLI.IO (decodeFileStrict, getDefaultCostModel, queryInEra, readSigningKey)
import Language.Marlowe.CLI.Test.Script (scriptTest)
import Language.Marlowe.CLI.Test.Types (MarloweTests (..), Wallet (Wallet), ExecutionMode)
import Language.Marlowe.CLI.Test.Types (ExecutionMode, MarloweTests(..), Wallet(Wallet))
import Language.Marlowe.CLI.Transaction (querySlotConfig)
import Language.Marlowe.CLI.Types (CliEnv(CliEnv), CliError(..), SigningKeyFile(SigningKeyFile))
import qualified Language.Marlowe.CLI.Types as T
Expand All @@ -65,16 +65,16 @@ runTests era ScriptTests{..} =
LocalNodeConnectInfo
{
localConsensusModeParams = CardanoModeParams $ EpochSlots 21600
, localNodeNetworkId = network
, localNodeSocketPath = socketPath
, localNodeNetworkId = stNetwork
, localNodeSocketPath = stSocketPath
}
protocol <- runCli $ queryInEra connection C.QueryProtocolParameters
faucetSigningKey <- readSigningKey (SigningKeyFile faucetSigningKeyFile)
faucetSigningKey <- readSigningKey (SigningKeyFile stFaucetSigningKeyFile)
let
protocolVersion = toPlutusProtocolVersion $ protocolParamProtocolVersion protocol
faucet = Wallet faucetAddress faucetSigningKey mempty mempty
faucet = Wallet stFaucetAddress faucetSigningKey mempty mempty

slotConfig <- runCli $ querySlotConfig connection
tests' <- mapM decodeFileStrict tests
mapM_ (scriptTest era protocolVersion costModel connection faucet slotConfig executionMode) tests'
tests' <- mapM decodeFileStrict stTests
mapM_ (scriptTest era protocolVersion costModel connection faucet slotConfig stExecutionMode) tests'

16 changes: 8 additions & 8 deletions marlowe-cli/src/Language/Marlowe/CLI/Test/Script.hs
Expand Up @@ -147,10 +147,10 @@ import qualified Plutus.V1.Ledger.Value as P
import qualified Plutus.V1.Ledger.Value as Value


timeoutForExecutionMode :: MonadError CliError m
timeoutForOnChainMode :: MonadError CliError m
=> MonadReader (ScriptEnv era) m
=> m (Maybe Int)
timeoutForExecutionMode = do
timeoutForOnChainMode = do
executionMode <- view seExecutionMode
let
executionTimeout = case executionMode of
Expand Down Expand Up @@ -184,7 +184,7 @@ interpret FundWallet {..} = do
(Wallet faucetAddress faucetSigningKey _ _) <- getFaucet
(Wallet address _ _ _) <- findWallet soWalletNickname
connection <- view seConnection
timeout <- timeoutForExecutionMode
timeout <- timeoutForOnChainMode
txBody <- runCli "[FundWallet] " $ buildFaucetImpl
connection
values
Expand All @@ -203,7 +203,7 @@ interpret FundWallet {..} = do
interpret SplitWallet {..} = do
Wallet address skey _ _ <- findWallet soWalletNickname
connection <- view seConnection
timeout <- timeoutForExecutionMode
timeout <- timeoutForOnChainMode
let
values = [ C.lovelaceToValue v | v <- soValues ]

Expand All @@ -230,7 +230,7 @@ interpret so@Mint {..} = do
pure ((tokenName, amount, Just destAddress), (nickname, wallet, tokenName, amount))
logSoMsg' so $ "Minting currency " <> show soCurrencyNickname <> " with tokens distribution: " <> show soTokenDistribution
connection <- view seConnection
timeout <- timeoutForExecutionMode
timeout <- timeoutForOnChainMode
(_, policy) <- runCli "[Mint] " $ buildMintingImpl
connection
faucetSigningKey
Expand Down Expand Up @@ -344,7 +344,7 @@ interpret Prepare {..} = do
modifying ssContracts $ Map.insert soContractNickname marloweContract'

interpret so@AutoRun {..} = do
timeoutForExecutionMode >>= \case
timeoutForOnChainMode >>= \case
Nothing -> logSoMsg' so "Execution Mode set to 'Simulation' - Transactions are not submitted to chain in simulation mode"
(Just _) -> do
marloweContract@MarloweContract {..} <- findMarloweContract soContractNickname
Expand Down Expand Up @@ -404,7 +404,7 @@ interpret so@Publish {..} = do

pure marloweScriptRefs
Nothing -> do
timeoutForExecutionMode >>= \case
timeoutForOnChainMode >>= \case
Nothing -> throwSoError so "Can't perform on chain script publishing in simulation mode"
(Just timeout) -> do
logSoMsg' so "Scripts not found so publishing them."
Expand Down Expand Up @@ -468,7 +468,7 @@ autoRunTransaction currency defaultSubmitter prev curr@T.MarloweTransaction {..}
Nothing -> throwError "[autoRunTransaction] Contract requires a role currency which was not specified."

connection <- view seConnection
timeout <- timeoutForExecutionMode
timeout <- timeoutForOnChainMode
txBody <- runCli "[AutoRun] " $ autoRunTransactionImpl
connection
prev
Expand Down
14 changes: 7 additions & 7 deletions marlowe-cli/src/Language/Marlowe/CLI/Test/Types.hs
Expand Up @@ -104,13 +104,13 @@ data MarloweTests era a =
-- | Test contracts on-chain.
ScriptTests
{
network :: NetworkId -- ^ The network ID, if any.
, socketPath :: FilePath -- ^ The path to the node socket.
, faucetSigningKeyFile :: FilePath -- ^ The file containing the faucet's signing key.
, faucetAddress :: AddressInEra era -- ^ The faucet address.
, burnAddress :: AddressInEra era -- ^ The address to which to send unneeded native tokens.
, executionMode :: ExecutionMode
, tests :: [a] -- ^ Input for the tests.
stNetwork :: NetworkId -- ^ The network ID, if any.
, stSocketPath :: FilePath -- ^ The path to the node socket.
, stFaucetSigningKeyFile :: FilePath -- ^ The file containing the faucet's signing key.
, stFaucetAddress :: AddressInEra era -- ^ The faucet address.
, stBurnAddress :: AddressInEra era -- ^ The address to which to send unneeded native tokens.
, stExecutionMode :: ExecutionMode
, stTests :: [a] -- ^ Input for the tests.
}
deriving stock (Eq, Generic, Show)

Expand Down

0 comments on commit 8501085

Please sign in to comment.