Skip to content

Commit 9f406d0

Browse files
Merge #2268
2268: Remove outdated comments about empty output lists in transactions. r=KtorZ a=jonathanknowles # Issue Number Cleanup after #2247, #2255, and other related PRs. # Overview This PR: * removes a couple of outdated comments about disallowing empty lists of outputs in transactions. It's been established that having an empty list of outputs is perfectly reasonable in certain circumstances (such as a transaction that includes just a delegation certificate). * updates the `Arbitrary ApiTransaction` instance to generate possibly-empty lists of outputs. Co-authored-by: Jonathan Knowles <jonathan.knowles@iohk.io>
2 parents 19a0bf6 + bb6c319 commit 9f406d0

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed

lib/core/src/Cardano/Wallet/Api/Types.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,9 +649,6 @@ data ApiTransaction (n :: NetworkDiscriminant) = ApiTransaction
649649
, depth :: !(Maybe (Quantity "block" Natural))
650650
, direction :: !(ApiT Direction)
651651
, inputs :: ![ApiTxInput n]
652-
-- TODO: Investigate whether the list of outputs should be non-empty, and
653-
-- if so, whether the 'outputs' field can be encoded as a non-empty list.
654-
-- See: https://jira.iohk.io/browse/ADP-400
655652
, outputs :: ![AddressAmount (ApiT Address, Proxy n)]
656653
, withdrawals :: ![ApiWithdrawal n]
657654
, status :: !(ApiT TxStatus)

lib/core/test/unit/Cardano/Wallet/Api/TypesSpec.hs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,6 @@ import Data.FileEmbed
197197
( embedFile, makeRelativeToProject )
198198
import Data.Function
199199
( (&) )
200-
import Data.Generics.Internal.VL.Lens
201-
( view )
202200
import Data.List
203201
( foldl' )
204202
import Data.List.NonEmpty
@@ -1462,10 +1460,7 @@ instance Arbitrary ApiTxMetadata where
14621460
shrink = genericShrink
14631461

14641462
instance Arbitrary (ApiTransaction t) where
1465-
shrink = filter outputsNonEmpty . genericShrink
1466-
where
1467-
outputsNonEmpty :: ApiTransaction t -> Bool
1468-
outputsNonEmpty = (not . null) . view #outputs
1463+
shrink = genericShrink
14691464
arbitrary = do
14701465
txStatus <- arbitrary
14711466
txInsertedAt <- case txStatus of
@@ -1497,15 +1492,8 @@ instance Arbitrary (ApiTransaction t) where
14971492
where
14981493
genInputs =
14991494
Test.QuickCheck.scale (`mod` 3) arbitrary
1500-
-- Note that the generated list of outputs must be non-empty in order
1501-
-- to be consistent with the specification.
1502-
--
1503-
-- Ideally, we should encode this restriction in the type system.
1504-
--
1505-
-- See https://jira.iohk.io/browse/ADP-400.
1506-
genOutputs = (:)
1507-
<$> arbitrary
1508-
<*> Test.QuickCheck.scale (`mod` 3) arbitrary
1495+
genOutputs =
1496+
Test.QuickCheck.scale (`mod` 3) arbitrary
15091497
genWithdrawals =
15101498
Test.QuickCheck.scale (`mod` 3) arbitrary
15111499

0 commit comments

Comments
 (0)