|
| 1 | +{-# LANGUAGE OverloadedStrings #-} |
| 2 | + |
| 3 | +module Test.Golden.Dijkstra.Transaction.Assemble where |
| 4 | + |
| 5 | +import Control.Monad (void) |
| 6 | + |
| 7 | +import Test.Cardano.CLI.Util |
| 8 | + |
| 9 | +import Hedgehog (Property) |
| 10 | +import Hedgehog.Extras.Test qualified as H |
| 11 | + |
| 12 | +-- Check that a witness written by `transaction witness` in the Dijkstra era |
| 13 | +-- can be read back by `transaction assemble` to form a transaction. |
| 14 | +-- Regression test for https://github.com/IntersectMBO/cardano-cli/issues/1422 |
| 15 | +-- |
| 16 | +-- The exact transaction pinned by the golden files below was submitted to and |
| 17 | +-- accepted by a local Dijkstra testnet (magic 42). |
| 18 | + |
| 19 | +hprop_golden_dijkstra_transaction_assemble_witness_signing_key :: Property |
| 20 | +hprop_golden_dijkstra_transaction_assemble_witness_signing_key = |
| 21 | + watchdogProp . propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do |
| 22 | + txBodyFile <- noteTempFile tempDir "tx-body" |
| 23 | + |
| 24 | + -- Create tx body file |
| 25 | + void $ |
| 26 | + execCardanoCLI |
| 27 | + [ "dijkstra" |
| 28 | + , "transaction" |
| 29 | + , "build-raw" |
| 30 | + , "--tx-in" |
| 31 | + , "63e6a9a8e58e48cc025cae04daaed9d36fc7b70bc292721d9f5057ae37b24981#0" |
| 32 | + , "--tx-out" |
| 33 | + , "addr_test1vp0t4dfa9ktc2uvv7sg9leafuhtwyu0xcj4q4kf5pqkpjwqhklklg+15000002800000" |
| 34 | + , "--fee" |
| 35 | + , "200000" |
| 36 | + , "--tx-body-file" |
| 37 | + , txBodyFile |
| 38 | + ] |
| 39 | + |
| 40 | + -- Sign it with a single signing key, as a detached witness file |
| 41 | + witnessFile <- noteTempFile tempDir "single-signing-key-witness" |
| 42 | + signingKeyFile <- |
| 43 | + noteInputFile "test/cardano-cli-golden/files/input/dijkstra/keys/utxo_keys/signing_key" |
| 44 | + |
| 45 | + void $ |
| 46 | + execCardanoCLI |
| 47 | + [ "dijkstra" |
| 48 | + , "transaction" |
| 49 | + , "witness" |
| 50 | + , "--tx-body-file" |
| 51 | + , txBodyFile |
| 52 | + , "--signing-key-file" |
| 53 | + , signingKeyFile |
| 54 | + , "--testnet-magic" |
| 55 | + , "42" |
| 56 | + , "--out-file" |
| 57 | + , witnessFile |
| 58 | + ] |
| 59 | + |
| 60 | + goldenWitnessFile <- H.note "test/cardano-cli-golden/files/golden/dijkstra/transaction/witness_out" |
| 61 | + H.diffFileVsGoldenFile witnessFile goldenWitnessFile |
| 62 | + |
| 63 | + -- Assemble the body and the witness back into a signed transaction |
| 64 | + signedTxFile <- noteTempFile tempDir "signed-tx" |
| 65 | + void $ |
| 66 | + execCardanoCLI |
| 67 | + [ "dijkstra" |
| 68 | + , "transaction" |
| 69 | + , "assemble" |
| 70 | + , "--tx-body-file" |
| 71 | + , txBodyFile |
| 72 | + , "--witness-file" |
| 73 | + , witnessFile |
| 74 | + , "--out-file" |
| 75 | + , signedTxFile |
| 76 | + ] |
| 77 | + |
| 78 | + goldenSignedTxFile <- |
| 79 | + H.note "test/cardano-cli-golden/files/golden/dijkstra/transaction/assemble_out" |
| 80 | + H.diffFileVsGoldenFile signedTxFile goldenSignedTxFile |
0 commit comments