From 88d4cd937f68fc1b4b863cb50cd556604a8156e4 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Tue, 22 Oct 2019 10:28:39 +0200 Subject: [PATCH 1/5] extend Can forget pending transaction via CLI test --- .../Test/Integration/Scenario/CLI/Transactions.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/core-integration/src/Test/Integration/Scenario/CLI/Transactions.hs b/lib/core-integration/src/Test/Integration/Scenario/CLI/Transactions.hs index b010cb7986a..f8bea3299f9 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/CLI/Transactions.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/CLI/Transactions.hs @@ -970,6 +970,19 @@ 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 + ] + where unsafeGetTransactionTime :: [ApiTransaction t] From 320e7a0b0a25682f3e49086f70caac8ae8d137af Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Tue, 22 Oct 2019 10:49:10 +0200 Subject: [PATCH 2/5] porting checking not pending anymore error test to CLI --- .../Integration/Scenario/CLI/Transactions.hs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/lib/core-integration/src/Test/Integration/Scenario/CLI/Transactions.hs b/lib/core-integration/src/Test/Integration/Scenario/CLI/Transactions.hs index f8bea3299f9..f74d0efed25 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/CLI/Transactions.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/CLI/Transactions.hs @@ -93,6 +93,7 @@ import Test.Integration.Framework.TestData ( arabicWalletName , errMsg403Fee , errMsg403InputsDepleted + , errMsg403NoPendingAnymore , errMsg403NotEnoughMoney , errMsg403UTxO , errMsg403WrongPass @@ -983,6 +984,44 @@ spec = do , 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 + where unsafeGetTransactionTime :: [ApiTransaction t] From 3c5fa506a45e5cf44aca17c386a91a5a075c4fde Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Tue, 22 Oct 2019 11:10:54 +0200 Subject: [PATCH 3/5] port checking no transaction id error test to CLI --- .../Test/Integration/Scenario/CLI/Transactions.hs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/core-integration/src/Test/Integration/Scenario/CLI/Transactions.hs b/lib/core-integration/src/Test/Integration/Scenario/CLI/Transactions.hs index f74d0efed25..c12226b5748 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/CLI/Transactions.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/CLI/Transactions.hs @@ -97,6 +97,7 @@ import Test.Integration.Framework.TestData , errMsg403NotEnoughMoney , errMsg403UTxO , errMsg403WrongPass + , errMsg404CannotFindTx , errMsg404NoWallet , falseWalletIds , kanjiWalletName @@ -1017,11 +1018,23 @@ spec = do expectEventually' ctx getWalletEp balanceTotal amt wDest -- forget transaction once again - (Exit c2, Stdout out2, Stderr err2) <- deleteTransactionViaCLI @t ctx wid (T.unpack txId) + (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 + where unsafeGetTransactionTime :: [ApiTransaction t] From 358c9d5a62088f417ba75c37984490c08a085ed2 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Tue, 22 Oct 2019 11:21:25 +0200 Subject: [PATCH 4/5] port false wallet ids error to CLI --- .../Test/Integration/Scenario/CLI/Transactions.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/core-integration/src/Test/Integration/Scenario/CLI/Transactions.hs b/lib/core-integration/src/Test/Integration/Scenario/CLI/Transactions.hs index c12226b5748..41f8a4a9868 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/CLI/Transactions.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/CLI/Transactions.hs @@ -1035,6 +1035,21 @@ spec = do 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] From 6f15c87df43cb8c9f20553e2c8775f2bbf75d9ee Mon Sep 17 00:00:00 2001 From: KtorZ Date: Tue, 22 Oct 2019 13:20:20 +0200 Subject: [PATCH 5/5] assert on the source wallet in TRANS_DELETE_01 The source wallet is a fixture wallet, so there are incoming transactions which may come from different sources. Since we list transactions with no particular ordering, we can't really guarantee which one will be the first item. Using the destination wallet instead makes it non ambiguous as there is only one transaction in this wallet --- .../src/Test/Integration/Scenario/API/Transactions.hs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/core-integration/src/Test/Integration/Scenario/API/Transactions.hs b/lib/core-integration/src/Test/Integration/Scenario/API/Transactions.hs index cce6c0dad3c..c582f37584d 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/API/Transactions.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/API/Transactions.hs @@ -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 ]