Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement tests for witness creation and assembly of tx body and witness
- Loading branch information
Showing
9 changed files
with
256 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
cardano-cli/test/Test/Golden/Shelley/Transaction/Assemble.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Test.Golden.Shelley.Transaction.Assemble | ||
( golden_shelleyTransactionAssembleWitness_AllMultiSig | ||
, golden_shelleyTransactionAssembleWitness_AnyMultiSig | ||
, golden_shelleyTransactionAssembleWitness_AtLeastMultiSig | ||
, golden_shelleyTransactionAssembleWitness_SigningKey | ||
) where | ||
|
||
import Cardano.Prelude | ||
import Hedgehog (Property) | ||
import Test.OptParse | ||
|
||
{- HLINT ignore "Use camelCase" -} | ||
|
||
-- Check that we can assemble a txbody and a tx witness to form a transaction | ||
|
||
golden_shelleyTransactionAssembleWitness_AllMultiSig :: Property | ||
golden_shelleyTransactionAssembleWitness_AllMultiSig = propertyOnce $ moduleWorkspace "tmp" $ \tempDir -> do | ||
allWitnessTx <- noteTempFile tempDir "all-witness-tx" | ||
txBodyFile <- noteInputFile "test/data/golden/shelley/tx/txbody" | ||
allScriptWitnessFile <- noteInputFile "test/data/golden/shelley/witnesses/allScriptWitness" | ||
void $ execCardanoCLI | ||
[ "shelley","transaction","sign-witness" | ||
, "--tx-body-file", txBodyFile | ||
, "--witness-file", allScriptWitnessFile | ||
, "--out-file", allWitnessTx | ||
] | ||
|
||
assertFileOccurences 1 "TxSignedShelley" allWitnessTx | ||
|
||
golden_shelleyTransactionAssembleWitness_AnyMultiSig :: Property | ||
golden_shelleyTransactionAssembleWitness_AnyMultiSig = propertyOnce $ moduleWorkspace "tmp" $ \tempDir -> do | ||
anyWitnessTx <- noteTempFile tempDir "any-witness-tx" | ||
txBodyFile <- noteInputFile "test/data/golden/shelley/tx/txbody" | ||
anyScriptWitnessFile <- noteInputFile "test/data/golden/shelley/witnesses/anyScriptWitness" | ||
void $ execCardanoCLI | ||
[ "shelley","transaction","sign-witness" | ||
, "--tx-body-file", txBodyFile | ||
, "--witness-file", anyScriptWitnessFile | ||
, "--out-file", anyWitnessTx | ||
] | ||
|
||
assertFileOccurences 1 "TxSignedShelley" anyWitnessTx | ||
|
||
golden_shelleyTransactionAssembleWitness_AtLeastMultiSig :: Property | ||
golden_shelleyTransactionAssembleWitness_AtLeastMultiSig = propertyOnce $ moduleWorkspace "tmp" $ \tempDir -> do | ||
atLeastWitnessTx <- noteTempFile tempDir "atLeast-witness-tx" | ||
txBodyFile <- noteInputFile "test/data/golden/shelley/tx/txbody" | ||
atLeastScriptWitnessFile <- noteInputFile "test/data/golden/shelley/witnesses/anyScriptWitness" | ||
void $ execCardanoCLI | ||
[ "shelley","transaction","sign-witness" | ||
, "--tx-body-file", txBodyFile | ||
, "--witness-file", atLeastScriptWitnessFile | ||
, "--out-file", atLeastWitnessTx | ||
] | ||
|
||
assertFileOccurences 1 "TxSignedShelley" atLeastWitnessTx | ||
|
||
golden_shelleyTransactionAssembleWitness_SigningKey :: Property | ||
golden_shelleyTransactionAssembleWitness_SigningKey = propertyOnce $ moduleWorkspace "tmp" $ \tempDir -> do | ||
witnessTx <- noteTempFile tempDir "single-signing-key-witness-tx" | ||
txBodyFile <- noteInputFile "test/data/golden/shelley/tx/txbody" | ||
signingKeyWitnessFile <- noteInputFile "test/data/golden/shelley/witnesses/singleSigningKeyWitness" | ||
void $ execCardanoCLI | ||
[ "shelley","transaction","sign-witness" | ||
, "--tx-body-file", txBodyFile | ||
, "--witness-file", signingKeyWitnessFile | ||
, "--witness-file", signingKeyWitnessFile | ||
, "--out-file", witnessTx | ||
] | ||
|
||
assertFileOccurences 1 "TxSignedShelley" witnessTx |
140 changes: 140 additions & 0 deletions
140
cardano-cli/test/Test/Golden/Shelley/Transaction/CreateWitness.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Test.Golden.Shelley.Transaction.CreateWitness | ||
( golden_shelleyTransactionAllMultiSigWitness | ||
, golden_shelleyTransactionAnyMultiSigWitness | ||
, golden_shelleyTransactionAtLeastMultiSigWitness | ||
, golden_shelleyTransactionSigningKeyWitness | ||
) where | ||
|
||
import Cardano.Prelude | ||
import Prelude (String) | ||
|
||
import Hedgehog (Property) | ||
import Test.OptParse | ||
|
||
|
||
{- HLINT ignore "Use camelCase" -} | ||
|
||
txIn :: String | ||
txIn = "2392d2b1200b5139fe555c81261697b29a8ccf561c5c783d46e78a479d977053#0" | ||
|
||
txOut :: String | ||
txOut = "addr1q94cxl99qvtwunsqqv6g9mgj3zrawtpt4edsgwxkjtwpy5dsezcht90tmwfur7t5hc9fk8hjd3r5vjwec2h8vmk3xh8s7er7t3+100" | ||
|
||
golden_shelleyTransactionAllMultiSigWitness :: Property | ||
golden_shelleyTransactionAllMultiSigWitness = propertyOnce $ moduleWorkspace "tmp" $ \tempDir -> do | ||
txBodyOutFile <- noteTempFile tempDir "tx-body-out" | ||
|
||
-- Create tx body file | ||
void $ execCardanoCLI | ||
[ "shelley","transaction","build-raw" | ||
, "--tx-in", txIn | ||
, "--tx-out", txOut | ||
, "--ttl", "60" | ||
, "--fee", "12" | ||
, "--tx-body-file", txBodyOutFile | ||
] | ||
|
||
assertFileOccurences 1 "TxUnsignedShelley" txBodyOutFile | ||
assertEndsWithSingleNewline txBodyOutFile | ||
|
||
|
||
-- Create all multisig witness | ||
allMultiSigWitnessOutFile <- noteTempFile tempDir "all-multisig-witness" | ||
allScriptWitnessFile <- noteInputFile "test/data/golden/shelley/multisig/scripts/all" | ||
void $ execCardanoCLI | ||
[ "shelley","transaction","witness" | ||
, "--tx-body-file", txBodyOutFile | ||
, "--script-file", allScriptWitnessFile | ||
, "--mainnet" | ||
, "--out-file", allMultiSigWitnessOutFile | ||
] | ||
|
||
assertFileOccurences 1 "TxWitnessShelley" allMultiSigWitnessOutFile | ||
assertEndsWithSingleNewline txBodyOutFile | ||
|
||
|
||
golden_shelleyTransactionAnyMultiSigWitness :: Property | ||
golden_shelleyTransactionAnyMultiSigWitness = propertyOnce $ moduleWorkspace "tmp" $ \tempDir -> do | ||
txBodyOutFile <- noteTempFile tempDir "tx-body-out" | ||
|
||
-- Create tx body file | ||
void $ execCardanoCLI | ||
[ "shelley","transaction","build-raw" | ||
, "--tx-in", txIn | ||
, "--tx-out", txOut | ||
, "--ttl", "60" | ||
, "--fee", "12" | ||
, "--tx-body-file", txBodyOutFile | ||
] | ||
|
||
-- Create all multisig witness | ||
allMultiSigWitnessOutFile <- noteTempFile tempDir "any-multisig-witness" | ||
anyScriptWitnessFile <- noteInputFile "test/data/golden/shelley/multisig/scripts/any" | ||
void $ execCardanoCLI | ||
[ "shelley","transaction","witness" | ||
, "--tx-body-file", txBodyOutFile | ||
, "--script-file", anyScriptWitnessFile | ||
, "--mainnet" | ||
, "--out-file", allMultiSigWitnessOutFile | ||
] | ||
|
||
assertFileOccurences 1 "TxWitnessShelley" allMultiSigWitnessOutFile | ||
assertEndsWithSingleNewline txBodyOutFile | ||
|
||
golden_shelleyTransactionAtLeastMultiSigWitness :: Property | ||
golden_shelleyTransactionAtLeastMultiSigWitness = propertyOnce $ moduleWorkspace "tmp" $ \tempDir -> do | ||
txBodyOutFile <- noteTempFile tempDir "tx-body-out" | ||
|
||
-- Create tx body file | ||
void $ execCardanoCLI | ||
[ "shelley","transaction","build-raw" | ||
, "--tx-in", txIn | ||
, "--tx-out", txOut | ||
, "--ttl", "60" | ||
, "--fee", "12" | ||
, "--tx-body-file", txBodyOutFile | ||
] | ||
|
||
-- Create all multisig witness | ||
atLeastMultiSigWitnessOutFile <- noteTempFile tempDir "atleast-multisig-witness" | ||
atLeastScriptWitnessFile <- noteInputFile "test/data/golden/shelley/multisig/scripts/atleast" | ||
void $ execCardanoCLI | ||
[ "shelley","transaction","witness" | ||
, "--tx-body-file", txBodyOutFile | ||
, "--script-file", atLeastScriptWitnessFile | ||
, "--mainnet" | ||
, "--out-file", atLeastMultiSigWitnessOutFile | ||
] | ||
|
||
assertFileOccurences 1 "TxWitnessShelley" atLeastMultiSigWitnessOutFile | ||
assertEndsWithSingleNewline txBodyOutFile | ||
|
||
golden_shelleyTransactionSigningKeyWitness :: Property | ||
golden_shelleyTransactionSigningKeyWitness = propertyOnce $ moduleWorkspace "tmp" $ \tempDir -> do | ||
txBodyOutFile <- noteTempFile tempDir "tx-body-out" | ||
|
||
-- Create tx body file | ||
void $ execCardanoCLI | ||
[ "shelley","transaction","build-raw" | ||
, "--tx-in", txIn | ||
, "--tx-out", txOut | ||
, "--ttl", "60" | ||
, "--fee", "12" | ||
, "--tx-body-file", txBodyOutFile | ||
] | ||
|
||
-- Create all multisig witness | ||
witnessOutFile <- noteTempFile tempDir "signingkey-witness" | ||
signingKeyFile <- noteInputFile "test/data/golden/shelley/keys/payment_keys/signing_key" | ||
void $ execCardanoCLI | ||
[ "shelley","transaction","witness" | ||
, "--tx-body-file", txBodyOutFile | ||
, "--signing-key-file", signingKeyFile | ||
, "--mainnet" | ||
, "--out-file", witnessOutFile | ||
] | ||
|
||
assertFileOccurences 1 "TxWitnessShelley" witnessOutFile | ||
assertEndsWithSingleNewline txBodyOutFile |
5 changes: 5 additions & 0 deletions
5
cardano-cli/test/data/golden/shelley/witnesses/allScriptWitness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "TxWitnessShelley", | ||
"description": "", | ||
"cborHex": "820282008201888200581ce09d36c79dec9bd1b3d9e152247701cd0bb860b5ebfd1de8abb6735a8200581ca687dcc24e00dd3caafbeb5e68f97ca8ef269cb6fe971345eb9517568200581c0bd1d702b2e6188fe0857a6dc7ffb0675229bab58c86638ffa87ed6d8200581cdd0044a26cf7d4491ecea720fda11afb59d5725b53afa605fdf695e68200581ccf223afe150cc8e89f11edaacbbd55b011ba44fbedef66fbd37d8c9d8200581c372643e7ef4b41fd2649ada30a89d35cb90b7c14cb5de252e6ce6cb78200581caa453dc184c5037d60e3fbbadb023f4a41bac112f249b76be9bb37ad8200581c6b732c60c267bab894854d6dd57a04a94e603fcc4c36274c9ed75952" | ||
} |
5 changes: 5 additions & 0 deletions
5
cardano-cli/test/data/golden/shelley/witnesses/anyScriptWitness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "TxWitnessShelley", | ||
"description": "", | ||
"cborHex": "820282008202868200581cd92b712d1882c3b0f75b6f677e0b2cbef4fbc8b8121bb9dde324ff098200581c4d780ed1bfc88cbd4da3f48de91fe728c3530d662564bf5a284b53218200581c3a94d6d4e786a3f5d439939cafc0536f6abc324fb8404084d6034bf88200581cb12e094d1db7c0fba5121f22db193d0060efed8be43654f861bb68ae8200581c9be49d56442b4b8b16cab4e43e238bbdefc6c803d554c82fcd5facc38200581c622be5fab3b5c3f371a50a535e4d3349c942a98cecee93b24e2fd11d" | ||
} |
5 changes: 5 additions & 0 deletions
5
cardano-cli/test/data/golden/shelley/witnesses/atLeastScriptWitness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "TxWitnessShelley", | ||
"description": "", | ||
"cborHex": "82028200830302848200581c2f3d4cf10d0471a1db9f2d2907de867968c27bca6272f062cd1c24138200581cf856c0c5839bab22673747d53f1ae9eed84afafb085f086e8e9886148200581cb275b08c999097247f7c17e77007c7010cd19f20cc086ad99d3985388200581c686024aecb5884d73a11b9ae4e63931112ba737e878d74638b78513a" | ||
} |
5 changes: 5 additions & 0 deletions
5
cardano-cli/test/data/golden/shelley/witnesses/singleSigningKeyWitness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "TxWitnessShelley", | ||
"description": "", | ||
"cborHex": "82008258208dc60533b5dfa60a530955a696323a2ef4f14e8bc95a8f84cf6c441fea42342758409f69aa4bf41acf78deaffb002c4f36157f3bad7c434a19b1ffe7e7df5f98f629e58503a762e83c1f60e54c9eb7eef9885b16c2b42ce1336914f2df9aa63b1407" | ||
} |