Skip to content

Commit

Permalink
Remove migration test that checks for depletion of source funds.
Browse files Browse the repository at this point in the history
This check is actually already performed in other integration tests.

In addition, we can easily add this check to the end of tests that don't
have it already.
  • Loading branch information
jonathanknowles committed May 13, 2021
1 parent 188438c commit 7b1f342
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 35 deletions.
Expand Up @@ -350,6 +350,17 @@ spec = describe "BYRON_MIGRATIONS" $ do
((`shouldBe` (Just 2)) . Map.lookup 1_000_000_000_000)
]

-- Check that the source wallet has the expected leftover balance:
responseFinalSourceBalance <- request @ApiByronWallet ctx
(Link.getWallet @'Byron sourceWallet) Default Empty
verify responseFinalSourceBalance
[ expectResponseCode HTTP.status200
, expectField (#balance . #available)
(`shouldBe` Quantity 100)
, expectField (#balance . #total)
(`shouldBe` Quantity 100)
]

it "BYRON_MIGRATE_03 - \
\Migrating an empty wallet should fail."
$ \ctx -> forM_ [emptyRandomWallet, emptyIcarusWallet]
Expand Down Expand Up @@ -502,39 +513,6 @@ spec = describe "BYRON_MIGRATIONS" $ do
, expectErrorMessage errMsg400ParseError
]

it "BYRON_MIGRATE_XX - \
\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

-- Perform a migration from the source wallet to a target wallet:
targetWallet <- emptyWallet ctx
addrs <- listAddresses @n ctx targetWallet
let addr1 = (addrs !! 1) ^. #id

r0 <- request @[ApiTransaction n] ctx
(Link.migrateWallet @'Byron sourceWallet)
Default
(Json [json|
{ passphrase: #{fixturePassphrase}
, addresses: [#{addr1}]
}|])
verify r0
[ expectResponseCode HTTP.status202
, expectField id (`shouldSatisfy` (not . null))
]

-- Verify that the source wallet has no funds available:
r1 <- request @ApiByronWallet ctx
(Link.getWallet @'Byron sourceWallet) Default Empty
verify r1
[ expectResponseCode HTTP.status200
, expectField (#balance . #available) (`shouldBe` Quantity 0)
]

Hspec.it "BYRON_MIGRATE_XX - \
\migrating wallet with dust should fail."
$ \ctx -> runResourceT @IO $ do
Expand Down Expand Up @@ -702,3 +680,15 @@ spec = describe "BYRON_MIGRATIONS" $ do
(#balance . #total)
(`shouldBe` Quantity expectedTargetBalance)
]

-- Check that the source wallet has a balance of zero:
responseFinalSourceBalance <- request @ApiByronWallet ctx
(Link.getWallet @'Byron sourceWallet) Default Empty
verify responseFinalSourceBalance
[ expectField
(#balance . #available)
(`shouldBe` Quantity 0)
, expectField
(#balance . #total)
(`shouldBe` Quantity 0)
]
Expand Up @@ -333,6 +333,17 @@ spec = describe "SHELLEY_MIGRATIONS" $ do
((`shouldBe` (Just 2)) . Map.lookup 10_000_000_000_000)
]

-- Check that the source wallet has the expected leftover balance:
responseFinalSourceBalance <- request @ApiWallet ctx
(Link.getWallet @'Shelley sourceWallet) Default Empty
verify responseFinalSourceBalance
[ expectResponseCode HTTP.status200
, expectField (#balance . #available)
(`shouldBe` Quantity 0)
, expectField (#balance . #total)
(`shouldBe` Quantity 0)
]

it "SHELLEY_MIGRATE_03 - \
\Migrating an empty wallet should fail."
$ \ctx -> runResourceT $ do
Expand Down Expand Up @@ -656,9 +667,9 @@ spec = describe "SHELLEY_MIGRATIONS" $ do
]

-- Check that the source wallet has a balance of zero:
response3 <- request @ApiWallet ctx
responseFinalSourceBalance <- request @ApiWallet ctx
(Link.getWallet @'Shelley sourceWallet) Default Empty
verify response3
verify responseFinalSourceBalance
[ expectField
(#balance . #available)
(`shouldBe` Quantity 0)
Expand Down

0 comments on commit 7b1f342

Please sign in to comment.