-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add transAddressShelley in PlutusLedger
- Loading branch information
1 parent
3a7b90c
commit 6a915e1
Showing
5 changed files
with
85 additions
and
9 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
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,33 @@ | ||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE GADTs #-} | ||
|
||
module Convex.PlutusLedgerSpec where | ||
|
||
import qualified Cardano.Api.Shelley as C | ||
import Test.Gen.Cardano.Api.Typed qualified as CGen | ||
import Convex.PlutusLedger (transAddressShelley, unTransAddressShelley) | ||
import Test.QuickCheck qualified as QC | ||
import Test.QuickCheck.Hedgehog qualified as QC | ||
import qualified Cardano.Api.Ledger as Shelley | ||
|
||
newtype ArbitraryNetworkMagic = ArbitraryNetworkMagic C.NetworkMagic | ||
deriving stock (Show) | ||
|
||
instance QC.Arbitrary ArbitraryNetworkMagic where | ||
arbitrary = fmap ArbitraryNetworkMagic $ QC.hedgehog CGen.genNetworkMagic | ||
|
||
newtype ArbitraryAddressShelley = ArbitraryAddressShelley (C.Address C.ShelleyAddr) | ||
deriving stock (Show) | ||
|
||
instance QC.Arbitrary ArbitraryAddressShelley where | ||
arbitrary = fmap ArbitraryAddressShelley $ QC.hedgehog CGen.genAddressShelley | ||
|
||
prop_rountripAddressShelleyPlutusTranslation :: ArbitraryNetworkMagic -> ArbitraryAddressShelley -> Bool | ||
prop_rountripAddressShelleyPlutusTranslation | ||
(ArbitraryNetworkMagic nm) | ||
(ArbitraryAddressShelley addr@(C.ShelleyAddress n _ _)) | ||
= do | ||
let nid = case n of Shelley.Mainnet -> C.Mainnet; Shelley.Testnet -> C.Testnet nm | ||
case unTransAddressShelley nid (transAddressShelley addr) of | ||
Left _err -> False | ||
Right addr' -> addr' == addr |
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 @@ | ||
{-# OPTIONS_GHC -F -pgmF tasty-discover #-} |