-
Notifications
You must be signed in to change notification settings - Fork 721
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3852: cardano-tracer: init RTView r=deepfire a=denisshevchenko This is pre-MVP for RTView. 3880: Old peers tracing was erroneously called in new tracing r=deepfire a=jutaro /nix/store/qaplqccmisqy8n7ai65nssafzkxyyc7p-cabal-install-exe-cabal-3.6.2.0/bin/cabal --project-file=/home/deepfire/cardano-node/.nix-shell-cabal.project run exe:cardano-node -- +RTS -sghc-rts-report.txt -RTS run --config config.json --database-path run/current/node-0/db-testnet --topology topology.json --host-addr 127.0.0.1 --port 30000 --socket-path node.socket +RTS -N2 -I0 -A16m -qg -qb --disable-delayed-os-memory-return -RTS cardano-node: ExceptionInLinkedThread (ThreadId 11) The name ""peersFromNodeKernel"" is already taken by a metric. CallStack (from HasCallStack): error, called at ./System/Metrics.hs:214:5 in ekg-core-0.1.1.7-FjoslY1tzknIAl90c73kOZ:System.Metrics 3882: Fix datum in tx and ref scripts r=Jimbo4350 a=ch1bo (Couldn't reopen #3881, so created this one) :snowflake: Add a roundtrip property `TxBodyContent -> TxBody -> TxBodyContent` This helped in fixing the :bug: and uncover the two additional gaps in the code. I'm not 100% happy with the current implementation of the property though! I needed to accept two exceptions to the general `===`: 1. `SimpleScriptV1` reference scripts may become `SimpleScriptV2` 2. A `TxOutDatumHash` + a matching `ScriptData` may become a `TxOutDatumTx` :snowflake: Resolve datum hash + matching datum in transaction to `TxOutDatumInTx`, fixes #3866 ❄️ Add missing script languages to `scriptLanguageSupportedInEra` for `BabbageEra` ❄️ Allow scripts in any language as refeference scripts Co-authored-by: Denis Shevchenko <denis.shevchenko@iohk.io> Co-authored-by: Kosyrev Serge <serge.kosyrev@iohk.io> Co-authored-by: Yupanqui <jnf@arcor.de> Co-authored-by: Sebastian Nagel <sebastian.nagel@ncoding.at>
- Loading branch information
Showing
76 changed files
with
6,615 additions
and
165 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
|
||
module Test.Cardano.Api.Typed.TxBody | ||
( tests | ||
) where | ||
|
||
import Cardano.Prelude | ||
|
||
import Hedgehog (Property, annotateShow, failure, (===), MonadTest) | ||
import qualified Hedgehog as H | ||
import Test.Tasty (TestTree) | ||
import Test.Tasty.Hedgehog (testProperty) | ||
import Test.Tasty.TH (testGroupGenerator) | ||
|
||
import Cardano.Api | ||
import Cardano.Api.Shelley (ReferenceScript (..), refScriptToShelleyScript) | ||
import Data.Type.Equality (TestEquality (testEquality)) | ||
import Gen.Cardano.Api.Typed | ||
import Test.Cardano.Api.Typed.Orphans () | ||
|
||
{- HLINT ignore "Use camelCase" -} | ||
|
||
-- | Check the txOuts in a TxBodyContent after a ledger roundtrip. | ||
prop_roundtrip_txbodycontent_txouts:: Property | ||
prop_roundtrip_txbodycontent_txouts = | ||
H.property $ do | ||
content <- H.forAll $ genTxBodyContent BabbageEra | ||
-- Create the ledger body & auxiliaries | ||
body <- case makeTransactionBody content of | ||
Left err -> annotateShow err >> failure | ||
Right body -> pure body | ||
annotateShow body | ||
-- Convert ledger body back via 'getTxBodyContent' and 'fromLedgerTxBody' | ||
let (TxBody content') = body | ||
matchTxOuts (txOuts content) (txOuts content') | ||
where | ||
matchTxOuts :: MonadTest m => [TxOut CtxTx BabbageEra] -> [TxOut CtxTx BabbageEra] -> m () | ||
matchTxOuts as bs = | ||
mapM_ matchTxOut $ zip as bs | ||
|
||
matchTxOut :: MonadTest m => (TxOut CtxTx BabbageEra, TxOut CtxTx BabbageEra) -> m () | ||
matchTxOut (a, b) = do | ||
let TxOut aAddress aValue aDatum aRefScript = a | ||
let TxOut bAddress bValue bDatum bRefScript = b | ||
aAddress === bAddress | ||
aValue === bValue | ||
matchDatum (aDatum, bDatum) | ||
matchRefScript (aRefScript, bRefScript) | ||
|
||
-- NOTE: We accept TxOutDatumInTx instead of TxOutDatumHash as it may be | ||
-- correctly resolved given a datum matching the hash was generated. | ||
matchDatum :: MonadTest m => (TxOutDatum CtxTx era, TxOutDatum CtxTx era) -> m () | ||
matchDatum = \case | ||
(TxOutDatumHash _ dh, TxOutDatumInTx _ d) -> | ||
dh === hashScriptData d | ||
(a, b) -> | ||
a === b | ||
|
||
-- NOTE: After Allegra, all eras interpret SimpleScriptV1 as SimpleScriptV2 | ||
-- because V2 is a superset of V1. So we accept that as a valid conversion. | ||
matchRefScript :: MonadTest m => (ReferenceScript BabbageEra, ReferenceScript BabbageEra) -> m () | ||
matchRefScript (a, b) | ||
| isSimpleScriptV1 a && isSimpleScriptV2 b = | ||
refScriptToShelleyScript BabbageEra a === refScriptToShelleyScript BabbageEra b | ||
| otherwise = | ||
a === b | ||
|
||
isSimpleScriptV1 :: ReferenceScript era -> Bool | ||
isSimpleScriptV1 = isLang (SimpleScriptLanguage SimpleScriptV1) | ||
|
||
isSimpleScriptV2 :: ReferenceScript era -> Bool | ||
isSimpleScriptV2 = isLang (SimpleScriptLanguage SimpleScriptV2) | ||
|
||
isLang :: ScriptLanguage a -> ReferenceScript era -> Bool | ||
isLang expected = \case | ||
(ReferenceScript _ (ScriptInAnyLang actual _)) -> isJust $ testEquality expected actual | ||
_ -> False | ||
|
||
tests :: TestTree | ||
tests = $testGroupGenerator |
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
Oops, something went wrong.