Skip to content

Commit

Permalink
Generate possibly-empty lists of outputs in Arbitrary ApiTransaction.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed Oct 26, 2020
1 parent ed61124 commit 737f489
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions lib/core/test/unit/Cardano/Wallet/Api/TypesSpec.hs
Expand Up @@ -1462,10 +1462,7 @@ instance Arbitrary ApiTxMetadata where
shrink = genericShrink

instance Arbitrary (ApiTransaction t) where
shrink = filter outputsNonEmpty . genericShrink
where
outputsNonEmpty :: ApiTransaction t -> Bool
outputsNonEmpty = (not . null) . view #outputs
shrink = genericShrink
arbitrary = do
txStatus <- arbitrary
txInsertedAt <- case txStatus of
Expand Down Expand Up @@ -1497,15 +1494,8 @@ instance Arbitrary (ApiTransaction t) where
where
genInputs =
Test.QuickCheck.scale (`mod` 3) arbitrary
-- Note that the generated list of outputs must be non-empty in order
-- to be consistent with the specification.
--
-- Ideally, we should encode this restriction in the type system.
--
-- See https://jira.iohk.io/browse/ADP-400.
genOutputs = (:)
<$> arbitrary
<*> Test.QuickCheck.scale (`mod` 3) arbitrary
genOutputs =
Test.QuickCheck.scale (`mod` 3) arbitrary
genWithdrawals =
Test.QuickCheck.scale (`mod` 3) arbitrary

Expand Down

0 comments on commit 737f489

Please sign in to comment.