Skip to content

Commit

Permalink
Update integration test WALLETS_COIN_SELECTION_02.
Browse files Browse the repository at this point in the history
Update integration test `WALLETS_COIN_SELECTION_02` to check that the
set of coin selection outputs is exactly the same as intially provided,
rather than being a subset.
  • Loading branch information
jonathanknowles committed Oct 20, 2020
1 parent 3732fe1 commit e37a764
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Expand Up @@ -124,6 +124,7 @@ import Test.Integration.Framework.TestData
)

import qualified Cardano.Wallet.Api.Link as Link
import qualified Data.List as L
import qualified Data.List.NonEmpty as NE
import qualified Data.Text as T
import qualified Network.HTTP.Types.Status as HTTP
Expand Down Expand Up @@ -946,7 +947,6 @@ spec = describe "SHELLEY_WALLETS" $ do
(`shouldBe` [output])
]

let satisfy = flip shouldSatisfy
it "WALLETS_COIN_SELECTION_02 - \
\Multiple payments are all included in the coin selection output." $
\ctx -> do
Expand All @@ -958,18 +958,16 @@ spec = describe "SHELLEY_WALLETS" $ do
let payments = NE.fromList
$ take paymentCount
$ zipWith AddressAmount targetAddresses amounts
let outputs = NE.fromList
$ take paymentCount
let outputs =
take paymentCount
$ zipWith ApiCoinSelectionOutput targetAddresses amounts
selectCoins @_ @'Shelley ctx source payments >>= flip verify
[ expectResponseCode
HTTP.status200
, expectField
#inputs (`shouldSatisfy` (not . null))
, expectField
#outputs (satisfy $ (> paymentCount) . length)
, expectField
#outputs (satisfy $ flip all outputs . flip elem)
#outputs (`shouldSatisfy` ((L.sort outputs ==) . L.sort))
]

it "WALLETS_COIN_SELECTION_03 - \
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/Cardano/Wallet/Api/Types.hs
Expand Up @@ -434,7 +434,7 @@ data ApiCoinSelectionInput (n :: NetworkDiscriminant) = ApiCoinSelectionInput
data ApiCoinSelectionOutput (n :: NetworkDiscriminant) = ApiCoinSelectionOutput
{ address :: !(ApiT Address, Proxy n)
, amount :: !(Quantity "lovelace" Natural)
} deriving (Eq, Generic, Show)
} deriving (Eq, Ord, Generic, Show)

data ApiWallet = ApiWallet
{ id :: !(ApiT WalletId)
Expand Down

0 comments on commit e37a764

Please sign in to comment.