Skip to content

Commit

Permalink
Improve BehaviorSpec
Browse files Browse the repository at this point in the history
Make sure utxoToDecommit is not fanned out and close with decommit in
place will fanout both utxos present.
  • Loading branch information
v0d1ch committed May 30, 2024
1 parent 0ba5973 commit 735ba8f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion hydra-node/test/Hydra/BehaviorSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,19 @@ spec = parallel $ do
waitUntil [n1, n2] $ DecommitApproved{headId = testHeadId, utxoToDecommit = utxoRefs [22]}
waitUntil [n1, n2] $ DecommitFinalized{headId = testHeadId}

it "can close with decommit in flight" $
shouldRunInSim $ do
withSimulatedChainAndNetwork $ \chain ->
withHydraNode aliceSk [bob] chain $ \n1 -> do
withHydraNode bobSk [alice] chain $ \n2 -> do
openHead chain n1 n2
let decommitTx = SimpleTx 1 (utxoRef 2) (utxoRef 42)
send n2 (Decommit{decommitTx})
send n1 Close
waitUntil [n1, n2] $ ReadyToFanout{headId = testHeadId}
send n1 Fanout
waitUntil [n1, n2] $ HeadIsFinalized{headId = testHeadId, utxo = utxoRefs [1, 2]}

it "fanout utxo is correct after a decommit" $
shouldRunInSim $ do
withSimulatedChainAndNetwork $ \chain ->
Expand All @@ -440,10 +453,11 @@ spec = parallel $ do
openHead chain n1 n2
let decommitTx = SimpleTx 1 (utxoRef 1) (utxoRef 42)
send n2 (Decommit{decommitTx})
waitUntil [n1, n2] $ DecommitApproved{headId = testHeadId, utxoToDecommit = utxoRefs [42]}
send n1 Close
waitUntil [n1, n2] $ ReadyToFanout{headId = testHeadId}
send n1 Fanout
waitUntil [n1, n2] $ HeadIsFinalized{headId = testHeadId, utxo = utxoRefs [1, 2]}
waitUntil [n1, n2] $ HeadIsFinalized{headId = testHeadId, utxo = utxoRefs [2]}

it "can be finalized by all parties after contestation period" $
shouldRunInSim $ do
Expand Down

0 comments on commit 735ba8f

Please sign in to comment.