Skip to content

Commit

Permalink
Try #2462:
Browse files Browse the repository at this point in the history
  • Loading branch information
iohk-bors[bot] committed Jan 28, 2021
2 parents 736ad57 + 0f6dc0a commit f7cb1b6
Show file tree
Hide file tree
Showing 33 changed files with 1,323 additions and 5,231 deletions.
2 changes: 0 additions & 2 deletions lib/core-integration/cardano-wallet-core-integration.cabal
Expand Up @@ -30,7 +30,6 @@ library
-Werror
build-depends:
HUnit
, QuickCheck
, aeson
, aeson-qq
, base
Expand Down Expand Up @@ -109,6 +108,5 @@ library
Test.Integration.Scenario.CLI.Miscellaneous
Test.Integration.Scenario.CLI.Network
Test.Integration.Scenario.CLI.Port
Cardano.Wallet.TransactionSpecShared
Cardano.Wallet.LatencyBenchShared
Cardano.Wallet.BenchShared
65 changes: 0 additions & 65 deletions lib/core-integration/src/Cardano/Wallet/TransactionSpecShared.hs

This file was deleted.

70 changes: 19 additions & 51 deletions lib/core-integration/src/Test/Integration/Framework/TestData.hs
Expand Up @@ -38,11 +38,9 @@ module Test.Integration.Framework.TestData
, errMsg400WalletIdEncoding
, errMsg400StartTimeLaterThanEndTime
, errMsg403Fee
, errMsg403DelegationFee
, errMsg403NotAByronWallet
, errMsg403NotAnIcarusWallet
, errMsg403NotEnoughMoney
, errMsg403NotEnoughMoney_
, errMsg403WrongPass
, errMsg403AlreadyInLedger
, errMsg404NoSuchPool
Expand Down Expand Up @@ -71,9 +69,7 @@ module Test.Integration.Framework.TestData
, errMsg400MinWithdrawalWrong
, errMsg403WithdrawalNotWorth
, errMsg403NotAShelleyWallet
, errMsg403InputsDepleted
, errMsg404MinUTxOValue
, errMsg403TxTooLarge
, errMsg403MinUTxOValue
, errMsg403CouldntIdentifyAddrAsMine
, errMsg503PastHorizon
) where
Expand All @@ -86,8 +82,6 @@ import Data.Text
( Text, pack, unpack )
import Data.Word
( Word32 )
import Numeric.Natural
( Natural )
import Test.Integration.Framework.DSL
( Payload (..), fixturePassphrase, json )

Expand Down Expand Up @@ -225,19 +219,13 @@ versionLine = "Running as v" <> pack (showFullVersion version gitRevision)
--- Error messages
---

errMsg403InputsDepleted :: String
errMsg403InputsDepleted = "I cannot select enough UTxO from your wallet to construct\
\ an adequate transaction. Try sending a smaller amount or increasing the number\
\ of available UTxO."

errMsg404MinUTxOValue :: Natural -> String
errMsg404MinUTxOValue minUTxOValue = mconcat
[ "I'm unable to construct the given transaction as some outputs or changes"
, " are too small! Each output and change is expected to be >= "
, (show minUTxOValue)
, " Lovelace. In the current transaction the following pieces are not"
, " satisfying this condition"
]
errMsg403MinUTxOValue :: String
errMsg403MinUTxOValue =
"Some outputs specifies an Ada value that is too small. Indeed, there's a \
\minimum Ada value specified by the protocol that each output must satisfy. \
\I'll handle that minimum value myself when you do not explicitly specify \
\an Ada value for outputs. Otherwise, you must specify enough Ada."

errMsg409WalletExists :: String -> String
errMsg409WalletExists walId = "This operation would yield a wallet with the following\
\ id: " ++ walId ++ " However, I already know of a wallet with this id."
Expand All @@ -256,15 +244,9 @@ errMsg400StartTimeLaterThanEndTime startTime endTime = mconcat
]

errMsg403Fee :: String
errMsg403Fee = "I'm unable to adjust the given transaction to cover the\
\ associated fee! In order to do so, I'd have to select one or\
\ more additional inputs, but I can't do that without increasing\
\ the size of the transaction beyond the acceptable limit."

errMsg403DelegationFee :: Natural -> String
errMsg403DelegationFee n =
"I'm unable to select enough coins to pay for a delegation certificate. \
\I need: " ++ show n ++ " Lovelace."
errMsg403Fee =
"I am unable to finalize the transaction as there are not enough Ada I can \
\use to pay for either fees, or minimum Ada value in change outputs."

errMsg403NotAByronWallet :: String
errMsg403NotAByronWallet =
Expand All @@ -276,26 +258,16 @@ errMsg403NotAnIcarusWallet =
"I cannot derive new address for this wallet type.\
\ Make sure to use a sequential wallet style, like Icarus."

