Skip to content

Commit

Permalink
SCP-4327 implement trivial contract template test
Browse files Browse the repository at this point in the history
  • Loading branch information
ladamesny committed Aug 8, 2022
1 parent f6e1195 commit 940a370
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 128 deletions.
16 changes: 1 addition & 15 deletions marlowe-cli/examples/simple/run-simple.sh
Expand Up @@ -75,21 +75,7 @@ BYSTANDER_PREFIX="$TREASURY/christopher-marlowe"
BYSTANDER_NAME="Christopher Marlowe"
BYSTANDER_PAYMENT_SKEY="$BYSTANDER_PREFIX".skey
BYSTANDER_PAYMENT_VKEY="$BYSTANDER_PREFIX".vkey

if [[ ! -e "$BYSTANDER_PAYMENT_SKEY" ]]
then
cardano-cli address key-gen --signing-key-file "$BYSTANDER_PAYMENT_SKEY" \
--verification-key-file "$BYSTANDER_PAYMENT_VKEY"
fi

BYSTANDER_ADDRESS=$(
cardano-cli address build --testnet-magic "$MAGIC" \
--payment-verification-key-file "$BYSTANDER_PAYMENT_VKEY" \
)
BYSTANDER_PUBKEYHASH=$(
cardano-cli address key-hash --payment-verification-key-file "$BYSTANDER_PAYMENT_VKEY"
)

if [[ ! -e "$BYSTANDER_PAYMENT_SKEY" ]] then cardano-cli address key-gen --signing-key-file "$BYSTANDER_PAYMENT_SKEY" \ --verification-key-file "$BYSTANDER_PAYMENT_VKEY" fi BYSTANDER_ADDRESS=$( cardano-cli address build --testnet-magic "$MAGIC" \ --payment-verification-key-file "$BYSTANDER_PAYMENT_VKEY" \) BYSTANDER_PUBKEYHASH=$( cardano-cli address key-hash --payment-verification-key-file "$BYSTANDER_PAYMENT_VKEY")
marlowe-cli util faucet --testnet-magic "$MAGIC" \
--socket-path "$CARDANO_NODE_SOCKET_PATH" \
--out-file /dev/null \
Expand Down
26 changes: 15 additions & 11 deletions marlowe-cli/src/Language/Marlowe/CLI/Command.hs
Expand Up @@ -31,7 +31,8 @@ import Language.Marlowe.CLI.Command.Contract (ContractCommand, parseContractComm
import Language.Marlowe.CLI.Command.Input (InputCommand, parseInputCommand, runInputCommand)
import Language.Marlowe.CLI.Command.Role (RoleCommand, parseRoleCommand, runRoleCommand)
import Language.Marlowe.CLI.Command.Run (RunCommand, parseRunCommand, runRunCommand)
import Language.Marlowe.CLI.Command.Template (TemplateCommand, parseTemplateCommand, runTemplateCommand)
import Language.Marlowe.CLI.Command.Template (OutputFiles (..), TemplateCommand, parseTemplateCommand,
parseTemplateCommandOutputFiles, runTemplateCommand)
import Language.Marlowe.CLI.Command.Test (TestCommand, parseTestCommand, runTestCommand)
import Language.Marlowe.CLI.Command.Transaction (TransactionCommand, parseTransactionCommand, runTransactionCommand)
import Language.Marlowe.CLI.Command.Util (UtilCommand, parseUtilCommand, runUtilCommand)
Expand All @@ -54,7 +55,7 @@ data Command =
-- | Role-related commands.
| RoleCommand RoleCommand
-- | Template-related commands.
| TemplateCommand TemplateCommand
| TemplateCommand TemplateCommand OutputFiles
-- | Transaction-related commands.
| TransactionCommand TransactionCommand
-- | Miscellaneous commands.
Expand Down Expand Up @@ -86,14 +87,16 @@ runCommand :: MonadError CliError m
=> MonadIO m
=> Command -- ^ The command.
-> m () -- ^ Action to run the command.
runCommand (RunCommand command) = runRunCommand command
runCommand (ContractCommand command) = runContractCommand command
runCommand (TestCommand command) = runTestCommand command
runCommand (InputCommand command) = runInputCommand command
runCommand (RoleCommand command) = runRoleCommand command
runCommand (TemplateCommand command) = runTemplateCommand command
runCommand (TransactionCommand command) = runTransactionCommand command
runCommand (UtilCommand command) = runUtilCommand command
runCommand (RunCommand command) = runRunCommand command
runCommand (PabCommand command) = runPabCommand command
runCommand (ContractCommand command) = runContractCommand command
runCommand (TestCommand command) = runTestCommand command
runCommand (InputCommand command) = runInputCommand command
runCommand (QueryCommand command) = runQueryCommand command
runCommand (RoleCommand command) = runRoleCommand command
runCommand (TemplateCommand command outputFiles) = runTemplateCommand command outputFiles
runCommand (TransactionCommand command) = runTransactionCommand command
runCommand (UtilCommand command) = runUtilCommand command


-- | Command parseCommand for the tool version.
Expand All @@ -112,7 +115,8 @@ parseCommand networkId socketPath version =
(
O.commandGroup "High-level commands:"
<> O.command "run" (O.info (RunCommand <$> parseRunCommand networkId socketPath ) $ O.progDesc "Run a contract." )
<> O.command "template" (O.info (TemplateCommand <$> parseTemplateCommand ) $ O.progDesc "Create a contract from a template.")
<> O.command "pab" (O.info (PabCommand <$> parsePabCommand ) $ O.progDesc "Run a contract via the PAB." )
<> O.command "template" (O.info (TemplateCommand <$> parseTemplateCommand <*> parseTemplateCommandOutputFiles ) $ O.progDesc "Create a contract from a template.")
<> O.command "test" (O.info (TestCommand <$> parseTestCommand networkId socketPath) $ O.progDesc "Test contracts." )
)
, O.hsubparser
Expand Down

0 comments on commit 940a370

Please sign in to comment.