Skip to content

Commit

Permalink
Add transaction get by id check to Byron API and CLI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Stachyra committed Jun 26, 2020
1 parent 8801312 commit bf4da8f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Cardano.Wallet.Api.Types
, ApiFee
, ApiT (..)
, ApiTransaction
, ApiTxId (ApiTxId)
, ApiUtxoStatistics
, DecodeAddress (..)
, EncodeAddress (..)
Expand Down Expand Up @@ -194,6 +195,7 @@ scenario_TRANS_CREATE_01_02 fixtureSource fixtures = it title $ \ctx -> do

-- ACTION
r <- postByronTransaction @n ctx wSrc payments fixturePassphrase
let txid = getFromResponse #id r

-- ASSERTIONS
let (feeMin, feeMax) = ctx ^. #_feeEstimator $ PaymentDescription
Expand Down Expand Up @@ -238,8 +240,26 @@ scenario_TRANS_CREATE_01_02 fixtureSource fixtures = it title $ \ctx -> do
, expectListField 10 (#status . #getApiT) (`shouldBe` InLedger)
, expectListField 10 #depth (`shouldNotBe` Nothing)
]
-- Verify one can get incoming tx by ID from dst wallet
let linkInc = Link.getTransaction @'Byron wDest (ApiTxId txid)
rInc <- request @(ApiTransaction n) ctx linkInc Default Empty
verify rInc
[ expectResponseCode HTTP.status200
, expectField (#direction . #getApiT) (`shouldBe` Incoming)
, expectField (#status . #getApiT) (`shouldBe` InLedger)
]

-- Verify one can get outgoing tx by ID from src wallet
let linkOut = Link.getTransaction @'Byron wSrc (ApiTxId txid)
rOut <- request @(ApiTransaction n) ctx linkOut Default Empty
verify rOut
[ expectResponseCode HTTP.status200
, expectField (#direction . #getApiT) (`shouldBe` Outgoing)
, expectField (#status . #getApiT) (`shouldBe` InLedger)
]

where
title = "TRANS_CREATE_01/02 - " ++ show n ++ " recipient(s)"
title = "TRANS_CREATE_01/02, TRANS_GET_01 - " ++ show n ++ " recipient(s)"
n = fromIntegral $ length fixtures

scenario_TRANS_ESTIMATE_01_02
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import Test.Integration.Framework.DSL
, fixtureRandomWallet
, fixtureRandomWalletAddrs
, fixtureRandomWalletWith
, getTransactionViaCLI
, getTxId
, getWalletViaCLI
, icarusAddresses
Expand Down Expand Up @@ -513,6 +514,8 @@ scenario_TRANS_CREATE_01_02 fixtureSource fixtures = it title $ \ctx -> do
err `shouldBe` "Please enter your passphrase: **************\nOk.\n"
c `shouldBe` ExitSuccess
r <- expectValidJSON (Proxy @(ApiTransaction n)) out
let txId = getTxId r

let (feeMin, feeMax) = ctx ^. #_feeEstimator $ PaymentDescription
{ nInputs = fromIntegral n
, nOutputs = fromIntegral n
Expand Down Expand Up @@ -547,8 +550,30 @@ scenario_TRANS_CREATE_01_02 fixtureSource fixtures = it title $ \ctx -> do
[ expectCliField (#balance . #available)
(`shouldBe` Quantity (faucetAmt + amnt))
]

-- Verify Tx in dest wallet is Incoming and InLedger
(Exit code1, Stdout out1, Stderr err1) <-
getTransactionViaCLI @t ctx (T.unpack (wDest ^. walletId)) txId
err1 `shouldBe` "Ok.\n"
code1 `shouldBe` ExitSuccess
outJson1 <- expectValidJSON (Proxy @(ApiTransaction n)) out1
verify outJson1
[ expectCliField (#direction . #getApiT) (`shouldBe` Incoming)
, expectCliField (#status . #getApiT) (`shouldBe` InLedger)
]

-- Verify Tx in source wallet is Outgoing and InLedger
(Exit code2, Stdout out2, Stderr err2) <-
getTransactionViaCLI @t ctx (T.unpack (wSrc ^. walletId)) txId
err2 `shouldBe` "Ok.\n"
code2 `shouldBe` ExitSuccess
outJson2 <- expectValidJSON (Proxy @(ApiTransaction n)) out2
verify outJson2
[ expectCliField (#direction . #getApiT) (`shouldBe` Outgoing)
, expectCliField (#status . #getApiT) (`shouldBe` InLedger)
]
where
title = "CLI_TRANS_CREATE_01/02 - " ++ show n ++ " recipient(s)"
title = "CLI_TRANS_CREATE_01/02, CLI_TRANS_GET_01 - " ++ show n ++ " recipient(s)"
n = fromIntegral $ length fixtures

scenario_TRANS_ESTIMATE_01_02
Expand Down

0 comments on commit bf4da8f

Please sign in to comment.