@@ -116,6 +116,9 @@ tests =
116116 , testProperty
117117 " script-free tx returns empty execution units map"
118118 prop_evaluateTransaction_no_scripts_empty_exunits
119+ , testProperty
120+ " balanced tx has mempty balance"
121+ prop_evaluateTransaction_balanced_mempty
119122 ]
120123 ]
121124
@@ -745,10 +748,16 @@ prop_makeTransactionBodyAutoBalance_balance_negative = H.property $ do
745748 H. annotate " Expected TxBodyErrorBalanceNegative but tx balanced successfully"
746749 >> H. failure
747750
748- -- | A well-funded transaction returns a positive fee from 'evaluateTransaction'.
749- prop_evaluateTransaction_positive_fee :: Property
750- prop_evaluateTransaction_positive_fee = H. property $ do
751- (unsignedTx, utxo, _changeAddr) <- H. forAll $ genFundedSimpleTx Exp. ConwayEra
751+ -- | Evaluate a simple signed transaction, returning the result and UTxO.
752+ evalSimpleTx
753+ :: Gen
754+ ( Exp. TxEvaluationResult (Exp. LedgerEra Exp. ConwayEra )
755+ , L. UTxO (Exp. LedgerEra Exp. ConwayEra )
756+ , Exp. UnsignedTx (Exp. LedgerEra Exp. ConwayEra )
757+ , L. Addr
758+ )
759+ evalSimpleTx = do
760+ (unsignedTx, utxo, changeAddr) <- genFundedSimpleTx Exp. ConwayEra
752761 let signedTx = Exp. signTx Exp. ConwayEra [] [] unsignedTx
753762 systemStart = Api. SystemStart $ Time. posixSecondsToUTCTime 0
754763 epochInfo =
@@ -764,13 +773,29 @@ prop_evaluateTransaction_positive_fee = H.property $ do
764773 mempty
765774 utxo
766775 signedTx
776+ pure (result, utxo, unsignedTx, changeAddr)
777+
778+ -- | A well-funded transaction returns a positive fee from 'evaluateTransaction'.
779+ prop_evaluateTransaction_positive_fee :: Property
780+ prop_evaluateTransaction_positive_fee = H. property $ do
781+ (result, _utxo, _unsignedTx, _changeAddr) <- H. forAll evalSimpleTx
767782 H. assertWith (Exp. txEvalFee result) (> L. Coin 0 )
768783
769784-- | A script-free transaction returns an empty execution units map.
770785prop_evaluateTransaction_no_scripts_empty_exunits :: Property
771786prop_evaluateTransaction_no_scripts_empty_exunits = H. property $ do
772- (unsignedTx, utxo, _changeAddr) <- H. forAll $ genFundedSimpleTx Exp. ConwayEra
773- let signedTx = Exp. signTx Exp. ConwayEra [] [] unsignedTx
787+ (result, _utxo, _unsignedTx, _changeAddr) <- H. forAll evalSimpleTx
788+ H. assertWith (Exp. txEvalExecutionUnits result) Map. null
789+
790+ -- | A transaction balanced by 'calcMinFeeRecursive' has mempty balance
791+ -- when checked by 'evaluateSignedTx'.
792+ prop_evaluateTransaction_balanced_mempty :: Property
793+ prop_evaluateTransaction_balanced_mempty = H. property $ do
794+ (unsignedTx, utxo, changeAddr) <- H. forAll $ genFundedSimpleTx Exp. ConwayEra
795+ Exp. UnsignedTx balancedLedgerTx <-
796+ H. leftFail $
797+ Exp. calcMinFeeRecursive changeAddr unsignedTx utxo exampleProtocolParams mempty mempty mempty 0
798+ let signedTx = Exp. SignedTx balancedLedgerTx
774799 systemStart = Api. SystemStart $ Time. posixSecondsToUTCTime 0
775800 epochInfo =
776801 Api. LedgerEpochInfo $
@@ -785,7 +810,7 @@ prop_evaluateTransaction_no_scripts_empty_exunits = H.property $ do
785810 mempty
786811 utxo
787812 signedTx
788- H. assertWith ( Exp. txEvalExecutionUnits result) Map. null
813+ Exp. txEvalBalance result H. === mempty
789814
790815-- | Regression test for the bug where 'mapScriptWitnessesCertificates' silently
791816-- dropped certs stored with a @Nothing@ witness (e.g. shelley stake registration
0 commit comments