Skip to content

Commit 8e9a655

Browse files
committed
Use applyBlockEither instead of tryRunImpRule @"BBODY" in tryTxsInBlock
1 parent 0a74033 commit 8e9a655

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
@@ -195,6 +195,7 @@ import Cardano.Ledger.Keys (
195195
)
196196
import Cardano.Ledger.Shelley (ShelleyEra)
197197
import Cardano.Ledger.Shelley.API.ByronTranslation (translateToShelleyLedgerStateFromUtxo)
198+
import Cardano.Ledger.Shelley.API.Validation (BlockTransitionError (..), applyBlockEither)
198199
import Cardano.Ledger.Shelley.AdaPots (sumAdaPots, totalAdaPotsES)
199200
import Cardano.Ledger.Shelley.Core
200201
import Cardano.Ledger.Shelley.Genesis (
@@ -211,7 +212,6 @@ import Cardano.Ledger.Shelley.LedgerState (
211212
esLStateL,
212213
lsCertStateL,
213214
lsUTxOStateL,
214-
nesBcurL,
215215
nesELL,
216216
nesEsL,
217217
prevPParamsEpochStateL,
@@ -1426,24 +1426,21 @@ tryTxsInBlock act = do
14261426
pure $ Block {blockHeader, blockBody}
14271427

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

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

14481445
pure $ Right block
14491446

0 commit comments

Comments
 (0)