Skip to content

Commit

Permalink
Review rework
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Nov 3, 2020
1 parent e6aa604 commit eb74e0e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module Test.Integration.Framework.TestData
, errMsg403NotEnoughMoney
, errMsg403NotEnoughMoney_
, errMsg403WrongPass
, errMsg403NoPendingAnymore
, errMsg403AlreadyInLedger
, errMsg404NoSuchPool
, errMsg403PoolAlreadyJoined
, errMsg403NotDelegating
Expand Down Expand Up @@ -353,9 +353,9 @@ errMsg404NoEndpoint = "I couldn't find the requested endpoint. If the endpoint\
\ contains path parameters, please ensure they are well-formed, otherwise I\
\ won't be able to route them correctly."

errMsg403NoPendingAnymore :: Text -> String
errMsg403NoPendingAnymore tid = "The transaction with id: " ++ unpack tid ++
" cannot be forgotten as it is not pending anymore."
errMsg403AlreadyInLedger :: Text -> String
errMsg403AlreadyInLedger tid = "The transaction with id: " ++ unpack tid ++
" cannot be forgotten as it is already in the ledger."

errMsg404NoSuchPool :: Text -> String
errMsg404NoSuchPool pid = "I couldn't find any stake pool with the given id: "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ import Test.Integration.Framework.TestData
, errMsg400StartTimeLaterThanEndTime
, errMsg400TxMetadataStringTooLong
, errMsg400TxTooLarge
, errMsg403AlreadyInLedger
, errMsg403Fee
, errMsg403InputsDepleted
, errMsg403NoPendingAnymore
, errMsg403NotAShelleyWallet
, errMsg403NotEnoughMoney
, errMsg403NotEnoughMoney_
Expand Down Expand Up @@ -2174,7 +2174,7 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do
let ep = Link.deleteTransaction @'Shelley wSrc (ApiTxId txid)
rDel <- request @ApiTxId ctx ep Default Empty
expectResponseCode @IO HTTP.status403 rDel
let err = errMsg403NoPendingAnymore (toUrlPiece (ApiTxId txid))
let err = errMsg403AlreadyInLedger (toUrlPiece (ApiTxId txid))
expectErrorMessage err rDel

describe "TRANS_DELETE_03 - checking no transaction id error for " $ do
Expand All @@ -2187,7 +2187,7 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do
txDeleteFromDifferentWalletTest emptyRandomWallet "byron-wallets"

it "TRANS_TTL_DELETE_01 - Shelley: can remove expired tx" $ \ctx -> do
(wa, wb) <- (,) <$> fixtureWallet ctx <*> fixtureWallet ctx
(wa, wb) <- (,) <$> fixtureWallet ctx <*> emptyWallet ctx
let amt = minUTxOValue :: Natural

-- this transaction is going to expire really soon.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ import Test.Integration.Framework.DSL
)
import Test.Integration.Framework.TestData
( arabicWalletName
, errMsg403NoPendingAnymore
, errMsg403AlreadyInLedger
, errMsg403WrongPass
, errMsg404CannotFindTx
, errMsg404NoWallet
Expand Down Expand Up @@ -741,7 +741,7 @@ spec = describe "SHELLEY_CLI_TRANSACTIONS" $ do
-- Try Forget transaction once it's no longer pending
(Exit c2, Stdout out2, Stderr err2) <-
deleteTransactionViaCLI @t ctx wSrcId txId
err2 `shouldContain` errMsg403NoPendingAnymore (T.pack txId)
err2 `shouldContain` errMsg403AlreadyInLedger (T.pack txId)
out2 `shouldBe` ""
c2 `shouldBe` ExitFailure 1

Expand Down
4 changes: 2 additions & 2 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2500,9 +2500,9 @@ instance LiftHandler ErrRemoveTx where
, toText tid
]
ErrRemoveTxAlreadyInLedger tid ->
apiError err403 TransactionNotPending $ mconcat
apiError err403 TransactionAlreadyInLedger $ mconcat
[ "The transaction with id: ", toText tid,
" cannot be forgotten as it is not pending anymore."
" cannot be forgotten as it is already in the ledger."
]

instance LiftHandler ErrPostTx where
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/Cardano/Wallet/Api/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ newtype ApiVerificationKey = ApiVerificationKey
data ApiErrorCode
= NoSuchWallet
| NoSuchTransaction
| TransactionNotPending
| TransactionAlreadyInLedger
| WalletAlreadyExists
| NoRootKey
| WrongEncryptionPassphrase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import Test.Integration.Framework.DSL
import Test.Integration.Framework.TestData
( errMsg400MalformedTxPayload
, errMsg400WronglyEncodedTxPayload
, errMsg403NoPendingAnymore
, errMsg403AlreadyInLedger
)
import Test.Integration.Jormungandr.Scenario.API.Transactions
( ExternalTxFixture (..), fixtureExternalTx, getWalletBalance )
Expand Down Expand Up @@ -200,6 +200,6 @@ spec = do
-- Try to forget external tx
(Exit c2, Stdout out2, Stderr err2) <-
deleteTransactionViaCLI @t ctx (T.unpack $ w ^. walletId) txid
err2 `shouldContain` errMsg403NoPendingAnymore (T.pack txid)
err2 `shouldContain` errMsg403AlreadyInLedger (T.pack txid)
out2 `shouldBe` ""
c2 `shouldBe` ExitFailure 1
10 changes: 5 additions & 5 deletions specifications/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1967,16 +1967,16 @@ x-errNoSuchTransaction: &errNoSuchTransaction
type: string
enum: ['no_such_transaction']

x-errTransactionNotPending: &errTransactionNotPending
x-errTransactionAlreadyInLedger: &errTransactionAlreadyInLedger
<<: *responsesErr
title: transaction_not_pending
title: transaction_already_in_ledger
properties:
message:
type: string
description: May occur when trying to forget a transaction that is not pending.
description: Occurs when attempting to delete a transaction which is neither pending nor expired.
code:
type: string
enum: ['transaction_not_pending']
enum: ['transaction_already_in_ledger']

x-errWalletAlreadyExists: &errWalletAlreadyExists
<<: *responsesErr
Expand Down Expand Up @@ -2683,7 +2683,7 @@ x-responsesDeleteTransaction: &responsesDeleteTransaction
description: Forbidden
content:
application/json:
schema: *errTransactionNotPending
schema: *errTransactionAlreadyInLedger
404:
description: Not Found
content:
Expand Down

0 comments on commit eb74e0e

Please sign in to comment.