Skip to content

Commit

Permalink
Try #2763:
Browse files Browse the repository at this point in the history
  • Loading branch information
iohk-bors[bot] committed Jul 22, 2021
2 parents cd7b59d + 86bfd25 commit 46f6514
Show file tree
Hide file tree
Showing 38 changed files with 750 additions and 444 deletions.
11 changes: 7 additions & 4 deletions lib/core-integration/src/Test/Integration/Framework/DSL.hs
Expand Up @@ -231,6 +231,7 @@ import Cardano.Wallet.Api.Types
, ApiByronWallet
, ApiCoinSelection
, ApiEpochInfo
, ApiEra (..)
, ApiFee
, ApiMaintenanceAction (..)
, ApiNetworkInformation
Expand Down Expand Up @@ -654,8 +655,10 @@ walletId =
--

-- | Min UTxO parameter for the test cluster.
minUTxOValue :: Natural
minUTxOValue = 1_000_000
minUTxOValue :: ApiEra -> Natural
minUTxOValue e
| e >= ApiAlonzo = 999_978
| otherwise = 1_000_000 -- 34482 lovelace per word

-- | Parameter in test cluster shelley genesis.
--
Expand Down Expand Up @@ -1417,7 +1420,7 @@ fixtureMultiAssetRandomWallet ctx = do
-- pick out assets to send
let assetsSrc = wMA ^. #assets . #total . #getApiT
assetsSrc `shouldNotBe` mempty
let val = minUTxOValue <$ pickAnAsset assetsSrc
let val = minUTxOValue (_mainEra ctx) <$ pickAnAsset assetsSrc

rL <- request @[ApiAddress n] ctx (Link.listAddresses @'Byron wB) Default Empty
let addrs = getFromResponse id rL
Expand Down Expand Up @@ -1458,7 +1461,7 @@ fixtureMultiAssetIcarusWallet ctx = do
-- pick out assets to send
let assetsSrc = wMA ^. #assets . #total . #getApiT
assetsSrc `shouldNotBe` mempty
let val = minUTxOValue <$ pickAnAsset assetsSrc
let val = minUTxOValue (_mainEra ctx) <$ pickAnAsset assetsSrc

rL <- request @[ApiAddress n] ctx (Link.listAddresses @'Byron wB) Default Empty
let addrs = getFromResponse id rL
Expand Down
Expand Up @@ -84,7 +84,8 @@ spec = describe "BYRON_COIN_SELECTION" $ do
rnW <- emptyRandomWallet ctx
shW <- emptyWallet ctx
(addr:_) <- fmap (view #id) <$> listAddresses @n ctx shW
let payments = NE.fromList [ AddressAmount addr (Quantity minUTxOValue) mempty ]
let amt = Quantity . minUTxOValue . _mainEra $ ctx
let payments = NE.fromList [ AddressAmount addr amt mempty ]
selectCoins @_ @'Byron ctx rnW payments >>= flip verify
[ expectResponseCode HTTP.status403
, expectErrorMessage errMsg403NotAnIcarusWallet
Expand All @@ -96,7 +97,7 @@ spec = describe "BYRON_COIN_SELECTION" $ do
source <- fixtureIcarusWallet ctx
target <- emptyWallet ctx
targetAddress : _ <- fmap (view #id) <$> listAddresses @n ctx target
let amt = Quantity minUTxOValue
let amt = Quantity . minUTxOValue $ _mainEra ctx
let payment = AddressAmount targetAddress amt mempty
let output = ApiCoinSelectionOutput targetAddress amt mempty
selectCoins @_ @'Byron ctx source (payment :| []) >>= flip verify
Expand All @@ -122,7 +123,7 @@ spec = describe "BYRON_COIN_SELECTION" $ do
source <- fixtureIcarusWallet ctx
target <- emptyWallet ctx
targetAddresses <- fmap (view #id) <$> listAddresses @n ctx target
let amounts = Quantity <$> [minUTxOValue ..]
let amounts = Quantity <$> [minUTxOValue (_mainEra ctx) ..]
let targetAssets = repeat mempty
let payments = NE.fromList
$ take paymentCount
Expand All @@ -143,7 +144,8 @@ spec = describe "BYRON_COIN_SELECTION" $ do
icW <- emptyIcarusWallet ctx
shW <- emptyWallet ctx
(addr:_) <- fmap (view #id) <$> listAddresses @n ctx shW
let payments = NE.fromList [ AddressAmount addr (Quantity minUTxOValue) mempty ]
let minUTxOValue' = Quantity . minUTxOValue $ _mainEra ctx
let payments = NE.fromList [ AddressAmount addr minUTxOValue' mempty ]
_ <- request @ApiByronWallet ctx (Link.deleteWallet @'Byron icW) Default Empty
selectCoins @_ @'Byron ctx icW payments >>= flip verify
[ expectResponseCode HTTP.status404
Expand Down
Expand Up @@ -128,11 +128,12 @@ spec = describe "BYRON_HW_WALLETS" $ do
--send funds
let [addr] = take 1 $ icarusAddresses @n mnemonics
let destination = encodeAddress @n addr
let minUTxOValue' = minUTxOValue (_mainEra ctx)
let payload = Json [json|{
"payments": [{
"address": #{destination},
"amount": {
"quantity": #{minUTxOValue},
"quantity": #{minUTxOValue'},
"unit": "lovelace"
}
}],
Expand All @@ -147,9 +148,9 @@ spec = describe "BYRON_HW_WALLETS" $ do
(Link.getWallet @'Byron wDest) Default Empty
verify rGet
[ expectField
(#balance . #total) (`shouldBe` Quantity minUTxOValue)
(#balance . #total) (`shouldBe` Quantity minUTxOValue')
, expectField
(#balance . #available) (`shouldBe` Quantity minUTxOValue)
(#balance . #available) (`shouldBe` Quantity minUTxOValue')
]

-- delete wallet
Expand All @@ -166,9 +167,9 @@ spec = describe "BYRON_HW_WALLETS" $ do
(Link.getWallet @'Byron wDest') Default Empty
verify rGet
[ expectField
(#balance . #total) (`shouldBe` Quantity minUTxOValue)
(#balance . #total) (`shouldBe` Quantity minUTxOValue')
, expectField
(#balance . #available) (`shouldBe` Quantity minUTxOValue)
(#balance . #available) (`shouldBe` Quantity minUTxOValue')
]

describe "HW_WALLETS_03 - Cannot do operations requiring private key" $ do
Expand All @@ -182,11 +183,12 @@ spec = describe "BYRON_HW_WALLETS" $ do

let [addr] = take 1 $ icarusAddresses @n mnemonics
let destination = encodeAddress @n addr
let minUTxOValue' = minUTxOValue (_mainEra ctx)
let payload = Json [json|{
"payments": [{
"address": #{destination},
"amount": {
"quantity": #{minUTxOValue},
"quantity": #{minUTxOValue'},
"unit": "lovelace"
}
}],
Expand Down Expand Up @@ -238,11 +240,12 @@ spec = describe "BYRON_HW_WALLETS" $ do

let [addr] = take 1 $ icarusAddresses @n mnemonics
let destination = encodeAddress @n addr
let minUTxOValue' = minUTxOValue (_mainEra ctx)
let payload = Json [json|{
"payments": [{
"address": #{destination},
"amount": {
"quantity": #{minUTxOValue},
"quantity": #{minUTxOValue'},
"unit": "lovelace"
}
}]
Expand Down Expand Up @@ -327,8 +330,9 @@ spec = describe "BYRON_HW_WALLETS" $ do
let targetAddresses = take paymentCount $
(\a -> (ApiT a, Proxy @n)) <$>
icarusAddresses @n mnemonics
let minUTxOValue' = minUTxOValue (_mainEra ctx)
let targetAmounts = take paymentCount $
Quantity <$> [minUTxOValue ..]
Quantity <$> [minUTxOValue' ..]
let targetAssets = repeat mempty
let payments = NE.fromList $ map ($ mempty) $
zipWith AddressAmount targetAddresses targetAmounts
Expand Down
Expand Up @@ -65,7 +65,7 @@ import Test.Hspec.Expectations.Lifted
import Test.Hspec.Extra
( it )
import Test.Integration.Framework.DSL
( Context
( Context (..)
, Headers (..)
, Payload (..)
, between
Expand Down Expand Up @@ -144,11 +144,12 @@ spec = describe "BYRON_TRANSACTIONS" $ do
-- pick out an asset to send
let assetsSrc = wSrc ^. #assets . #total . #getApiT
assetsSrc `shouldNotBe` mempty
let val = minUTxOValue <$ pickAnAsset assetsSrc
let minUTxOValue' = minUTxOValue (_mainEra ctx)
let val = minUTxOValue' <$ pickAnAsset assetsSrc

addrs <- listAddresses @n ctx wDest
let destination = (addrs !! 1) ^. #id
payload <- mkTxPayloadMA @n destination (minUTxOValue * 2) [val] fixturePassphrase
payload <- mkTxPayloadMA @n destination (minUTxOValue' * 2) [val] fixturePassphrase

rtx <- request @(ApiTransaction n) ctx
(Link.createTransaction @'Byron wSrc) Default payload
Expand All @@ -175,11 +176,12 @@ spec = describe "BYRON_TRANSACTIONS" $ do
-- pick out an asset to send
let assetsSrc = wSrc ^. #assets . #total . #getApiT
assetsSrc `shouldNotBe` mempty
let val = minUTxOValue <$ pickAnAsset assetsSrc
let minUTxOValue' = minUTxOValue (_mainEra ctx)
let val = minUTxOValue' <$ pickAnAsset assetsSrc

addrs <- listAddresses @n ctx wDest
let destination = (addrs !! 1) ^. #id
payload <- mkTxPayloadMA @n destination minUTxOValue [val] fixturePassphrase
payload <- mkTxPayloadMA @n destination minUTxOValue' [val] fixturePassphrase

rtx <- request @(ApiTransaction n) ctx
(Link.createTransaction @'Byron wSrc) Default payload
Expand All @@ -197,7 +199,7 @@ spec = describe "BYRON_TRANSACTIONS" $ do
-- pick out an asset to send
let assetsSrc = wSrc ^. #assets . #total . #getApiT
assetsSrc `shouldNotBe` mempty
let val = minUTxOValue <$ pickAnAsset assetsSrc
let val = minUTxOValue (_mainEra ctx) <$ pickAnAsset assetsSrc

addrs <- listAddresses @n ctx wDest
let destination = (addrs !! 1) ^. #id
Expand Down Expand Up @@ -309,7 +311,7 @@ spec = describe "BYRON_TRANSACTIONS" $ do
(wByron, wShelley) <- (,) <$> srcFixture ctx <*> fixtureWallet ctx
addrs <- listAddresses @n ctx wShelley

let amt = minUTxOValue :: Natural
let amt = minUTxOValue (_mainEra ctx) :: Natural
let destination = (addrs !! 1) ^. #id
let payload = Json [json|{
"payments": [{
Expand Down Expand Up @@ -380,7 +382,7 @@ spec = describe "BYRON_TRANSACTIONS" $ do
"payments": [{
"address": #{destination},
"amount": {
"quantity": #{minUTxOValue},
"quantity": #{minUTxOValue (_mainEra ctx)},
"unit": "lovelace"
}
}],
Expand Down Expand Up @@ -412,7 +414,7 @@ spec = describe "BYRON_TRANSACTIONS" $ do
"payments": [{
"address": #{destination},
"amount": {
"quantity": #{minUTxOValue},
"quantity": #{minUTxOValue (_mainEra ctx)},
"unit": "lovelace"
}
}]
Expand Down
Expand Up @@ -54,7 +54,7 @@ import Test.Hspec.Expectations.Lifted
import Test.Hspec.Extra
( it )
import Test.Integration.Framework.DSL
( Context
( Context (..)
, Headers (..)
, Payload (..)
, emptyIcarusWallet
Expand Down Expand Up @@ -134,7 +134,7 @@ spec = describe "NEW_BYRON_TRANSACTIONS" $ do
(wByron, wShelley) <- (,) <$> srcFixture ctx <*> emptyWallet ctx
addrs <- listAddresses @n ctx wShelley

let amt = minUTxOValue :: Natural
let amt = minUTxOValue (_mainEra ctx) :: Natural
let destination = (addrs !! 1) ^. #id
let payload = Json [json|{
"payments": [{
Expand Down Expand Up @@ -163,10 +163,10 @@ spec = describe "NEW_BYRON_TRANSACTIONS" $ do

liftIO $ pendingWith "Byron wallet returns 500, Icarus wallet as expected"

wa <- srcFixture ctx [minUTxOValue + 1]
wa <- srcFixture ctx [minUTxOValue (_mainEra ctx) + 1]
wb <- emptyWallet ctx

payload <- liftIO $ mkTxPayload ctx wb minUTxOValue
payload <- liftIO $ mkTxPayload ctx wb (minUTxOValue (_mainEra ctx))

rTx <- request @(ApiConstructTransaction n) ctx
(Link.createUnsignedTransaction @'Byron wa) Default payload
Expand All @@ -182,7 +182,8 @@ spec = describe "NEW_BYRON_TRANSACTIONS" $ do

liftIO $ pendingWith "Byron wallet returns 500, Icarus wallet as expected"

let (srcAmt, reqAmt) = (minUTxOValue, 2 * minUTxOValue)
let minUTxOValue' = minUTxOValue (_mainEra ctx)
let (srcAmt, reqAmt) = (minUTxOValue', 2 * minUTxOValue')
wa <- srcFixture ctx [srcAmt]
wb <- emptyWallet ctx

Expand All @@ -205,7 +206,7 @@ spec = describe "NEW_BYRON_TRANSACTIONS" $ do
wa <- emptySrcWallet ctx
wb <- emptyWallet ctx

payload <- liftIO $ mkTxPayload ctx wb minUTxOValue
payload <- liftIO $ mkTxPayload ctx wb (minUTxOValue (_mainEra ctx))

rTx <- request @(ApiConstructTransaction n) ctx
(Link.createUnsignedTransaction @'Byron wa) Default payload
Expand All @@ -225,7 +226,7 @@ spec = describe "NEW_BYRON_TRANSACTIONS" $ do
wb <- emptyWallet ctx
addrs <- listAddresses @n ctx wb

let amt = minUTxOValue :: Natural
let amt = minUTxOValue (_mainEra ctx) :: Natural
let destination1 = (addrs !! 1) ^. #id
let destination2 = (addrs !! 2) ^. #id
let payload = Json [json|{
Expand Down Expand Up @@ -273,12 +274,12 @@ spec = describe "NEW_BYRON_TRANSACTIONS" $ do
-- pick out an asset to send
let assetsSrc = wal ^. #assets . #total . #getApiT
assetsSrc `shouldNotBe` mempty
let val = minUTxOValue <$ pickAnAsset assetsSrc
let val = minUTxOValue (_mainEra ctx) <$ pickAnAsset assetsSrc

-- create payload
addrs <- listAddresses @n ctx wb
let destination = (addrs !! 1) ^. #id
let amt = 2 * minUTxOValue
let amt = 2 * minUTxOValue (_mainEra ctx)
payload <- mkTxPayloadMA @n destination amt [val]

--construct transaction
Expand Down Expand Up @@ -310,12 +311,12 @@ spec = describe "NEW_BYRON_TRANSACTIONS" $ do
-- pick out an asset to send
let assetsSrc = wal ^. #assets . #total . #getApiT
assetsSrc `shouldNotBe` mempty
let val = minUTxOValue <$ pickAnAsset assetsSrc
let val = minUTxOValue (_mainEra ctx) <$ pickAnAsset assetsSrc

-- create payload
addrs <- listAddresses @n ctx wb
let destination = (addrs !! 1) ^. #id
let amt = minUTxOValue
let amt = minUTxOValue (_mainEra ctx)
payload <- mkTxPayloadMA @n destination amt [val]

--construct transaction
Expand All @@ -341,7 +342,7 @@ spec = describe "NEW_BYRON_TRANSACTIONS" $ do
-- pick out an asset to send
let assetsSrc = wal ^. #assets . #total . #getApiT
assetsSrc `shouldNotBe` mempty
let val = minUTxOValue <$ pickAnAsset assetsSrc
let val = minUTxOValue (_mainEra ctx) <$ pickAnAsset assetsSrc

-- create payload
addrs <- listAddresses @n ctx wb
Expand All @@ -367,7 +368,7 @@ spec = describe "NEW_BYRON_TRANSACTIONS" $ do
forM_ [(fixtureMultiAssetRandomWallet @n, "Byron wallet"),
(fixtureMultiAssetIcarusWallet @n, "Icarus wallet")] $
\(srcFixture,name) -> it name $ \ctx -> runResourceT $ do

liftIO $ pendingWith "Byron wallet returns 500, Icarus wallet as expected"

wa <- srcFixture ctx
Expand All @@ -378,7 +379,8 @@ spec = describe "NEW_BYRON_TRANSACTIONS" $ do
-- pick out an asset to send
let assetsSrc = wal ^. #assets . #total . #getApiT
assetsSrc `shouldNotBe` mempty
let val = (minUTxOValue * minUTxOValue) <$ pickAnAsset assetsSrc
let minUTxOValue' = minUTxOValue (_mainEra ctx)
let val = (minUTxOValue' * minUTxOValue') <$ pickAnAsset assetsSrc

-- create payload
addrs <- listAddresses @n ctx wb
Expand Down
Expand Up @@ -1039,7 +1039,7 @@ spec = describe "SHARED_WALLETS" $ do
let destination = (sharedAddrs !! 1) ^. #id

wShelley <- fixtureWallet ctx
let amt = minUTxOValue
let amt = minUTxOValue (_mainEra ctx)
let payloadTx = Json [json|{
"payments": [{
"address": #{destination},
Expand Down
Expand Up @@ -56,7 +56,7 @@ import Test.Hspec.Expectations.Lifted
import Test.Hspec.Extra
( it )
import Test.Integration.Framework.DSL
( Context
( Context (..)
, Headers (..)
, Payload (..)
, emptyRandomWallet
Expand Down Expand Up @@ -211,14 +211,16 @@ spec = describe "SHELLEY_ADDRESSES" $ do
expectListField addrNum (#state . #getApiT) (`shouldBe` Unused) r
addrs <- listAddresses @n ctx wDest

let amt = minUTxOValue (_mainEra ctx)

-- run 10 transactions to make all addresses `Used`
forM_ [0..9] $ \addrNum -> do
let destination = (addrs !! addrNum) ^. #id
let payload = Json [json|{
"payments": [{
"address": #{destination},
"amount": {
"quantity": #{minUTxOValue},
"quantity": #{amt},
"unit": "lovelace"
}
}],
Expand All @@ -235,7 +237,7 @@ spec = describe "SHELLEY_ADDRESSES" $ do
(Link.getWallet @'Shelley wDest) Default Empty
expectField
(#balance . #available)
(`shouldBe` Quantity (10 * 1_000_000))
(`shouldBe` Quantity (10 * amt))
rb

-- verify new address_pool_gap has been created
Expand Down Expand Up @@ -295,7 +297,7 @@ spec = describe "SHELLEY_ADDRESSES" $ do

-- 2. Send a transaction from A -> B
destination <- view #id . head <$> listAddresses @n ctx wB
let amount = 10 * minUTxOValue
let amount = 10 * minUTxOValue (_mainEra ctx)
let payload = Json [json|{
"payments": [{
"address": #{destination},
Expand Down

0 comments on commit 46f6514

Please sign in to comment.