Skip to content

Commit

Permalink
Merge #879
Browse files Browse the repository at this point in the history
879: Porting the rest of forget pending tx integration tests to CLI r=KtorZ a=paweljakubas

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->
#836 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have ported the rest of forgetting pending tx integration tests to CLI

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Pawel Jakubas <[email protected]>
Co-authored-by: KtorZ <[email protected]>
  • Loading branch information
3 people authored Oct 22, 2019
2 parents c3f7cef + 6f15c87 commit c5e2676
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1539,12 +1539,10 @@ spec = do
[ expectEventually ctx getWalletEp balanceAvailable (faucetAmt - feeMax - amt)
]

rd <- request @([ApiTransaction t]) ctx (listTxEp wSrc mempty)
Default Empty
expectResponseCode @IO HTTP.status200 rd
rd <- request @([ApiTransaction t]) ctx (listTxEp wDest mempty) Default Empty

verify rd
[ expectListItemFieldEqual 0 direction Outgoing
[ expectListItemFieldEqual 0 direction Incoming
, expectListItemFieldEqual 0 status InLedger
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ import Test.Integration.Framework.TestData
( arabicWalletName
, errMsg403Fee
, errMsg403InputsDepleted
, errMsg403NoPendingAnymore
, errMsg403NotEnoughMoney
, errMsg403UTxO
, errMsg403WrongPass
, errMsg404CannotFindTx
, errMsg404NoWallet
, falseWalletIds
, kanjiWalletName
Expand Down Expand Up @@ -970,6 +972,84 @@ spec = do
[ expectCliFieldEqual balanceAvailable amt
, expectCliFieldEqual balanceTotal amt
]

(Exit c2, Stdout out2, Stderr err2) <-
listTransactionsViaCLI @t ctx [T.unpack $ wSrc ^. walletId]
err2 `shouldBe` "Ok.\n"
c2 `shouldBe` ExitSuccess

txsJson <- expectValidJSON (Proxy @([ApiTransaction t])) out2
let txJson2 = filter (\json -> json ^. #id == txId') txsJson
verify txJson2
[ expectCliListItemFieldEqual 0 direction Outgoing
, expectCliListItemFieldEqual 0 status InLedger
]

it "TRANS_DELETE_02 - Checking not pending anymore error via CLI" $ \ctx -> do
wSrc <- fixtureWallet ctx
wDest <- emptyWallet ctx
addr:_ <- listAddresses ctx wDest
let addrStr =
encodeAddress (Proxy @t) (getApiT $ fst $ addr ^. #id)
let amt = 1
let args = T.unpack <$>
[ wSrc ^. walletId
, "--payment", T.pack (show amt) <> "@" <> addrStr
]

-- post transaction
(c, out, err) <- postTransactionViaCLI @t ctx "cardano-wallet" args
err `shouldBe` "Please enter your passphrase: **************\nOk.\n"
txJson <- expectValidJSON (Proxy @(ApiTransaction t)) out
verify txJson
[ expectCliFieldEqual direction Outgoing
, expectCliFieldEqual status Pending
]
c `shouldBe` ExitSuccess

let txId' = txJson ^. #id
let txId = toUrlPiece (ApiTxId txId')

-- forget transaction
let wid = T.unpack $ wSrc ^. walletId
Exit c1 <- deleteTransactionViaCLI @t ctx wid (T.unpack txId)
c1 `shouldBe` ExitSuccess

expectEventually' ctx getWalletEp balanceTotal amt wDest

-- forget transaction once again
(Exit c2, Stdout out2, Stderr err2) <-
deleteTransactionViaCLI @t ctx wid (T.unpack txId)
err2 `shouldContain` errMsg403NoPendingAnymore txId
out2 `shouldBe` ""
c2 `shouldBe` ExitFailure 1

it "TRANS_DELETE_03 - Checking no transaction id error via CLI" $ \ctx -> do
wSrc <- fixtureWallet ctx
let wid = T.unpack $ wSrc ^. walletId
let txId = "3e6ec12da4414aa0781ff8afa9717ae53ee8cb4aa55d622f65bc62619a4f7b12"
-- forget transaction once again
(Exit c, Stdout out, Stderr err) <-
deleteTransactionViaCLI @t ctx wid (T.unpack txId)
err `shouldContain` errMsg404CannotFindTx txId
out `shouldBe` ""
c `shouldBe` ExitFailure 1

describe "TRANS_DELETE_04 - False wallet ids via CLI" $ do
forM_ falseWalletIds $ \(title, walId) -> it title $ \ctx -> do
let txId = "3e6ec12da4414aa0781ff8afa9717ae53ee8cb4aa55d622f65bc62619a4f7b12"
-- forget transaction once again
(Exit c, Stdout out, Stderr err) <-
deleteTransactionViaCLI @t ctx walId (T.unpack txId)
out `shouldBe` ""
c `shouldBe` ExitFailure 1
if (title == "40 chars hex") then
err `shouldContain` "I couldn't find a wallet with \
\the given id: 1111111111111111111111111111111111111111"
else
err `shouldContain` "wallet id should be an \
\hex-encoded string of 40 characters"

where
unsafeGetTransactionTime
:: [ApiTransaction t]
Expand Down

0 comments on commit c5e2676

Please sign in to comment.