Skip to content

Commit

Permalink
make core unit tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Jul 1, 2020
1 parent 163e6fc commit ce054d7
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 75 deletions.
152 changes: 81 additions & 71 deletions lib/core/test/data/Cardano/Wallet/Api/ApiNetworkParameters.json
@@ -1,243 +1,253 @@
{
"seed": -1331206292408369414,
"seed": 1783641201901976871,
"samples": [
{
"slot_length": {
"quantity": 4481,
"quantity": 4898,
"unit": "second"
},
"decentralization_level": {
"quantity": 67,
"quantity": 5.85,
"unit": "percent"
},
"epoch_stability": {
"quantity": 26318,
"quantity": 528,
"unit": "block"
},
"genesis_block_hash": "7f1535376d0c60752d213266651b90b1095573f1326d110169f0396e016e1b63",
"blockchain_start_time": "1908-08-05T09:00:00Z",
"genesis_block_hash": "374ca035306ae5516835045e4b233b5971c9840127700f6d20752d4439024740",
"blockchain_start_time": "1869-05-07T07:10:00Z",
"desired_pool_number": 246,
"epoch_length": {
"quantity": 13609,
"quantity": 20945,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 78.62708373240245,
"quantity": 94.55547664569349,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 3359,
"quantity": 5803,
"unit": "second"
},
"decentralization_level": {
"quantity": 59.77,
"quantity": 91.83,
"unit": "percent"
},
"epoch_stability": {
"quantity": 6460,
"quantity": 15302,
"unit": "block"
},
"genesis_block_hash": "673b352d3c2f6c57176825e532f86c19b5a0356237b78c3e960d5c28616d7066",
"blockchain_start_time": "1883-09-17T08:37:33.480496398755Z",
"genesis_block_hash": "7d3cf56b896e087ddc6f2e793d77224f7c742ff065463a16bb4a6b437443327b",
"blockchain_start_time": "1880-03-03T09:00:00Z",
"desired_pool_number": 1332,
"epoch_length": {
"quantity": 22307,
"quantity": 14005,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 58.146715325079654,
"quantity": 29.678701480196924,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 7255,
"quantity": 1210,
"unit": "second"
},
"decentralization_level": {
"quantity": 28.94,
"quantity": 84.39,
"unit": "percent"
},
"epoch_stability": {
"quantity": 5369,
"quantity": 24490,
"unit": "block"
},
"genesis_block_hash": "7c4f4b2e0703a155761c6a5d693b5868244a415f11c47d63627f151571062a23",
"blockchain_start_time": "1867-09-15T04:44:07.18685544607Z",
"genesis_block_hash": "b2d75f565952443844295b853eb3045c0a1817366e5c2e293596093f4dd02854",
"blockchain_start_time": "1864-05-18T18:07:13.640068095679Z",
"desired_pool_number": 907,
"epoch_length": {
"quantity": 32596,
"quantity": 8497,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 31.533960051384536,
"quantity": 41.0009989127716,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 3285,
"quantity": 4155,
"unit": "second"
},
"decentralization_level": {
"quantity": 63.69,
"quantity": 25.84,
"unit": "percent"
},
"epoch_stability": {
"quantity": 2008,
"quantity": 10252,
"unit": "block"
},
"genesis_block_hash": "0d212e27f76e13ca63bd2d63102c667b321203a84077396c786753100943c15c",
"blockchain_start_time": "1860-03-07T22:01:48Z",
"genesis_block_hash": "5a59c67da96f38177509e8023306205a62ab3b504d0963532e1333380d113961",
"blockchain_start_time": "1901-10-16T12:05:49Z",
"desired_pool_number": 670,
"epoch_length": {
"quantity": 25091,
"quantity": 261,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 36.72480953416392,
"quantity": 58.28661284335994,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 6702,
"quantity": 566,
"unit": "second"
},
"decentralization_level": {
"quantity": 72.49,
"quantity": 30.33,
"unit": "percent"
},
"epoch_stability": {
"quantity": 17350,
"quantity": 472,
"unit": "block"
},
"genesis_block_hash": "77706a697cdc1a976e2c09125a7f4d368f7f5d0437b2560a650462504a7368df",
"blockchain_start_time": "1898-07-20T16:00:00Z",
"genesis_block_hash": "24721c606c6919353377db135c08603f68ec495d0935502731ff8e4e1b5a0c4f",
"blockchain_start_time": "1866-03-22T03:01:21.729708338291Z",
"desired_pool_number": 24,
"epoch_length": {
"quantity": 30963,
"quantity": 29237,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 50.93074806849109,
"quantity": 67.80354754258157,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 772,
"quantity": 5956,
"unit": "second"
},
"decentralization_level": {
"quantity": 35.59,
"quantity": 21.87,
"unit": "percent"
},
"epoch_stability": {
"quantity": 22445,
"quantity": 1687,
"unit": "block"
},
"genesis_block_hash": "4e524827324137b84f48336e741b56073f362d393941215b6b0416a7027d0535",
"blockchain_start_time": "1896-11-17T16:15:36.595743770768Z",
"genesis_block_hash": "ad31d660575c2504372e950862042a764b074b31da225d63fc4e4f7f43183e6a",
"blockchain_start_time": "1903-10-15T12:17:45.5065572951Z",
"desired_pool_number": 29,
"epoch_length": {
"quantity": 18281,
"quantity": 14271,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 23.914063381142526,
"quantity": 83.43727081721306,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 665,
"quantity": 3908,
"unit": "second"
},
"decentralization_level": {
"quantity": 78.14,
"quantity": 48.46,
"unit": "percent"
},
"epoch_stability": {
"quantity": 25293,
"quantity": 22186,
"unit": "block"
},
"genesis_block_hash": "4b072032a102699632952d600f49a00efb1d58647a354a556d9f602d41226c21",
"blockchain_start_time": "1904-02-07T22:39:44Z",
"genesis_block_hash": "b8be756e7f4d75045f02ed031170165a1376506432a0271a5d73583223091f36",
"blockchain_start_time": "1859-06-20T02:53:30.051677675312Z",
"desired_pool_number": 131,
"epoch_length": {
"quantity": 26670,
"quantity": 26820,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 44.94722400324369,
"quantity": 99.86983178290603,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 2354,
"quantity": 6162,
"unit": "second"
},
"decentralization_level": {
"quantity": 55.69,
"quantity": 77.42,
"unit": "percent"
},
"epoch_stability": {
"quantity": 27989,
"quantity": 3633,
"unit": "block"
},
"genesis_block_hash": "f1af112711150a07f09d796e4731062a5f3e60666f325a071dcb3a95453f0272",
"blockchain_start_time": "1906-08-22T21:33:20.123872129442Z",
"genesis_block_hash": "8dfb5e5d261e25785877564e1560c06b4f55207c5b160a4f054d51af1f00306d",
"blockchain_start_time": "1882-01-28T01:08:48Z",
"desired_pool_number": 1742,
"epoch_length": {
"quantity": 24789,
"quantity": 17463,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 38.097207764414755,
"quantity": 41.24160362212043,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 2971,
"quantity": 7121,
"unit": "second"
},
"decentralization_level": {
"quantity": 80.73,
"quantity": 64.87,
"unit": "percent"
},
"epoch_stability": {
"quantity": 14987,
"quantity": 26035,
"unit": "block"
},
"genesis_block_hash": "4e365b357a766d0b02760f362df3e73b21b5d2365f52007e75f360534754044d",
"blockchain_start_time": "1906-12-13T04:46:01.284275225298Z",
"genesis_block_hash": "645b5c3820a62a72190b397340498f2c15793c4d19234a692637d257d55f207f",
"blockchain_start_time": "1868-07-20T19:00:00Z",
"desired_pool_number": 1253,
"epoch_length": {
"quantity": 17350,
"quantity": 22546,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 5.981136244796314,
"quantity": 75.4233809757601,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 8555,
"quantity": 5096,
"unit": "second"
},
"decentralization_level": {
"quantity": 26.8,
"quantity": 16.74,
"unit": "percent"
},
"epoch_stability": {
"quantity": 16129,
"quantity": 29252,
"unit": "block"
},
"genesis_block_hash": "13aa2072246c4b33103f32734f393d660e40120b6534d22366247f3d41605bde",
"blockchain_start_time": "1878-01-18T02:46:53Z",
"genesis_block_hash": "42612d053e2a9b1e6d122e74223c65015f7342432f7960137e75271a2a537d1d",
"blockchain_start_time": "1907-03-24T21:54:55.587984051255Z",
"desired_pool_number": 1873,
"epoch_length": {
"quantity": 23138,
"quantity": 28293,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 49.91311704166292,
"quantity": 91.91285590796747,
"unit": "percent"
}
}
Expand Down
Expand Up @@ -98,6 +98,7 @@ dummyProtocolParameters :: ProtocolParameters
dummyProtocolParameters = ProtocolParameters
{ decentralizationLevel = minBound
, txParameters = dummyTxParameters
, desiredNumberOfStakePools = 100
}

-- | Construct a @Tx@, computing its hash using the dummy @mkTxId@.
Expand Down
12 changes: 11 additions & 1 deletion lib/core/test/unit/Cardano/Wallet/Api/TypesSpec.hs
Expand Up @@ -778,6 +778,8 @@ spec = do
activeSlotCoefficient (x :: ApiNetworkParameters)
, decentralizationLevel =
decentralizationLevel (x :: ApiNetworkParameters)
, desiredPoolNumber =
desiredPoolNumber (x :: ApiNetworkParameters)
}
in
x' === x .&&. show x' === show x
Expand Down Expand Up @@ -1173,7 +1175,15 @@ instance Arbitrary (Quantity "percent" Double) where
arbitrary = Quantity <$> choose (0,100)

instance Arbitrary ApiNetworkParameters where
arbitrary = genericArbitrary
arbitrary = ApiNetworkParameters
<$> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> choose (1, 2000)
shrink = genericShrink

instance Arbitrary SlotId where
Expand Down
3 changes: 2 additions & 1 deletion lib/core/test/unit/Cardano/Wallet/DB/Arbitrary.hs
Expand Up @@ -571,7 +571,8 @@ rootKeysRnd = unsafePerformIO $ generate (vectorOf 10 genRootKeysRnd)
-------------------------------------------------------------------------------}

instance Arbitrary ProtocolParameters where
arbitrary = ProtocolParameters <$> arbitrary <*> arbitrary
arbitrary =
ProtocolParameters <$> arbitrary <*> arbitrary <*> choose (1, 2000)
shrink = genericShrink

instance Arbitrary TxParameters where
Expand Down
4 changes: 2 additions & 2 deletions specifications/api/swagger.yaml
Expand Up @@ -817,7 +817,7 @@ components:
- epoch_stability
- active_slot_coefficient
- decentralization_level
- desired_number_of_pools
- desired_pool_number
properties:
genesis_block_hash: *blockId
blockchain_start_time: *date
Expand All @@ -826,7 +826,7 @@ components:
epoch_stability: *numberOfBlocks
active_slot_coefficient: *percentage
decentralization_level: *percentage
desired_number_of_pools: *stakePoolsNumber
desired_pool_number: *stakePoolsNumber

ApiSelectCoinsData: &ApiSelectCoinsData
type: object
Expand Down

0 comments on commit ce054d7

Please sign in to comment.