Skip to content

Commit

Permalink
Draft a test to check the blueprint transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch committed Mar 27, 2024
1 parent 0053eb0 commit 00a14e1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion hydra-node/test/Hydra/Chain/Direct/TxSpec.hs
Expand Up @@ -36,21 +36,23 @@ import Hydra.Contract.Initial qualified as Initial
import Hydra.Ledger.Cardano (adaOnly, genOneUTxOFor, genVerificationKey)
import Hydra.Ledger.Cardano.Evaluate (EvaluationReport, maxTxExecutionUnits)
import Hydra.Party (Party)
import Test.Hydra.Fixture (testHeadId)
import Test.QuickCheck (
Property,
choose,
counterexample,
elements,
forAll,
forAllBlind,
generate,
label,
property,
vectorOf,
withMaxSuccess,
(===),
)
import Test.QuickCheck.Instances.Semigroup ()
import Test.QuickCheck.Monadic (monadicIO)
import Test.QuickCheck.Monadic (assert, monadicIO, run)
import Test.QuickCheck.Property (checkCoverage)

spec :: Spec
Expand Down Expand Up @@ -140,6 +142,17 @@ spec =
& counterexample "Failed to construct and observe init tx."
& counterexample (renderTx tx)
& counterexample (show e)
describe "commitTx" $ do
prop "Appends needed commit changes to blueprintTx" $ \blueprintTx -> monadicIO $ do
scriptRegistry <- run $ generate genScriptRegistry
party <- run $ generate arbitrary
utxoToCommit <- run $ generate arbitrary
initialInput <- run $ generate arbitrary
out <- run $ generate arbitrary
vkh <- run $ generate arbitrary
let tx = commitTx testNetworkId scriptRegistry testHeadId party utxoToCommit blueprintTx (initialInput, out, vkh)
-- TODO: assert all untouched tx fields are equal
assert $ blueprintTx == tx

withinTxExecutionBudget :: EvaluationReport -> Property
withinTxExecutionBudget report =
Expand Down

0 comments on commit 00a14e1

Please sign in to comment.