-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
99 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Imp/BbodySpec.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{-# LANGUAGE BangPatterns #-} | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
|
||
module Test.Cardano.Ledger.Shelley.Imp.BbodySpec ( | ||
spec, | ||
) where | ||
|
||
import Cardano.Ledger.BHeaderView (BHeaderView (..)) | ||
import Cardano.Ledger.BaseTypes (BlocksMade (..), ProtVer (..), ShelleyBase, SlotNo (..), inject) | ||
import Cardano.Ledger.Block | ||
import Cardano.Ledger.Coin (Coin (..)) | ||
import Cardano.Ledger.Shelley.Core | ||
import Cardano.Ledger.Shelley.LedgerState | ||
import Cardano.Ledger.Shelley.Rules ( | ||
BbodyEnv (..), | ||
Event, | ||
LedgerEnv (..), | ||
ShelleyBbodyState (..), | ||
) | ||
import Cardano.Ledger.Shelley.UTxO (UTxO (..)) | ||
import Control.Monad.State.Strict (MonadState (..), gets) | ||
import Control.State.Transition.Extended (STS (..)) | ||
import Data.Bifunctor (first) | ||
import qualified Data.Map as Map | ||
import qualified Data.Map.Strict as Map | ||
import qualified Data.Sequence.Strict as SSeq | ||
import qualified Data.Set as Set | ||
import Debug.Trace | ||
import Lens.Micro ((&), (.~), (^.)) | ||
import Lens.Micro.Mtl | ||
import Test.Cardano.Ledger.Core.KeyPair (mkAddr) | ||
import Test.Cardano.Ledger.Core.Utils (txInAt) | ||
import Test.Cardano.Ledger.Imp.Common | ||
import Test.Cardano.Ledger.Shelley.ImpTest | ||
|
||
spec :: | ||
forall era. | ||
( ShelleyEraImp era | ||
, EraSegWits era | ||
) => | ||
SpecWith (ImpTestState era) | ||
spec = describe "BBODY" $ do | ||
it "Works" $ do | ||
let !_ = trace ("\n Works??" <> (show True) <> "\n") True | ||
nes <- use impNESL | ||
LedgerEnv {ledgerPp, ledgerAccount} <- impLedgerEnv nes | ||
let env = BbodyEnv ledgerPp ledgerAccount | ||
let ls = nes ^. nesEsL . esLStateL | ||
let state = BbodyState ls (BlocksMade Map.empty) | ||
kh <- freshKeyHash | ||
tx <- fixupTx $ mkBasicTx mkBasicTxBody | ||
let txSeq = toTxSeq @era $ SSeq.fromList [tx] | ||
let bhView = | ||
BHeaderView | ||
{ bhviewID = kh | ||
, bhviewBSize = fromIntegral $ bBodySize (ProtVer (eraProtVerLow @era) 0) txSeq | ||
, bhviewHSize = 0 | ||
, bhviewBHash = hashTxSeq txSeq | ||
, bhviewSlot = SlotNo 0 | ||
} | ||
let signal = UnsafeUnserialisedBlock bhView txSeq | ||
res <- | ||
tryRunImpRule @"BBODY" | ||
env | ||
state | ||
(UnsafeUnserialisedBlock bhView txSeq) | ||
expectRight res | ||
pure () | ||
|
||
-- expectRightDeepExpr $ first fst res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters