From ed339b6efc49f8c1a1884a3471dc51a9c024336a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Dimja=C5=A1evi=C4=87?= Date: Wed, 17 Jul 2019 14:57:44 +0200 Subject: [PATCH] Issue #263: adds a coverage test for UTxO --- .../executable-spec/test/Ledger/UTxO/Properties.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/byron/ledger/executable-spec/test/Ledger/UTxO/Properties.hs b/byron/ledger/executable-spec/test/Ledger/UTxO/Properties.hs index 1e992bcc809..00766060951 100644 --- a/byron/ledger/executable-spec/test/Ledger/UTxO/Properties.hs +++ b/byron/ledger/executable-spec/test/Ledger/UTxO/Properties.hs @@ -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. @@ -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