{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Test.Cardano.Ledger.Shelley.ByronTranslation (testGroupByronTranslation) where
import qualified Cardano.Chain.Common as Byron
import qualified Cardano.Chain.UTxO as Byron
import Cardano.Ledger.Address
import Cardano.Ledger.Coin
import Cardano.Ledger.Shelley (ShelleyEra)
import Cardano.Ledger.Shelley.API.ByronTranslation
import Cardano.Ledger.Shelley.Core
import Test.Cardano.Ledger.Shelley.Arbitrary ()
import Test.Tasty
import Test.Tasty.QuickCheck
testGroupByronTranslation :: TestTree
testGroupByronTranslation :: TestTree
testGroupByronTranslation =
TestName -> [TestTree] -> TestTree
testGroup
TestName
"Translation from Byron to Shelley"
[ forall a. Testable a => TestName -> a -> TestTree
testProperty TestName
"translateTxOut correctness" CompactTxOut -> Property
prop_translateTxOut_correctness
]
prop_translateTxOut_correctness :: Byron.CompactTxOut -> Property
prop_translateTxOut_correctness :: CompactTxOut -> Property
prop_translateTxOut_correctness CompactTxOut
compactTxOut =
TxOut -> TxOut ShelleyEra
translateTxOutByronToShelley (CompactTxOut -> TxOut
Byron.fromCompactTxOut CompactTxOut
compactTxOut)
forall a. (Eq a, Show a) => a -> a -> Property
=== CompactTxOut -> ShelleyTxOut ShelleyEra
translateCompactTxOutByronToShelley CompactTxOut
compactTxOut
translateTxOutByronToShelley :: Byron.TxOut -> TxOut ShelleyEra
translateTxOutByronToShelley :: TxOut -> TxOut ShelleyEra
translateTxOutByronToShelley (Byron.TxOut Address
addr Lovelace
amount) =
forall era.
(EraTxOut era, HasCallStack) =>
Addr -> Value era -> TxOut era
mkBasicTxOut (Address -> Addr
translateAddr Address
addr) (Lovelace -> Coin
translateAmount Lovelace
amount)
where
translateAmount :: Byron.Lovelace -> Coin
translateAmount :: Lovelace -> Coin
translateAmount = Integer -> Coin
Coin forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lovelace -> Integer
Byron.lovelaceToInteger
translateAddr :: Byron.Address -> Addr
translateAddr :: Address -> Addr
translateAddr = BootstrapAddress -> Addr
AddrBootstrap forall b c a. (b -> c) -> (a -> b) -> a -> c
. Address -> BootstrapAddress
BootstrapAddress