Skip to content

Commit

Permalink
unpend byron witnesses tests in shelley core unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Jun 13, 2022
1 parent 0b78d0c commit 631ec76
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
1 change: 1 addition & 0 deletions lib/shelley/src/Cardano/Wallet/Shelley/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module Cardano.Wallet.Shelley.Transaction
, TxSkeleton (..)
, TxWitnessTag (..)
, TxWitnessTagFor (..)
, EraConstraints
, _decodeSealedTx
, _estimateMaxNumberOfInputs
, _maxScriptExecutionCost
Expand Down
39 changes: 22 additions & 17 deletions lib/shelley/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{- HLINT ignore "Use null" -}

Expand Down Expand Up @@ -212,7 +213,8 @@ import Cardano.Wallet.Shelley.Compatibility
import Cardano.Wallet.Shelley.Compatibility.Ledger
( toAlonzoTxOut )
import Cardano.Wallet.Shelley.Transaction
( TxSkeleton (..)
( EraConstraints
, TxSkeleton (..)
, TxUpdate (..)
, TxWitnessTag (..)
, TxWitnessTagFor
Expand All @@ -221,6 +223,7 @@ import Cardano.Wallet.Shelley.Transaction
, estimateTxCost
, estimateTxSize
, maximumCostOfIncreasingCoin
, mkByronWitness
, mkDelegationCertificates
, mkShelleyWitness
, mkTxSkeleton
Expand Down Expand Up @@ -318,7 +321,6 @@ import System.FilePath
import Test.Hspec
( Spec
, SpecWith
, before_
, describe
, expectationFailure
, it
Expand Down Expand Up @@ -1000,11 +1002,6 @@ eraNum e = fst $ head $ filter ((== e) . snd) allEras
shelleyEraNum :: AnyShelleyBasedEra -> Int
shelleyEraNum = eraNum . shelleyToCardanoEra

pendingOnAlonzo :: String -> ShelleyBasedEra era -> SpecWith a -> SpecWith a
pendingOnAlonzo msg era = before_ $ case era of
Cardano.ShelleyBasedEraAlonzo -> pendingWith ("AlonzoEra: " ++ msg)
_ -> pure ()

instance Arbitrary AnyCardanoEra where
arbitrary = frequency $ zip [1..] $ map (pure . snd) allEras
-- Shrink by choosing a *later* era
Expand Down Expand Up @@ -1401,13 +1398,21 @@ binaryCalculationsSpec :: AnyCardanoEra -> Spec
binaryCalculationsSpec (AnyCardanoEra era) =
case cardanoEraStyle era of
LegacyByronEra -> pure ()
ShelleyBasedEra shelleyEra ->
-- TODO: [ADP-919] tests for byron witnesses
pendingOnAlonzo "Golden transactions not yet updated" shelleyEra $
before_ (pendingWith ("Will return with signTx PR")) $
binaryCalculationsSpec' shelleyEra

binaryCalculationsSpec' :: IsShelleyBasedEra era => ShelleyBasedEra era -> Spec
ShelleyBasedEra shelleyEra -> case shelleyEra of
ShelleyBasedEraShelley ->
binaryCalculationsSpec' @Cardano.ShelleyEra shelleyEra
ShelleyBasedEraAllegra ->
binaryCalculationsSpec' @Cardano.AllegraEra shelleyEra
ShelleyBasedEraMary ->
binaryCalculationsSpec' @Cardano.MaryEra shelleyEra
ShelleyBasedEraAlonzo ->
binaryCalculationsSpec' @Cardano.AlonzoEra shelleyEra
ShelleyBasedEraBabbage ->
binaryCalculationsSpec' @Cardano.BabbageEra shelleyEra

binaryCalculationsSpec'
:: forall era. EraConstraints era
=> ShelleyBasedEra era -> Spec
binaryCalculationsSpec' era = describe ("calculateBinary - "+||era||+"") $ do
describe "Byron witnesses - mainnet" $ do
let net = Cardano.Mainnet
Expand Down Expand Up @@ -1560,12 +1565,12 @@ binaryCalculationsSpec' era = describe ("calculateBinary - "+||era||+"") $ do
where
slotNo = SlotNo 7750
md = Nothing
calculateBinary _net utxo outs chgs pairs =
calculateBinary net utxo outs chgs pairs =
hex (Cardano.serialiseToCBOR ledgerTx)
where
ledgerTx = Cardano.makeSignedTransaction addrWits unsigned
mkByronWitness' _unsignedTx (_, (TxOut _addr _)) =
error "mkByronWitness'" -- TODO: [ADP-919]
mkByronWitness' unsignedTx (_, (TxOut addr _)) =
mkByronWitness @era unsignedTx net addr
addrWits = zipWith (mkByronWitness' unsigned) inps pairs
fee = toCardanoLovelace $ selectionDelta txOutCoin cs
Right unsigned =
Expand Down

0 comments on commit 631ec76

Please sign in to comment.