From b7f827279414f125e80332b9f7f9b7793450c0b9 Mon Sep 17 00:00:00 2001 From: Jonathan Knowles Date: Fri, 26 May 2023 05:38:04 +0000 Subject: [PATCH 1/3] Remove unused function `genWits`. --- lib/wallet/test/unit/Cardano/Wallet/Api/TypesSpec.hs | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/wallet/test/unit/Cardano/Wallet/Api/TypesSpec.hs b/lib/wallet/test/unit/Cardano/Wallet/Api/TypesSpec.hs index bc876b2e811..2bb36a769d0 100644 --- a/lib/wallet/test/unit/Cardano/Wallet/Api/TypesSpec.hs +++ b/lib/wallet/test/unit/Cardano/Wallet/Api/TypesSpec.hs @@ -2170,9 +2170,6 @@ selectFromPreparedBinaries = elements $ toByteString <$> let (Right bs) = fromHex $ T.encodeUtf8 txt in bs -genWits :: Gen ByteString -genWits = BS.pack <$> Test.QuickCheck.scale (min 32) (listOf arbitrary) - deriving instance Arbitrary a => Arbitrary (ApiAsArray s a) instance Arbitrary (ApiBytesT base ByteString) where From 13c3913e77ff4e72dd0f51e28016b2e5c6169586 Mon Sep 17 00:00:00 2001 From: Jonathan Knowles Date: Fri, 26 May 2023 05:38:50 +0000 Subject: [PATCH 2/3] Remove unused imports. --- lib/wallet/bench/restore-bench.hs | 6 +----- lib/wallet/test/unit/Cardano/Wallet/Api/TypesSpec.hs | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/wallet/bench/restore-bench.hs b/lib/wallet/bench/restore-bench.hs index e0756651680..91d28f23e74 100644 --- a/lib/wallet/bench/restore-bench.hs +++ b/lib/wallet/bench/restore-bench.hs @@ -51,11 +51,7 @@ import Cardano.BM.Trace import Cardano.Mnemonic ( SomeMnemonic (..), entropyToMnemonic ) import Cardano.Wallet - ( WalletException (..) - , WalletLayer (..) - , WalletWorkerLog (..) - , dummyChangeAddressGen - ) + ( WalletLayer (..), WalletWorkerLog (..), dummyChangeAddressGen ) import Cardano.Wallet.Address.Book ( AddressBookIso ) import Cardano.Wallet.Address.Derivation diff --git a/lib/wallet/test/unit/Cardano/Wallet/Api/TypesSpec.hs b/lib/wallet/test/unit/Cardano/Wallet/Api/TypesSpec.hs index 2bb36a769d0..6a38a80798e 100644 --- a/lib/wallet/test/unit/Cardano/Wallet/Api/TypesSpec.hs +++ b/lib/wallet/test/unit/Cardano/Wallet/Api/TypesSpec.hs @@ -483,7 +483,6 @@ import Test.QuickCheck , forAll , frequency , liftArbitrary - , listOf , oneof , property , scale From 4f1df4c24c3ebd1765b96d56ca37b8f50dd6039a Mon Sep 17 00:00:00 2001 From: Jonathan Knowles Date: Fri, 26 May 2023 05:39:18 +0000 Subject: [PATCH 3/3] Test class laws for `AnyRecentEra`. --- .../test/unit/Cardano/Wallet/Write/TxSpec.hs | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/wallet/test/unit/Cardano/Wallet/Write/TxSpec.hs b/lib/wallet/test/unit/Cardano/Wallet/Write/TxSpec.hs index a58d7902dc5..1d3218fe854 100644 --- a/lib/wallet/test/unit/Cardano/Wallet/Write/TxSpec.hs +++ b/lib/wallet/test/unit/Cardano/Wallet/Write/TxSpec.hs @@ -18,7 +18,8 @@ import Cardano.Ledger.Babbage.TxBody import Cardano.Wallet.Unsafe ( unsafeFromHex ) import Cardano.Wallet.Write.Tx - ( BinaryData + ( AnyRecentEra + , BinaryData , RecentEra (..) , Script , StandardBabbage @@ -59,11 +60,18 @@ import Test.QuickCheck ( Arbitrary (..) , Arbitrary1 (liftArbitrary) , Property + , arbitraryBoundedEnum , conjoin , counterexample , property , (===) ) +import Test.QuickCheck.Classes + ( boundedEnumLaws, eqLaws, showLaws ) +import Test.QuickCheck.Extra + ( shrinkBoundedEnum ) +import Test.Utils.Laws + ( testLawsMany ) import qualified Cardano.Api as Cardano import qualified Cardano.Api.Gen as Cardano @@ -75,6 +83,15 @@ import qualified Data.Map as Map spec :: Spec spec = do + + describe "AnyRecentEra" $ do + describe "Class instances obey laws" $ do + testLawsMany @AnyRecentEra + [ boundedEnumLaws + , eqLaws + , showLaws + ] + describe "BinaryData" $ do it "BinaryData is isomorphic to Cardano.ScriptData" $ testIsomorphism @@ -265,6 +282,14 @@ testIsomorphism (NamedFun f fName) (NamedFun g gName) normalize = (property $ \x -> g (f x) === x) ] +-------------------------------------------------------------------------------- +-- Arbitrary instances +-------------------------------------------------------------------------------- + +instance Arbitrary AnyRecentEra where + arbitrary = arbitraryBoundedEnum + shrink = shrinkBoundedEnum + -------------------------------------------------------------------------------- -- Test Data --------------------------------------------------------------------------------