Skip to content

Commit

Permalink
Resurrect test CREATE_MIGRATION_PLAN_04.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed May 13, 2021
1 parent 0271b58 commit d7df1c6
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 17 deletions.
4 changes: 4 additions & 0 deletions lib/core-integration/src/Test/Integration/Faucet.hs
Expand Up @@ -20,6 +20,10 @@ module Test.Integration.Faucet
, mirMnemonics
, maMnemonics

-- * Dust wallets
, bigDustWallet
, onlyDustWallet

-- * Sea horses
, seaHorseTokenName
, seaHorsePolicyId
Expand Down
Expand Up @@ -177,28 +177,35 @@ spec = describe "BYRON_MIGRATIONS" $ do
(errMsg404NoWallet $ sourceWallet ^. walletId)
]

it "BYRON_CALCULATE_02 - \
\Cannot calculate fee for wallet with dust, that cannot be migrated."
it "BYRON_CREATE_MIGRATION_PLAN_04 - \
\Cannot create a plan for a wallet that only contains dust."
$ \ctx -> runResourceT $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
-- NOTE
-- Special mnemonic for which wallet with dust
-- (5 utxo with 60 lovelace)
let mnemonics =
["suffer", "decorate", "head", "opera", "yellow", "debate"
, "visa", "fire", "salute", "hybrid", "stone", "smart"] :: [Text]
-- NOTE:
-- Special mnemonic for wallet that has dust
-- (5 UTxOs with 60 lovelace each)
let mnemonicSentence =
[ "suffer", "decorate", "head", "opera", "yellow", "debate"
, "visa", "fire", "salute", "hybrid", "stone", "smart"
] :: [Text]
let payloadRestore = Json [json| {
"name": "Dust Byron Wallet",
"mnemonic_sentence": #{mnemonics},
"mnemonic_sentence": #{mnemonicSentence},
"passphrase": #{fixturePassphrase},
"style": "random"
} |]
w <- unsafeResponse <$> postByronWallet ctx payloadRestore
let ep = Link.createMigrationPlan @'Byron w
r <- request @(ApiWalletMigrationPlan n) ctx ep Default Empty
verify r
sourceWallet <- unsafeResponse <$>
postByronWallet ctx payloadRestore
targetWallet <- emptyWallet ctx
targetAddresses <- listAddresses @n ctx targetWallet
let targetAddressIds = targetAddresses <&>
(\(ApiTypes.ApiAddress addrId _ _) -> addrId)
let ep = Link.createMigrationPlan @'Byron sourceWallet
response <- request @(ApiWalletMigrationPlan n) ctx ep Default
(Json [json|{addresses: #{targetAddressIds}}|])
verify response
[ expectResponseCode HTTP.status403
, expectErrorMessage (errMsg403NothingToMigrate $ w ^. walletId)
, expectErrorMessage
(errMsg403NothingToMigrate $ sourceWallet ^. walletId)
]

describe "BYRON_MIGRATE_05 - I could migrate to any valid address" $ do
Expand Down
Expand Up @@ -17,7 +17,7 @@ module Test.Integration.Scenario.API.Shelley.Migrations
import Prelude

import Cardano.Mnemonic
( entropyToMnemonic, genEntropy )
( entropyToMnemonic, genEntropy, mnemonicToText )
import Cardano.Wallet.Api.Types
( ApiT (..)
, ApiTransaction
Expand Down Expand Up @@ -67,6 +67,8 @@ import Test.Hspec.Expectations.Lifted
( shouldBe, shouldSatisfy )
import Test.Hspec.Extra
( it )
import Test.Integration.Faucet
( onlyDustWallet )
import Test.Integration.Framework.DSL
( Context (..)
, Headers (..)
Expand Down Expand Up @@ -184,6 +186,31 @@ spec = describe "SHELLEY_MIGRATIONS" $ do
(errMsg404NoWallet $ sourceWallet ^. walletId)
]

it "SHELLEY_CREATE_MIGRATION_PLAN_04 - \
\Cannot create a plan for a wallet that only contains dust."
$ \ctx -> runResourceT $ do
liftIO $ pendingWith
"Disabled until a real dust wallet is available."
let payloadRestore = Json [json| {
"name": "Dust Shelley Wallet",
"mnemonic_sentence": #{mnemonicToText onlyDustWallet},
"passphrase": #{fixturePassphrase},
"style": "random"
} |]
sourceWallet <- unsafeResponse <$> postWallet ctx payloadRestore
targetWallet <- emptyWallet ctx
targetAddresses <- listAddresses @n ctx targetWallet
let targetAddressIds = targetAddresses <&>
(\(ApiTypes.ApiAddress addrId _ _) -> addrId)
let ep = Link.createMigrationPlan @'Shelley sourceWallet
response <- request @(ApiWalletMigrationPlan n) ctx ep Default
(Json [json|{addresses: #{targetAddressIds}}|])
verify response
[ expectResponseCode HTTP.status403
, expectErrorMessage
(errMsg403NothingToMigrate $ sourceWallet ^. walletId)
]

describe "SHELLEY_MIGRATE_01 - \
\after a migration operation successfully completes, the correct \
\amount eventually becomes available in the target wallet for arbitrary \
Expand All @@ -193,7 +220,7 @@ spec = describe "SHELLEY_MIGRATIONS" $ do
testAddressCycling 3
testAddressCycling 10

Hspec.it "SHELLEY_MIGRATE_01_big_wallet - \
it "SHELLEY_MIGRATE_01_big_wallet - \
\ migrate a big wallet requiring more than one tx" $ \ctx -> runResourceT @IO $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."

Expand Down

0 comments on commit d7df1c6

Please sign in to comment.