Skip to content

Commit 5c3a86f

Browse files
committed
Use applyBlockEither instead of tryRunImpRule @"BBODY" in tryTxsInBlock
1 parent 923bc3c commit 5c3a86f

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Era.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Cardano.Ledger.Core
2121
import Cardano.Ledger.Credential
2222
import Cardano.Ledger.Plutus (emptyCostModels)
2323
import Cardano.Ledger.Shelley
24-
import Cardano.Ledger.Shelley.API (ApplyTx)
24+
import Cardano.Ledger.Shelley.API (ApplyBlock, ApplyTx)
2525
import Cardano.Ledger.Shelley.LedgerState
2626
import Cardano.Ledger.Shelley.Scripts
2727
import Cardano.Ledger.Shelley.State
@@ -38,6 +38,7 @@ import Test.Cardano.Ledger.Shelley.TreeDiff ()
3838

3939
class
4040
( EraTest era
41+
, ApplyBlock era
4142
, ApplyTx era
4243
, ShelleyEraScript era
4344
, EraTransition era

eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ import Cardano.Ledger.Keys (
197197
)
198198
import Cardano.Ledger.Shelley (ShelleyEra)
199199
import Cardano.Ledger.Shelley.API.ByronTranslation (translateToShelleyLedgerStateFromUtxo)
200+
import Cardano.Ledger.Shelley.API.Validation (BlockTransitionError (..), applyBlockEither)
200201
import Cardano.Ledger.Shelley.AdaPots (sumAdaPots, totalAdaPotsES)
201202
import Cardano.Ledger.Shelley.Core
202203
import Cardano.Ledger.Shelley.Genesis (
@@ -213,7 +214,6 @@ import Cardano.Ledger.Shelley.LedgerState (
213214
esLStateL,
214215
lsCertStateL,
215216
lsUTxOStateL,
216-
nesBcurL,
217217
nesELL,
218218
nesEsL,
219219
prevPParamsEpochStateL,
@@ -1428,24 +1428,21 @@ tryTxsInBlock act = do
14281428
pure $ Block {blockHeader, blockBody}
14291429

14301430
res <- do
1431+
globals <- use impGlobalsL
14311432
let nes = startingState ^. impNESL
1432-
ls = nes ^. nesEsL . esLStateL
1433-
pp = nes ^. nesEsL . curPParamsEpochStateL @era
1434-
ca = nes ^. chainAccountStateL
1435-
bm = nes ^. nesBcurL
1436-
tryRunImpRule @"BBODY" (BbodyEnv pp ca) (BbodyState ls (BlocksMade bm)) block
1433+
pure $ applyBlockEither EPReturn ValidateAll globals nes block
14371434

14381435
case res of
1439-
Left predFailures -> do
1436+
Left (BlockTransitionError predFailures) -> do
14401437
put startingState
14411438
-- Verify that produced predicate failures are ready for the node-to-client protocol
14421439
liftIO $ forM_ predFailures $ roundTripEraExpectation @era
14431440
pure $ Left (predFailures, block)
1444-
Right (BbodyState bbodyLedgerState _, events) -> do
1441+
Right (blockNes, events) -> do
14451442
let stsEvents = SomeSTSEvent @era @"BBODY" <$> events
1446-
bbodyEvents = startingState ^. impEventsL <> Seq.fromList stsEvents
1447-
impNESL . nesEsL . esLStateL .= bbodyLedgerState
1448-
impEventsL .= bbodyEvents
1443+
blockEvents = startingState ^. impEventsL <> Seq.fromList stsEvents
1444+
impNESL .= blockNes
1445+
impEventsL .= blockEvents
14491446

14501447
pure $ Right block
14511448

0 commit comments

Comments
 (0)