errMsg403NotEnoughMoney_ :: String
errMsg403NotEnoughMoney_ =
"I can't process this payment because there's not enough UTxO available in \
errMsg403NotEnoughMoney :: String
errMsg403NotEnoughMoney =
"I can't process this payment because there's not enough funds available in \
\the wallet."

errMsg403NotEnoughMoney :: Integral i => i -> i -> String
errMsg403NotEnoughMoney has needs = "I can't process this payment because there's\
\ not enough UTxO available in the wallet. The total UTxO sums up to\
\ " ++ has' ++ " Lovelace, but I need " ++ needs' ++ " Lovelace\
\ (excluding fee amount) in order to proceed with the payment."

where
needs' = show (toInteger needs)
has' = show (toInteger has)

errMsg403TxTooBig :: Int -> String
errMsg403TxTooBig n = "I had to select " ++ show n ++ " inputs to construct the\
\ requested transaction. Unfortunately, this would create a transaction\
\ that is too big, and this would consequently be rejected by a core node.\
\ Try sending a smaller amount."
errMsg403TxTooBig :: String
errMsg403TxTooBig =
"I am not able to finalize the transaction because I need to select \
\additional inputs and doing so will make the transaction too big. \
\Try sending a smaller amount."

errMsg400MalformedTxPayload :: String
errMsg400MalformedTxPayload =
Expand All @@ -311,10 +283,6 @@ errMsg400TxMetadataStringTooLong :: String
errMsg400TxMetadataStringTooLong =
"Text string metadata value must consist of at most 64 UTF8 bytes"

errMsg403TxTooLarge :: String
errMsg403TxTooLarge =
"I am afraid that the transaction you're trying to submit is too large!"

