Skip to content

Commit

Permalink
Merge #934 #935
Browse files Browse the repository at this point in the history
934: Minor fixes r=dcoutts a=erikd



935: cli: Add new tests r=dcoutts a=erikd



Co-authored-by: Erik de Castro Lopo <erikd@mega-nerd.com>
  • Loading branch information
iohk-bors[bot] and erikd committed May 11, 2020
3 parents fe49b1f + fdc3b38 + b169eda commit e0f4c5a
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 23 deletions.
37 changes: 15 additions & 22 deletions cardano-api/src/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -167,28 +167,21 @@ shelleyRegisterStakePool
-> Certificate
shelleyRegisterStakePool poolVkeyHash vrfVkeyHash pldg cst
mrgn rwdact ownrs relays md = do
let poolPubKeyHash = poolVkeyHash
poolVRFkeyHash = vrfVkeyHash
poolPledge = pldg
poolCost = cst
poolMargin = mrgn
poolRewardAcnt = rwdact
poolOwners = ownrs
poolRelays = Seq.fromList relays
poolMetaData = Shelley.maybeToStrictMaybe md

let poolParams = Shelley.PoolParams
{ Shelley._poolPubKey = poolPubKeyHash
, Shelley._poolVrf = poolVRFkeyHash
, Shelley._poolPledge = poolPledge
, Shelley._poolCost = poolCost
, Shelley._poolMargin = poolMargin
, Shelley._poolRAcnt = poolRewardAcnt
, Shelley._poolOwners = poolOwners
, Shelley._poolRelays = poolRelays
, Shelley._poolMD = poolMetaData
}
ShelleyStakePoolCertificate . Shelley.DCertPool . Shelley.RegPool $ poolParams
ShelleyStakePoolCertificate
. Shelley.DCertPool
. Shelley.RegPool
$ Shelley.PoolParams
{ Shelley._poolPubKey = poolVkeyHash
, Shelley._poolVrf = vrfVkeyHash
, Shelley._poolPledge = pldg
, Shelley._poolCost = cst
, Shelley._poolMargin = mrgn
, Shelley._poolRAcnt = rwdact
, Shelley._poolOwners = ownrs
, Shelley._poolRelays = Seq.fromList relays
, Shelley._poolMD = Shelley.maybeToStrictMaybe md
}


-- | Retire a shelley staking pool.
shelleyRetireStakePool :: ShelleyVerificationKeyStakePool -> Shelley.EpochNo -> Certificate
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ pAddressCmd =
]
where
pAddressKeyGen :: Parser AddressCmd
pAddressKeyGen = AddressKeyGen <$> pVerificationKeyFile Input <*> pSigningKeyFile Input
pAddressKeyGen = AddressKeyGen <$> pVerificationKeyFile Output <*> pSigningKeyFile Output

pAddressKeyHash :: Parser AddressCmd
pAddressKeyHash = AddressKeyHash <$> pVerificationKeyFile Input
Expand Down
28 changes: 28 additions & 0 deletions cardano-cli/test/cli/node-key-gen-stake-pool/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh -u

cwd=$(dirname "$0")

# shellcheck source=/dev/null
. "${cwd}/../core/common"

# shellcheck disable=SC2154
banner "${testname}"

OUTPUT_DIR="${TEST}"

rm -rf "${OUTPUT_DIR}"
mkdir "${OUTPUT_DIR}"

error=0

${CARDANO_CLI} shelley node key-gen-stake-pool \
--verification-key-file "${OUTPUT_DIR}/key-gen-stake-pool.vkey" \
--signing-key-file "${OUTPUT_DIR}/key-gen-stake-pool.skey"

assert_file_exists "${OUTPUT_DIR}/key-gen-stake-pool.vkey"
assert_file_exists "${OUTPUT_DIR}/key-gen-stake-pool.skey"

assert_string 'VerificationKeyStakePoolShelley' "${OUTPUT_DIR}/key-gen-stake-pool.vkey"
assert_string 'SigningKeyShelley' "${OUTPUT_DIR}/key-gen-stake-pool.skey"

