|
1 | 1 | {-# LANGUAGE BangPatterns #-} |
2 | 2 | {-# LANGUAGE DataKinds #-} |
3 | 3 | {-# LANGUAGE FlexibleContexts #-} |
4 | | -{-# LANGUAGE NamedFieldPuns #-} |
5 | 4 | {-# LANGUAGE NumericUnderscores #-} |
6 | 5 | {-# LANGUAGE OverloadedLists #-} |
7 | 6 | {-# LANGUAGE PatternSynonyms #-} |
8 | 7 | {-# LANGUAGE ScopedTypeVariables #-} |
9 | 8 | {-# LANGUAGE TypeApplications #-} |
10 | 9 |
|
11 | | -module Test.Cardano.Ledger.Conway.Imp.BbodySpec ( |
12 | | - spec, |
13 | | -) where |
| 10 | +module Test.Cardano.Ledger.Conway.Imp.BbodySpec (spec) where |
14 | 11 |
|
15 | | -import Cardano.Ledger.BHeaderView (BHeaderView (..)) |
16 | 12 | import Cardano.Ledger.Babbage.Core |
17 | | -import Cardano.Ledger.BaseTypes (BlocksMade (..), Mismatch (..), ProtVer (..), natVersion) |
18 | | -import Cardano.Ledger.Block |
| 13 | +import Cardano.Ledger.BaseTypes (Mismatch (..), ProtVer (..), natVersion) |
19 | 14 | import Cardano.Ledger.Coin (Coin (..)) |
20 | 15 | import Cardano.Ledger.Conway.PParams (ConwayEraPParams (..)) |
21 | 16 | import Cardano.Ledger.Conway.Rules ( |
22 | 17 | ConwayBbodyPredFailure (..), |
23 | 18 | totalRefScriptSizeInBlock, |
24 | 19 | ) |
25 | | -import Cardano.Ledger.Conway.State |
26 | 20 | import Cardano.Ledger.Plutus (SLanguage (..), hashPlutusScript) |
27 | | -import Cardano.Ledger.Shelley.LedgerState |
28 | | -import Cardano.Ledger.Shelley.Rules ( |
29 | | - BbodyEnv (..), |
30 | | - ShelleyBbodyState (..), |
31 | | - ) |
32 | 21 | import Cardano.Ledger.Shelley.Scripts ( |
33 | 22 | pattern RequireSignature, |
34 | 23 | ) |
35 | 24 | import Cardano.Ledger.TxIn |
36 | 25 | import Control.Monad (forM) |
37 | 26 | import Data.List.NonEmpty (NonEmpty (..)) |
38 | 27 | import qualified Data.List.NonEmpty as NE |
39 | | -import qualified Data.Map as Map |
40 | 28 | import qualified Data.Sequence.Strict as SSeq |
41 | 29 | import Data.Word (Word32) |
42 | 30 | import Lens.Micro ((&), (.~), (^.)) |
43 | | -import Lens.Micro.Mtl (use) |
44 | 31 | import Test.Cardano.Ledger.Babbage.ImpTest |
45 | 32 | import Test.Cardano.Ledger.Conway.ImpTest (ConwayEraImp) |
46 | 33 | import Test.Cardano.Ledger.Core.Utils (txInAt) |
@@ -82,7 +69,7 @@ spec = do |
82 | 69 | >>= updateAddrTxWits |
83 | 70 |
|
84 | 71 | let expectedTotalRefScriptSize = scriptSize * sum txScriptCounts |
85 | | - predFailures <- expectLeftExpr =<< tryRunBBODY txs |
| 72 | + predFailures <- expectLeftExpr =<< tryRunImpBBODY txs |
86 | 73 | predFailures |
87 | 74 | `shouldBe` NE.fromList |
88 | 75 | [ injectFailure |
@@ -129,7 +116,7 @@ spec = do |
129 | 116 | pure $ refScriptTxs ++ [spendTx] |
130 | 117 | ) |
131 | 118 |
|
132 | | - predFailures <- expectLeftExpr =<< tryRunBBODY txs |
| 119 | + predFailures <- expectLeftExpr =<< tryRunImpBBODY txs |
133 | 120 | predFailures |
134 | 121 | `shouldBe` NE.fromList |
135 | 122 | [ injectFailure |
@@ -267,25 +254,6 @@ spec = do |
267 | 254 | <$> getUTxO |
268 | 255 | `shouldReturn` (if isPostV10 protVer then scriptSize else 0) |
269 | 256 | where |
270 | | - tryRunBBODY txs = do |
271 | | - let blockBody = mkBasicBlockBody @era & txSeqBlockBodyL .~ SSeq.fromList txs |
272 | | - nes <- use impNESL |
273 | | - let ls = nes ^. nesEsL . esLStateL |
274 | | - pp = nes ^. nesEsL . curPParamsEpochStateL @era |
275 | | - kh <- freshKeyHash |
276 | | - slotNo <- use impCurSlotNoG |
277 | | - let bhView = |
278 | | - BHeaderView |
279 | | - { bhviewID = kh |
280 | | - , bhviewBSize = fromIntegral $ bBodySize (ProtVer (eraProtVerLow @era) 0) blockBody |
281 | | - , bhviewHSize = 0 |
282 | | - , bhviewBHash = hashBlockBody blockBody |
283 | | - , bhviewSlot = slotNo |
284 | | - } |
285 | | - tryRunImpRule @"BBODY" |
286 | | - (BbodyEnv pp (nes ^. chainAccountStateL)) |
287 | | - (BbodyState ls (BlocksMade Map.empty)) |
288 | | - (Block {blockHeader = bhView, blockBody}) |
289 | 257 | isPostV10 protVer = pvMajor protVer >= natVersion @11 |
290 | 258 |
|
291 | 259 | -- Generate a list of integers such that the sum of their multiples by scale is greater than toExceed |
|
0 commit comments