errMsg400ParseError :: String
errMsg400ParseError = mconcat
[ "I couldn't understand the content of your message. If your "
Expand Down
Expand Up @@ -56,7 +56,6 @@ import Test.Integration.Framework.DSL
, expectField
, expectResponseCode
, fixtureIcarusWallet
, fixtureIcarusWalletWith
, listAddresses
, minUTxOValue
, request
Expand Down Expand Up @@ -160,34 +159,3 @@ spec = describe "BYRON_COIN_SELECTION" $ do
[ expectResponseCode HTTP.status404
, expectErrorMessage (errMsg404NoWallet $ icW ^. walletId)
]

it "BYRON_COIN_SELECTION_05 - \
\No change when payment fee eats leftovers due to minUTxOValue" $
\ctx -> runResourceT $ do
source <- fixtureIcarusWalletWith @n ctx [minUTxOValue, minUTxOValue]
target <- emptyWallet ctx

targetAddress:_ <- fmap (view #id) <$> listAddresses @n ctx target
let amt = Quantity minUTxOValue
let payment = AddressAmount targetAddress amt mempty
let output = ApiCoinSelectionOutput targetAddress amt
let isValidDerivationPath path =
( length path == 5 )
&&
( [ ApiT $ DerivationIndex $ getIndex purposeBIP44
, ApiT $ DerivationIndex $ getIndex coinTypeAda
, ApiT $ DerivationIndex $ getIndex @'Hardened minBound
] `isPrefixOf` NE.toList path
)
selectCoins @_ @'Byron ctx source (payment :| []) >>= flip verify
[ expectResponseCode HTTP.status200
, expectField #inputs
(`shouldSatisfy` (not . null))
, expectField #inputs
(`shouldSatisfy` all
(isValidDerivationPath . view #derivationPath))
, expectField #change
(`shouldSatisfy` null)
, expectField #outputs
(`shouldBe` [output])
]
Expand Up @@ -61,7 +61,7 @@ import Data.Text
import Data.Word
( Word64 )
import Test.Hspec
( SpecWith, describe, shouldBe, shouldSatisfy )
( SpecWith, describe, pendingWith, shouldBe, shouldSatisfy )
import Test.Hspec.Extra
( it )
import Test.Integration.Framework.DSL
Expand Down Expand Up @@ -119,6 +119,7 @@ spec = describe "BYRON_MIGRATIONS" $ do
\for non-empty wallet calculated fee is > zero."
$ \ctx -> forM_ [fixtureRandomWallet, fixtureIcarusWallet]
$ \fixtureByronWallet -> runResourceT $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
w <- fixtureByronWallet ctx
let ep = Link.getMigrationInfo @'Byron w
r <- request @ApiWalletMigrationInfo ctx ep Default Empty
Expand All @@ -132,6 +133,7 @@ spec = describe "BYRON_MIGRATIONS" $ do
\Cannot calculate fee for empty wallet."
$ \ctx -> forM_ [emptyRandomWallet, emptyIcarusWallet]
$ \emptyByronWallet -> runResourceT $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
w <- emptyByronWallet ctx
let ep = Link.getMigrationInfo @'Byron w
r <- request @ApiWalletMigrationInfo ctx ep Default Empty
Expand All @@ -143,6 +145,7 @@ spec = describe "BYRON_MIGRATIONS" $ do
it "BYRON_CALCULATE_02 - \
\Cannot calculate fee for wallet with dust, that cannot be migrated."
$ \ctx -> runResourceT $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
-- NOTE
-- Special mnemonic for which wallet with dust
-- (5 utxo with 60 lovelace)
Expand All @@ -166,6 +169,7 @@ spec = describe "BYRON_MIGRATIONS" $ do
it "BYRON_CALCULATE_03 - \
\Cannot estimate migration for Shelley wallet using Byron endpoint"
$ \ctx -> runResourceT $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
w <- emptyWallet ctx
let ep = Link.getMigrationInfo @'Byron w
r <- request @ApiWalletMigrationInfo ctx ep Default Empty
Expand All @@ -178,6 +182,7 @@ spec = describe "BYRON_MIGRATIONS" $ do
] $ \(walType, destWallet) -> do

it ("From wallet type: " ++ walType) $ \ctx -> runResourceT $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
--shelley address
wShelley <- emptyWallet ctx
addrs <- listAddresses @n ctx wShelley
Expand All @@ -204,6 +209,7 @@ spec = describe "BYRON_MIGRATIONS" $ do
]

it "BYRON_MIGRATE_07 - invalid payload, parser error" $ \ctx -> runResourceT $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
sourceWallet <- emptyRandomWallet ctx

r <- request @[ApiTransaction n] ctx
Expand All @@ -224,6 +230,7 @@ spec = describe "BYRON_MIGRATIONS" $ do

Hspec.it "BYRON_MIGRATE_01 - \
\ migrate a big wallet requiring more than one tx" $ \ctx -> runResourceT @IO $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
-- NOTE
-- Special mnemonic for which 200 legacy funds are attached to in the
-- genesis file.
Expand Down Expand Up @@ -313,6 +320,7 @@ spec = describe "BYRON_MIGRATIONS" $ do
\a migration operation removes all funds from the source wallet."
$ \ctx -> forM_ [fixtureRandomWallet, fixtureIcarusWallet]
$ \fixtureByronWallet -> runResourceT $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
-- Restore a Byron wallet with funds, to act as a source wallet:
sourceWallet <- fixtureByronWallet ctx

Expand Down Expand Up @@ -345,6 +353,7 @@ spec = describe "BYRON_MIGRATIONS" $ do
\migrating an empty wallet should fail."
$ \ctx -> forM_ [emptyRandomWallet, emptyIcarusWallet]
$ \emptyByronWallet -> runResourceT $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
sourceWallet <- emptyByronWallet ctx
targetWallet <- emptyWallet ctx
addrs <- listAddresses @n ctx targetWallet
Expand All @@ -365,6 +374,7 @@ spec = describe "BYRON_MIGRATIONS" $ do
Hspec.it "BYRON_MIGRATE_02 - \
\migrating wallet with dust should fail."
$ \ctx -> runResourceT @IO $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
-- NOTE
-- Special mnemonic for which wallet with dust
-- (5 utxos with 60 lovelace in total)
Expand Down Expand Up @@ -408,6 +418,7 @@ spec = describe "BYRON_MIGRATIONS" $ do
\actual fee for migration is the same as the predicted fee."
$ \ctx -> forM_ [fixtureRandomWallet, fixtureIcarusWallet]
$ \fixtureByronWallet -> runResourceT $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
-- Restore a Byron wallet with funds.
sourceWallet <- fixtureByronWallet ctx

Expand Down Expand Up @@ -445,6 +456,7 @@ spec = describe "BYRON_MIGRATIONS" $ do
it "BYRON_MIGRATE_04 - migration fails with a wrong passphrase"
$ \ctx -> forM_ [fixtureRandomWallet, fixtureIcarusWallet]
$ \fixtureByronWallet -> runResourceT $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
-- Restore a Byron wallet with funds, to act as a source wallet:
sourceWallet <- fixtureByronWallet ctx

Expand Down Expand Up @@ -522,6 +534,7 @@ spec = describe "BYRON_MIGRATIONS" $ do
testAddressCycling ctx addrNum =
forM_ [fixtureRandomWallet, fixtureIcarusWallet]
$ \fixtureByronWallet -> runResourceT $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
-- Restore a Byron wallet with funds, to act as a source wallet:
sourceWallet <- fixtureByronWallet ctx
let originalBalance =
Expand Down

0 comments on commit f7cb1b6

Please sign in to comment.