-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filling in missing babbage unit tests #3326
Merged
iohk-bors
merged 5 commits into
master
from
paweljakubas/adp-1885/fillin-missing-babbage-unit-tests
Jun 19, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4e01476
deal with BabbageEra missing tests in core unit tests
paweljakubas e9d2278
extend forAllEras to babbage in shelley unit tests
paweljakubas a530d98
extend genTxInEra
paweljakubas 4f97338
unpend byron witnesses tests in shelley core unit tests
paweljakubas f5cff1c
pospone calculateBinary testing for Alonzo/Babbage until ledger fix
paweljakubas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
{-# LANGUAGE TupleSections #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
{-# LANGUAGE TypeOperators #-} | ||
{-# LANGUAGE UndecidableInstances #-} | ||
{- HLINT ignore "Use null" -} | ||
|
||
|
@@ -212,7 +213,8 @@ import Cardano.Wallet.Shelley.Compatibility | |
import Cardano.Wallet.Shelley.Compatibility.Ledger | ||
( toAlonzoTxOut ) | ||
import Cardano.Wallet.Shelley.Transaction | ||
( TxSkeleton (..) | ||
( EraConstraints | ||
, TxSkeleton (..) | ||
, TxUpdate (..) | ||
, TxWitnessTag (..) | ||
, TxWitnessTagFor | ||
|
@@ -221,6 +223,7 @@ import Cardano.Wallet.Shelley.Transaction | |
, estimateTxCost | ||
, estimateTxSize | ||
, maximumCostOfIncreasingCoin | ||
, mkByronWitness | ||
, mkDelegationCertificates | ||
, mkShelleyWitness | ||
, mkTxSkeleton | ||
|
@@ -318,7 +321,6 @@ import System.FilePath | |
import Test.Hspec | ||
( Spec | ||
, SpecWith | ||
, before_ | ||
, describe | ||
, expectationFailure | ||
, it | ||
|
@@ -982,6 +984,7 @@ forAllShelleyBasedEras eraSpec = do | |
eraSpec (AnyCardanoEra AllegraEra) | ||
eraSpec (AnyCardanoEra MaryEra) | ||
eraSpec (AnyCardanoEra AlonzoEra) | ||
eraSpec (AnyCardanoEra BabbageEra) | ||
|
||
allEras :: [(Int, AnyCardanoEra)] | ||
allEras = | ||
|
@@ -990,6 +993,7 @@ allEras = | |
, (3, AnyCardanoEra AllegraEra) | ||
, (4, AnyCardanoEra MaryEra) | ||
, (5, AnyCardanoEra AlonzoEra) | ||
, (6, AnyCardanoEra BabbageEra) | ||
] | ||
|
||
eraNum :: AnyCardanoEra -> Int | ||
|
@@ -998,11 +1002,6 @@ eraNum e = fst $ head $ filter ((== e) . snd) allEras | |
shelleyEraNum :: AnyShelleyBasedEra -> Int | ||
shelleyEraNum = eraNum . shelleyToCardanoEra | ||
|
||
pendingOnAlonzo :: String -> ShelleyBasedEra era -> SpecWith a -> SpecWith a | ||
pendingOnAlonzo msg era = before_ $ case era of | ||
Cardano.ShelleyBasedEraAlonzo -> pendingWith ("AlonzoEra: " ++ msg) | ||
_ -> pure () | ||
|
||
instance Arbitrary AnyCardanoEra where | ||
arbitrary = frequency $ zip [1..] $ map (pure . snd) allEras | ||
-- Shrink by choosing a *later* era | ||
|
@@ -1399,13 +1398,23 @@ binaryCalculationsSpec :: AnyCardanoEra -> Spec | |
binaryCalculationsSpec (AnyCardanoEra era) = | ||
case cardanoEraStyle era of | ||
LegacyByronEra -> pure () | ||
ShelleyBasedEra shelleyEra -> | ||
-- TODO: [ADP-919] tests for byron witnesses | ||
pendingOnAlonzo "Golden transactions not yet updated" shelleyEra $ | ||
before_ (pendingWith ("Will return with signTx PR")) $ | ||
binaryCalculationsSpec' shelleyEra | ||
|
||
binaryCalculationsSpec' :: IsShelleyBasedEra era => ShelleyBasedEra era -> Spec | ||
ShelleyBasedEra shelleyEra -> case shelleyEra of | ||
ShelleyBasedEraShelley -> | ||
binaryCalculationsSpec' @Cardano.ShelleyEra shelleyEra | ||
ShelleyBasedEraAllegra -> | ||
binaryCalculationsSpec' @Cardano.AllegraEra shelleyEra | ||
ShelleyBasedEraMary -> | ||
binaryCalculationsSpec' @Cardano.MaryEra shelleyEra | ||
ShelleyBasedEraAlonzo -> | ||
pure () -- TO_DO when ledger's PR 2863 is included in node bump | ||
--binaryCalculationsSpec' @Cardano.AlonzoEra shelleyEra | ||
ShelleyBasedEraBabbage -> | ||
pure () -- TO_DO when ledger's PR 2863 is included in node bump | ||
--binaryCalculationsSpec' @Cardano.BabbageEra shelleyEra | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👌 |
||
|
||
binaryCalculationsSpec' | ||
:: forall era. EraConstraints era | ||
=> ShelleyBasedEra era -> Spec | ||
binaryCalculationsSpec' era = describe ("calculateBinary - "+||era||+"") $ do | ||
describe "Byron witnesses - mainnet" $ do | ||
let net = Cardano.Mainnet | ||
|
@@ -1558,12 +1567,12 @@ binaryCalculationsSpec' era = describe ("calculateBinary - "+||era||+"") $ do | |
where | ||
slotNo = SlotNo 7750 | ||
md = Nothing | ||
calculateBinary _net utxo outs chgs pairs = | ||
calculateBinary net utxo outs chgs pairs = | ||
hex (Cardano.serialiseToCBOR ledgerTx) | ||
where | ||
ledgerTx = Cardano.makeSignedTransaction addrWits unsigned | ||
mkByronWitness' _unsignedTx (_, (TxOut _addr _)) = | ||
error "mkByronWitness'" -- TODO: [ADP-919] | ||
mkByronWitness' unsignedTx (_, (TxOut addr _)) = | ||
mkByronWitness @era unsignedTx net addr | ||
addrWits = zipWith (mkByronWitness' unsigned) inps pairs | ||
fee = toCardanoLovelace $ selectionDelta txOutCoin cs | ||
Right unsigned = | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