@@ -11,6 +11,7 @@ import Pos.Client.Txp.Util (InputSelectionPolicy)
11
11
import qualified Pos.Crypto as Crypto
12
12
import qualified Pos.Txp.Toil.Types as V0
13
13
import qualified Pos.Wallet.Web.ClientTypes.Types as V0
14
+ import Servant.API (FromHttpApiData (.. ), ToHttpApiData (.. ))
14
15
import Test.Hspec
15
16
import Test.Hspec.QuickCheck
16
17
import Test.QuickCheck
@@ -22,6 +23,7 @@ import Pos.Util.BackupPhrase (BackupPhrase)
22
23
import qualified Pos.Core as Core
23
24
24
25
import Cardano.Wallet.API.Indices
26
+ import Cardano.Wallet.API.Request.Pagination (Page , PerPage )
25
27
import Cardano.Wallet.API.V1.Errors (WalletError )
26
28
import Cardano.Wallet.API.V1.Migration.Types (Migrate (.. ))
27
29
import Cardano.Wallet.API.V1.Types
@@ -32,7 +34,7 @@ import qualified Cardano.Wallet.Util as Util
32
34
spec :: Spec
33
35
spec = parallel $ describe " Marshalling & Unmarshalling" $ do
34
36
parallel $ describe " Roundtrips" $ do
35
- -- Aeson roundrips
37
+ -- Aeson roundtrips
36
38
aesonRoundtripProp @ (V1 BackupPhrase ) Proxy
37
39
aesonRoundtripProp @ Account Proxy
38
40
aesonRoundtripProp @ AssuranceLevel Proxy
@@ -63,8 +65,19 @@ spec = parallel $ describe "Marshalling & Unmarshalling" $ do
63
65
aesonRoundtripProp @ EstimatedCompletionTime Proxy
64
66
aesonRoundtripProp @ SyncProgress Proxy
65
67
aesonRoundtripProp @ SyncThroughput Proxy
66
-
67
- -- Migrate roundrips
68
+ aesonRoundtripProp @ AccountIndex Proxy
69
+
70
+ -- HttpApiData roundtrips
71
+ httpApiDataRoundtripProp @ AccountIndex Proxy
72
+ httpApiDataRoundtripProp @ (V1 Core. TxId ) Proxy
73
+ httpApiDataRoundtripProp @ WalletId Proxy
74
+ httpApiDataRoundtripProp @ (V1 Core. Timestamp ) Proxy
75
+ httpApiDataRoundtripProp @ (V1 Core. Address ) Proxy
76
+ httpApiDataRoundtripProp @ PerPage Proxy
77
+ httpApiDataRoundtripProp @ Page Proxy
78
+ httpApiDataRoundtripProp @ Core. Coin Proxy
79
+
80
+ -- Migrate roundtrips
68
81
migrateRoundtripProp @ (V1 Core. Address ) @ (V0. CId V0. Addr ) Proxy Proxy
69
82
migrateRoundtripProp @ (V1 Core. Coin ) @ V0. CCoin Proxy Proxy
70
83
migrateRoundtripProp @ AssuranceLevel @ V0. CWalletAssurance Proxy Proxy
@@ -151,6 +164,16 @@ aesonRoundtripProp
151
164
aesonRoundtripProp proxy =
152
165
prop (" Aeson " <> show (typeRep proxy) <> " roundtrips" ) (aesonRoundtrip proxy)
153
166
167
+ httpApiDataRoundtrip :: (Arbitrary a , FromHttpApiData a , ToHttpApiData a , Eq a , Show a ) => proxy a -> Property
168
+ httpApiDataRoundtrip (_ :: proxy a ) = forAll arbitrary $ \ (s :: a ) -> do
169
+ parseQueryParam (toQueryParam s) === Right s
170
+
171
+ httpApiDataRoundtripProp
172
+ :: (Arbitrary a , ToHttpApiData a , FromHttpApiData a , Eq a , Show a , Typeable a )
173
+ => proxy a -> Spec
174
+ httpApiDataRoundtripProp proxy =
175
+ prop (" HttpApiData " <> show (typeRep proxy) <> " roundtrips" ) (httpApiDataRoundtrip proxy)
176
+
154
177
generalRoundtrip
155
178
:: (Arbitrary from , Eq from , Show from , Show e )
156
179
=> (from -> to ) -> (to -> Either e from ) -> Property
0 commit comments