report_result ${error}
28 changes: 28 additions & 0 deletions cardano-cli/test/cli/node-key-gen-staking/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh -u

cwd=$(dirname "$0")

# shellcheck source=/dev/null
. "${cwd}/../core/common"

# shellcheck disable=SC2154
banner "${testname}"

OUTPUT_DIR="${TEST}"

rm -rf "${OUTPUT_DIR}"
mkdir "${OUTPUT_DIR}"

error=0

${CARDANO_CLI} shelley node key-gen-staking \
--verification-key-file "${OUTPUT_DIR}/key-gen-staking.vkey" \
--signing-key-file "${OUTPUT_DIR}/key-gen-staking.skey"

assert_file_exists "${OUTPUT_DIR}/key-gen-staking.vkey"
assert_file_exists "${OUTPUT_DIR}/key-gen-staking.skey"

assert_string 'VerificationKeyStakingShelley' "${OUTPUT_DIR}/key-gen-staking.vkey"
assert_string 'SigningKeyShelley' "${OUTPUT_DIR}/key-gen-staking.skey"

report_result ${error}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type: VerificationKeyStakingShelley
title: Free form text
cbor-hex:
18b958202e21d6d5d8d292a4037b1ae9554ec5d7d9ccf412583a2484b7d51ce9efc2a58f
37 changes: 37 additions & 0 deletions cardano-cli/test/cli/stake-address-deregistration-certificate/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh -u

cwd=$(dirname "$0")

# shellcheck source=/dev/null
. "${cwd}/../core/common"

# shellcheck disable=SC2154
banner "${testname}"

if test -d cardano-cli ; then
cd cardano-cli || exit 1
fi

OUTPUT_DIR="${TEST}"

rm -rf "${OUTPUT_DIR}"
mkdir "${OUTPUT_DIR}"

DATA_DIR="test/cli/${testname}/data"
if test -d cardano-cli ; then
DATA_DIR="cardano-cli/${DATA_DIR}"
fi

error=0

${CARDANO_CLI} shelley stake-address deregistration-certificate \
--verification-key-file "${DATA_DIR}/key-gen-staking.vkey" \
--out-file "${OUTPUT_DIR}/deregistration.cert"
fail_on_error $?

assert_file_exists "${OUTPUT_DIR}/deregistration.cert"
assert_string 'DelegationCertificateShelley' "${OUTPUT_DIR}/deregistration.cert"

#-----------------------------

report_result ${error}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type: VerificationKeyStakingShelley
title: Free form text
cbor-hex:
18b958202e21d6d5d8d292a4037b1ae9554ec5d7d9ccf412583a2484b7d51ce9efc2a58f
37 changes: 37 additions & 0 deletions cardano-cli/test/cli/stake-address-registration-certificate/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh -u

cwd=$(dirname "$0")

# shellcheck source=/dev/null
. "${cwd}/../core/common"

# shellcheck disable=SC2154
banner "${testname}"

if test -d cardano-cli ; then
cd cardano-cli || exit 1
fi

OUTPUT_DIR="${TEST}"

rm -rf "${OUTPUT_DIR}"
mkdir "${OUTPUT_DIR}"

DATA_DIR="test/cli/${testname}/data"
if test -d cardano-cli ; then
DATA_DIR="cardano-cli/${DATA_DIR}"
fi

error=0

${CARDANO_CLI} shelley stake-address registration-certificate \
--verification-key-file "${DATA_DIR}/key-gen-staking.vkey" \
--out-file "${OUTPUT_DIR}/registration.cert"
fail_on_error $?

assert_file_exists "${OUTPUT_DIR}/registration.cert"
assert_string 'DelegationCertificateShelley' "${OUTPUT_DIR}/registration.cert"

#-----------------------------

report_result ${error}

0 comments on commit e0f4c5a

Please sign in to comment.