Skip to content

Commit

Permalink
Resurrect test MIGRATE_06.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed May 14, 2021
1 parent 1fbf614 commit c220abb
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 43 deletions.
Expand Up @@ -444,36 +444,50 @@ spec = describe "BYRON_MIGRATIONS" $ do
, expectErrorMessage errMsg403WrongPass
]

describe "BYRON_MIGRATE_XX - I could migrate to any valid address" $ do
forM_ [ ("Byron", emptyRandomWallet)
describe "BYRON_MIGRATE_06 - \
\It's possible to migrate to any valid address."
$ forM_
[ ("Random", emptyRandomWallet)
, ("Icarus", emptyIcarusWallet)
] $ \(walType, destWallet) -> do
] $ \(walType, destWallet) ->

it ("From wallet type: " ++ walType) $ \ctx -> runResourceT $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
--shelley address

-- Create a Shelley address:
wShelley <- emptyWallet ctx
addrs <- listAddresses @n ctx wShelley
let addrShelley = (addrs !! 1) ^. #id
--icarus address
addrIcarus <- liftIO $ encodeAddress @n . head . icarusAddresses @n

-- Create an Icarus address:
addrIcarus <- liftIO $ encodeAddress @n
. head
. icarusAddresses @n
. entropyToMnemonic @15 <$> genEntropy
--byron address
addrByron <- liftIO $ encodeAddress @n . head . randomAddresses @n

-- Create a Byron address:
addrByron <- liftIO $ encodeAddress @n
. head
. randomAddresses @n
. entropyToMnemonic @12 <$> genEntropy

sWallet <- destWallet ctx
r <- request @[ApiTransaction n] ctx
(Link.migrateWallet @'Byron sWallet)
Default
-- Create a source wallet:
sourceWallet <- destWallet ctx

-- Initiate a migration to all address types:
response <- request @[ApiTransaction n] ctx
(Link.migrateWallet @'Byron sourceWallet) Default
(Json [json|
{ passphrase: #{fixturePassphrase}
, addresses: [#{addrShelley}, #{addrIcarus}, #{addrByron}]
, addresses:
[ #{addrShelley}
, #{addrIcarus}
, #{addrByron}
]
}|])
verify r
verify response
[ expectResponseCode HTTP.status403
, expectErrorMessage
(errMsg403NothingToMigrate (sWallet ^. walletId))
(errMsg403NothingToMigrate (sourceWallet ^. walletId))
]

it "BYRON_MIGRATE_07 - invalid payload, parser error" $ \ctx -> runResourceT $ do
Expand Down
Expand Up @@ -425,6 +425,39 @@ spec = describe "SHELLEY_MIGRATIONS" $ do
, expectErrorMessage errMsg403WrongPass
]

it "SHELLEY_MIGRATE_06 - \
\It's possible to migrate to any valid address."
$ \ctx -> runResourceT $ do

-- Create a Shelley address:
wShelley <- emptyWallet ctx
addrs <- listAddresses @n ctx wShelley
let addrShelley = (addrs !! 1) ^. #id

-- Create an Icarus address:
addrIcarus <- liftIO $ encodeAddress @n . head . icarusAddresses @n
. entropyToMnemonic @15 <$> genEntropy

-- Create a Byron address:
addrByron <- liftIO $ encodeAddress @n . head . randomAddresses @n
. entropyToMnemonic @12 <$> genEntropy

-- Create a source wallet:
sourceWallet <- emptyWallet ctx

-- Initiate a migration to all address types:
response <- request @[ApiTransaction n] ctx
(Link.migrateWallet @'Shelley sourceWallet) Default
(Json [json|
{ passphrase: #{fixturePassphrase}
, addresses: [#{addrShelley}, #{addrIcarus}, #{addrByron}]
}|])
verify response
[ expectResponseCode HTTP.status403
, expectErrorMessage
(errMsg403NothingToMigrate (sourceWallet ^. walletId))
]

Hspec.it "SHELLEY_MIGRATE_XX - \
\migrating wallet with 'dust' (that complies with minUTxOValue) should pass."
$ \ctx -> runResourceT @IO $ do
Expand Down Expand Up @@ -490,33 +523,6 @@ spec = describe "SHELLEY_MIGRATIONS" $ do
( `shouldBe` Quantity expectedBalance)
]

it "SHELLEY_MIGRATE_XX - I could migrate to any valid address" $ \ctx -> runResourceT $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
--shelley address
wShelley <- emptyWallet ctx
addrs <- listAddresses @n ctx wShelley
let addrShelley = (addrs !! 1) ^. #id
--icarus address
addrIcarus <- liftIO $ encodeAddress @n . head . icarusAddresses @n
. entropyToMnemonic @15 <$> genEntropy
--byron address
addrByron <- liftIO $ encodeAddress @n . head . randomAddresses @n
. entropyToMnemonic @12 <$> genEntropy

sWallet <- emptyWallet ctx
r <- request @[ApiTransaction n] ctx
(Link.migrateWallet @'Shelley sWallet)
Default
(Json [json|
{ passphrase: #{fixturePassphrase}
, addresses: [#{addrShelley}, #{addrIcarus}, #{addrByron}]
}|])
verify r
[ expectResponseCode HTTP.status403
, expectErrorMessage
(errMsg403NothingToMigrate (sWallet ^. walletId))
]

it "SHELLEY_MIGRATE_07 - invalid payload, parser error" $ \ctx -> runResourceT $ do
liftIO $ pendingWith "Migration endpoints temporarily disabled."
sourceWallet <- emptyWallet ctx
Expand Down

0 comments on commit c220abb

Please sign in to comment.