Skip to content

Commit

Permalink
Add note on MockChain behavior
Browse files Browse the repository at this point in the history
Thel MockChain behaves quite different than the real cardano chain
interfaced through a cardano-node (see FIXME)
  • Loading branch information
ch1bo committed Feb 19, 2024
1 parent a2096b2 commit e1ebdbe
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions hydra-node/test/Hydra/Model/MockChain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Hydra.BehaviorSpec (
SimulatedChainNetwork (..),
)
import Hydra.Cardano.Api.Pretty (renderTxWithUTxO)
import Hydra.Chain (Chain (..), initHistory)
import Hydra.Chain (Chain (..), PostTxError (..), initHistory)
import Hydra.Chain.Direct.Fixture (testNetworkId)
import Hydra.Chain.Direct.Handlers (
ChainSyncHandler (..),
Expand Down Expand Up @@ -149,15 +149,15 @@ mockChainAndNetwork tr seedKeys commits = do
Left err ->
throwSTM . userError . toString $
unlines
[ "Invalid tx submitted"
[ "MockChain: Invalid tx submitted"
, "Tx: " <> toText (renderTxWithUTxO utxo tx)
, "Error: " <> show err
]
Right report
| any isLeft report ->
throwSTM . userError . toString $
unlines
[ "Invalid tx submitted"
[ "MockChain: Invalid tx submitted"
, "Tx: " <> toText (renderTxWithUTxO utxo tx)
, "Error: " <> show (lefts . toList $ report)
]
Expand Down Expand Up @@ -239,6 +239,10 @@ mockChainAndNetwork tr seedKeys commits = do
Nothing ->
pure ()

-- FIXME: This should actually work more like a chain fork / switch to longer
-- chain. That is, the ledger switches to the longer chain state right away
-- and we issue rollback and forwards to synchronize clients. However,
-- submission will already validate against the new ledger state.
rollbackAndForward nodes chain numberOfBlocks = do
doRollBackward nodes chain numberOfBlocks
replicateM_ (fromIntegral numberOfBlocks) $
Expand Down

0 comments on commit e1ebdbe

Please sign in to comment.