From 7e4a6a4ef64aebf34977eb8b6d3cd807a05811be Mon Sep 17 00:00:00 2001 From: KtorZ Date: Wed, 7 Oct 2020 18:05:43 +0200 Subject: [PATCH] add roundtrip test for ToText/FromText DerivationPrefix instances --- .../Primitive/AddressDiscovery/SequentialSpec.hs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/core/test/unit/Cardano/Wallet/Primitive/AddressDiscovery/SequentialSpec.hs b/lib/core/test/unit/Cardano/Wallet/Primitive/AddressDiscovery/SequentialSpec.hs index 8c08167567a..66b466b2abd 100644 --- a/lib/core/test/unit/Cardano/Wallet/Primitive/AddressDiscovery/SequentialSpec.hs +++ b/lib/core/test/unit/Cardano/Wallet/Primitive/AddressDiscovery/SequentialSpec.hs @@ -26,7 +26,9 @@ import Cardano.Wallet.Primitive.AddressDerivation ( AccountingStyle (..) , DelegationAddress (..) , Depth (..) + , DerivationType (..) , HardDerivation (..) + , Index , KeyFingerprint , MkKeyFingerprint (..) , NetworkDiscriminant (..) @@ -103,7 +105,6 @@ import Test.QuickCheck , Positive (..) , Property , arbitraryBoundedEnum - , arbitraryBoundedEnum , checkCoverage , choose , classify @@ -144,6 +145,9 @@ spec = do it "defaultAddressPoolGap is valid" (property prop_defaultValid) + describe "DerivationPrefix" $ do + textRoundtrip (Proxy @DerivationPrefix) + let styles = [ Style (Proxy @'UTxOExternal) , Style (Proxy @'UTxOInternal) @@ -640,6 +644,16 @@ instance Arbitrary AddressState where shrink _ = [] arbitrary = genericArbitrary +instance Arbitrary DerivationPrefix where + arbitrary = fmap DerivationPrefix $ (,,) + <$> arbitrary + <*> arbitrary + <*> arbitrary + +instance Arbitrary (Index 'Hardened depth) where + shrink _ = [] + arbitrary = arbitraryBoundedEnum + -- | In this context, Arbitrary addresses are either some known addresses -- derived from "our account key", or they just are some arbitrary addresses -- that are unknown to us.