Skip to content

Commit

Permalink
Issue #263: adds a coverage test for UTxO
Browse files Browse the repository at this point in the history
  • Loading branch information
mdimjasevic committed Jul 17, 2019
1 parent c5d2591 commit ed339b6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions byron/ledger/executable-spec/test/Ledger/UTxO/Properties.hs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ relevantCasesAreCovered = withTests 400 $ property $ do

cover 20 "avg. nr. of tx outputs (1,5]" (1 <= avgOutputs && avgOutputs <= 5)
cover 20 "avg. nr. of tx outputs (5,10]" (5 < avgOutputs && avgOutputs <= 10)

cover 80 "starting UTxO has no future outputs" (all (== empty) (futureOutputs tr))
where
-- | The average "fee surplus" for transactions in the trace.
-- Could be zero if all the transactions had zero surplus fee.
Expand All @@ -116,6 +118,16 @@ relevantCasesAreCovered = withTests 400 $ property $ do
fee = unLovelace $ balance (txins tx_ utxo_) - balance (txouts tx_)
minFee = unLovelace $ txMinFee tx_

-- | The intersection of the starting UTxO and each transaction in
-- a trace
futureOutputs :: Trace UTXOW -> [Set TxIn]
futureOutputs tr =
let
UTxOState {utxo = utxo0} = _traceInitState tr
txs = body <$> traceSignals OldestFirst tr
in
(\ti -> dom (txouts ti) dom utxo0) <$> txs

-- | Returns the average number of inputs and outputs for a list of transactions.
avgInputsOutputs :: [Tx] -> (Double, Double)
avgInputsOutputs txs
Expand Down

0 comments on commit ed339b6

Please sign in to comment.