diff --git a/lib/core-integration/src/Test/Integration/Scenario/API/Byron/Transactions.hs b/lib/core-integration/src/Test/Integration/Scenario/API/Byron/Transactions.hs index 656886036aa..dd9ee75782f 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/API/Byron/Transactions.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/API/Byron/Transactions.hs @@ -3,6 +3,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE NumericUnderscores #-} {-# LANGUAGE OverloadedLabels #-} +{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} @@ -20,10 +21,12 @@ import Control.Monad ( forM_ ) import Data.Generics.Internal.VL.Lens ( (^.) ) +import Data.Quantity + ( Quantity (..) ) import Data.Text.Class ( fromText ) import Test.Hspec - ( SpecWith, describe, it ) + ( SpecWith, describe, it, shouldBe ) import Test.Integration.Framework.DSL ( Context , Headers (..) @@ -31,10 +34,14 @@ import Test.Integration.Framework.DSL , emptyIcarusWallet , emptyRandomWallet , expectErrorMessage + , expectField , expectListSize , expectResponseCode + , faucetAmt , fixtureIcarusWallet + , fixturePassphrase , fixtureRandomWallet + , json , request , toQueryString , verify @@ -58,6 +65,53 @@ spec :: forall n t. ( DecodeAddress n ) => SpecWith (Context t) spec = do + + it "BYRON_RESTORE_08 - Icarus wallet with high indexes" $ \ctx -> do + -- NOTE + -- Special Icarus mnemonic where address indexes are all after the index + -- 500. Because we don't have the whole history, restoring sequential + -- wallets like Icarus ones is tricky from just a snapshot and we need + -- to use arbitrarily big address pool gaps. + let mnemonics = + [ "erosion", "ahead", "vibrant", "air", "day" + , "timber", "thunder", "general", "dice", "into" + , "chest", "enrich", "social", "neck", "shine" + ] :: [T.Text] + let payload = Json [json| { + "name": "High Index Wallet", + "mnemonic_sentence": #{mnemonics}, + "passphrase": #{fixturePassphrase}, + "style": "icarus" + } |] + + r <- request @ApiByronWallet ctx (Link.postWallet @'Byron) Default payload + verify r + [ expectResponseCode @IO HTTP.status201 + , expectField (#balance . #available) (`shouldBe` Quantity faucetAmt) + ] + + it "BYRON_RESTORE_09 - Ledger wallet" $ \ctx -> do + -- NOTE + -- Special legacy wallets where addresses have been generated from a + -- seed derived using the auxiliary method used by Ledger. + let mnemonics = + [ "vague" , "wrist" , "poet" , "crazy" , "danger" , "dinner" + , "grace" , "home" , "naive" , "unfold" , "april" , "exile" + , "relief" , "rifle" , "ranch" , "tone" , "betray" , "wrong" + ] :: [T.Text] + let payload = Json [json| { + "name": "Ledger Wallet", + "mnemonic_sentence": #{mnemonics}, + "passphrase": #{fixturePassphrase}, + "style": "ledger" + } |] + + r <- request @ApiByronWallet ctx (Link.postWallet @'Byron) Default payload + verify r + [ expectResponseCode @IO HTTP.status201 + , expectField (#balance . #available) (`shouldBe` Quantity faucetAmt) + ] + it "BYRON_TX_LIST_01 - 0 txs on empty Byron wallet" $ \ctx -> forM_ [emptyRandomWallet, emptyIcarusWallet] $ \emptyByronWallet -> do w <- emptyByronWallet ctx diff --git a/lib/core-integration/src/Test/Integration/Scenario/API/Byron/Wallets.hs b/lib/core-integration/src/Test/Integration/Scenario/API/Byron/Wallets.hs index 9a8d86bfa4b..52eac2e8ca1 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/API/Byron/Wallets.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/API/Byron/Wallets.hs @@ -71,7 +71,6 @@ import Test.Integration.Framework.DSL , expectListSize , expectResponseCode , expectWalletUTxO - , faucetAmt , fixturePassphrase , fixturePassphraseEncrypted , getFromResponse @@ -319,52 +318,6 @@ spec = do @ApiByronWallet ctx (Link.postWallet @'Byron) Default payload verify r expectations - it "BYRON_RESTORE_08 - Icarus wallet with high indexes" $ \ctx -> do - -- NOTE - -- Special Icarus mnemonic where address indexes are all after the index - -- 500. Because we don't have the whole history, restoring sequential - -- wallets like Icarus ones is tricky from just a snapshot and we need - -- to use arbitrarily big address pool gaps. - let mnemonics = - [ "erosion", "ahead", "vibrant", "air", "day" - , "timber", "thunder", "general", "dice", "into" - , "chest", "enrich", "social", "neck", "shine" - ] :: [Text] - let payload = Json [json| { - "name": "High Index Wallet", - "mnemonic_sentence": #{mnemonics}, - "passphrase": #{fixturePassphrase}, - "style": "icarus" - } |] - - r <- request @ApiByronWallet ctx (Link.postWallet @'Byron) Default payload - verify r - [ expectResponseCode @IO HTTP.status201 - , expectField (#balance . #available) (`shouldBe` Quantity faucetAmt) - ] - - it "BYRON_RESTORE_09 - Ledger wallet" $ \ctx -> do - -- NOTE - -- Special legacy wallets where addresses have been generated from a - -- seed derived using the auxiliary method used by Ledger. - let mnemonics = - [ "vague" , "wrist" , "poet" , "crazy" , "danger" , "dinner" - , "grace" , "home" , "naive" , "unfold" , "april" , "exile" - , "relief" , "rifle" , "ranch" , "tone" , "betray" , "wrong" - ] :: [Text] - let payload = Json [json| { - "name": "Ledger Wallet", - "mnemonic_sentence": #{mnemonics}, - "passphrase": #{fixturePassphrase}, - "style": "ledger" - } |] - - r <- request @ApiByronWallet ctx (Link.postWallet @'Byron) Default payload - verify r - [ expectResponseCode @IO HTTP.status201 - , expectField (#balance . #available) (`shouldBe` Quantity faucetAmt) - ] - it "BYRON_UPDATE_NAME_01 - Update names of wallets" $ \ctx -> forM_ [ (emptyRandomWallet ctx, "Random Wallet") , (emptyIcarusWallet ctx, "Icarus Wallet") diff --git a/lib/shelley/test/integration/Main.hs b/lib/shelley/test/integration/Main.hs index 1a0867b5c50..9bc5ceaa2f5 100644 --- a/lib/shelley/test/integration/Main.hs +++ b/lib/shelley/test/integration/Main.hs @@ -107,7 +107,13 @@ import qualified Cardano.Wallet.Api.Link as Link import qualified Data.Aeson as Aeson import qualified Data.ByteString as BS import qualified Data.Text as T -import qualified Test.Integration.Scenario.API.Byron.Migrations as ByronMigrations +-- TODO: enable when byron transactions/addresses supported in the cardano-node +-- import qualified Test.Integration.Scenario.API.Byron.Addresses as ByronAddresses +-- import qualified Test.Integration.Scenario.API.Byron.Migrations as ByronMigrations +-- import qualified Test.Integration.Byron.Scenario.API.Transactions as ByronTransactions +-- import qualified Test.Integration.Scenario.API.Byron.Transactions as ByronTransactionsCommon +-- import qualified Test.Integration.Scenario.API.Byron.HWWallets as ByronHWWallets +import qualified Test.Integration.Scenario.API.Byron.Wallets as ByronWallets import qualified Test.Integration.Scenario.API.Network as Network import qualified Test.Integration.Scenario.API.Shelley.Addresses as Addresses import qualified Test.Integration.Scenario.API.Shelley.HWWallets as HWWallets @@ -141,7 +147,7 @@ main = withUtf8Encoding $ withLogging Nothing Info $ \(_, tr) -> do specWithServer tr $ do describe "API Specifications" $ do Addresses.spec @n - ByronMigrations.spec @n + ByronWallets.spec @n Migrations.spec @n Transactions.spec @n Wallets.spec @n