From 62696fd588cda3395d16b4ab9f98852e64eac91f Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Wed, 15 May 2024 16:30:11 +0200 Subject: [PATCH 01/25] introduce ApiErrorNoSuchWallet error --- lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs | 8 ++++++-- lib/api/src/Cardano/Wallet/Api/Types/Error.hs | 10 ++++++++++ lib/unit/test/unit/Cardano/Wallet/Api/TypesSpec.hs | 6 ++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs b/lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs index 5b08b1f1202..597c8b2199e 100644 --- a/lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs +++ b/lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs @@ -111,6 +111,7 @@ import Cardano.Wallet.Api.Types.Error , ApiErrorInfo (..) , ApiErrorMissingWitnessesInTransaction (..) , ApiErrorNoSuchPool (..) + , ApiErrorNoSuchWallet (..) , ApiErrorNodeNotYetInRecentEra (..) , ApiErrorNotEnoughMoney (..) , ApiErrorNotEnoughMoneyShortfall (..) @@ -251,7 +252,10 @@ instance IsServerError WalletException where instance IsServerError ErrNoSuchWallet where toServerError = \case ErrNoSuchWallet wid -> - apiError err404 NoSuchWallet $ mconcat + flip (apiError err404) message $ + NoSuchWallet ApiErrorNoSuchWallet { walletId = toText wid } + where + message = mconcat [ "I couldn't find a wallet with the given id: " , toText wid ] @@ -259,7 +263,7 @@ instance IsServerError ErrNoSuchWallet where instance IsServerError ErrWalletNotInitialized where toServerError = \case ErrWalletNotInitialized -> - apiError err404 NoSuchWallet $ mconcat + apiError err404 NoSuchWalletInitialized $ mconcat [ "The database for the requested wallet is not initialized. " ] diff --git a/lib/api/src/Cardano/Wallet/Api/Types/Error.hs b/lib/api/src/Cardano/Wallet/Api/Types/Error.hs index 7c4a164b211..97ecf387662 100644 --- a/lib/api/src/Cardano/Wallet/Api/Types/Error.hs +++ b/lib/api/src/Cardano/Wallet/Api/Types/Error.hs @@ -31,6 +31,7 @@ module Cardano.Wallet.Api.Types.Error , ApiErrorNotEnoughMoneyShortfall (..) , ApiErrorMissingWitnessesInTransaction (..) , ApiErrorNoSuchPool (..) + , ApiErrorNoSuchWallet (..) , ApiErrorUnsupportedEra (..) ) where @@ -163,6 +164,8 @@ data ApiErrorInfo !ApiErrorNoSuchPool | NoSuchTransaction | NoSuchWallet + !ApiErrorNoSuchWallet + | NoSuchWalletInitialized | NoUtxosAvailable | NodeNotYetInRecentEra !ApiErrorNodeNotYetInRecentEra @@ -327,3 +330,10 @@ data ApiErrorNoSuchPool = ApiErrorNoSuchPool deriving (Data, Eq, Generic, Show, Typeable) deriving (FromJSON, ToJSON) via DefaultRecord ApiErrorNoSuchPool deriving anyclass NFData + +data ApiErrorNoSuchWallet = ApiErrorNoSuchWallet + { walletId :: !Text + } + deriving (Data, Eq, Generic, Show, Typeable) + deriving (FromJSON, ToJSON) via DefaultRecord ApiErrorNoSuchWallet + deriving anyclass NFData diff --git a/lib/unit/test/unit/Cardano/Wallet/Api/TypesSpec.hs b/lib/unit/test/unit/Cardano/Wallet/Api/TypesSpec.hs index 0444e36a8e1..295afa2c85a 100644 --- a/lib/unit/test/unit/Cardano/Wallet/Api/TypesSpec.hs +++ b/lib/unit/test/unit/Cardano/Wallet/Api/TypesSpec.hs @@ -278,6 +278,7 @@ import Cardano.Wallet.Api.Types.Error , ApiErrorMessage (..) , ApiErrorMissingWitnessesInTransaction (..) , ApiErrorNoSuchPool (..) + , ApiErrorNoSuchWallet (..) , ApiErrorNodeNotYetInRecentEra (..) , ApiErrorNotEnoughMoney (..) , ApiErrorNotEnoughMoneyShortfall (..) @@ -804,6 +805,7 @@ spec = do jsonTest @ApiErrorTxOutputLovelaceInsufficient jsonTest @ApiErrorBalanceTxUnderestimatedFee jsonTest @ApiErrorNoSuchPool + jsonTest @ApiErrorNoSuchWallet jsonTest @ApiErrorNodeNotYetInRecentEra jsonTest @ApiErrorNotEnoughMoney jsonTest @ApiFee @@ -2468,6 +2470,10 @@ instance Arbitrary ApiErrorNoSuchPool where arbitrary = genericArbitrary shrink = genericShrink +instance Arbitrary ApiErrorNoSuchWallet where + arbitrary = genericArbitrary + shrink = genericShrink + instance Arbitrary ApiErrorMissingWitnessesInTransaction where arbitrary = genericArbitrary shrink = genericShrink From 47379d08a275e7f6e36a07b58cb9258eca3283fd Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Wed, 15 May 2024 17:12:03 +0200 Subject: [PATCH 02/25] swagger --- .../data/Cardano/Wallet/Api/ApiError.json | 931 +----------------- .../Wallet/Api/ApiErrorNoSuchWallet.json | 35 + specifications/api/swagger.yaml | 51 + 3 files changed, 101 insertions(+), 916 deletions(-) create mode 100644 lib/unit/test/data/Cardano/Wallet/Api/ApiErrorNoSuchWallet.json diff --git a/lib/unit/test/data/Cardano/Wallet/Api/ApiError.json b/lib/unit/test/data/Cardano/Wallet/Api/ApiError.json index adad3776aa0..8d4ee31a464 100644 --- a/lib/unit/test/data/Cardano/Wallet/Api/ApiError.json +++ b/lib/unit/test/data/Cardano/Wallet/Api/ApiError.json @@ -1,946 +1,45 @@ { "samples": [ { - "code": "unsupported_media_type", - "message": "\u0015팟􄸁E􎈳\u0006 o\u001eꞍ" - }, - { - "code": "transaction_already_balanced", - "message": "󱀇\\cX\u001a'𦃦oR\u0016=􉱨􁚸𩉸" - }, - { - "code": "balance_tx_underestimated_fee", - "info": { - "candidate_tx_hex": "", - "candidate_tx_readable": "(", - "estimated_number_of_bootstrap_key_wits": 0, - "estimated_number_of_key_wits": 2, - "underestimation": { - "quantity": 19770424347101868, - "unit": "lovelace" - } - }, - "message": "T𤢸sM\u001ba󵵩I" - }, - { - "code": "rejected_by_core_node", - "message": "t>Vc\u0004" - }, - { - "code": "created_wrong_policy_script_template", - "message": "S𫥋`" - }, - { - "code": "not_implemented", - "message": "H󻻡6]" - }, - { - "code": "validity_interval_not_inside_script_timelock", - "message": "\u000e&/`#\u001cIP\u0011䳓w" - }, - { - "code": "transaction_already_in_ledger", - "message": "s\u001f\r\u0001_𤭘T)l𰛞𤌿􎭉^;" - }, - { - "code": "non_null_rewards", - "message": "f\\p_쩧J" - }, - { - "code": "past_horizon", - "message": "b\u0002\\=Nl8Y" - }, - { - "code": "shared_wallet_incomplete", - "message": "stA\u000eJ[{幬" - }, - { - "code": "input_resolution_conflicts", - "message": "􃄕𬕲du5" - }, - { - "code": "shared_wallet_script_template_invalid", - "message": "eH\u0014\u0016􅄲㛼\t𬉕E;" - }, - { - "code": "unexpected_error", - "message": "𧚔𪊯􀈔-}􀲕D" - }, - { - "code": "balance_tx_existing_total_collateral", - "message": "3𤘘7t|a" - }, - { - "code": "utxo_too_small", - "info": { - "tx_output_index": 1, - "tx_output_lovelace_required_minimum": { - "quantity": 0, - "unit": "lovelace" - }, - "tx_output_lovelace_specified": { - "quantity": 19932530910944474, - "unit": "lovelace" - } - }, - "message": "󼠎팚" + "code": "balance_tx_existing_return_collateral", + "message": "9󲜨𰋆\u001b\u000by쨤v\u001b󳝾" }, { "code": "input_resolution_conflicts", - "message": ",N\u0003~\u001a󹝭􆔚s݁H􀂮6A0" - }, - { - "code": "hardened_derivation_required", - "message": "󶘥\u0001𖽝i\u000e9" - }, - { - "code": "query_param_missing", - "message": "GqgK𑤡𱅁" - }, - { - "code": "network_query_failed", - "message": "𰭼􎨆" - }, - { - "code": "shared_wallet_no_such_cosigner", - "info": { - "cosigner_index": 6, - "credential_type": "delegation" - }, - "message": "4 k󿝭L]4:𥊐ﵱa" - }, - { - "code": "asset_not_present", - "message": "g`v𪜕OO2L蒞g" - }, - { - "code": "redeemer_target_not_found", - "message": "㬩6]l\u001b>󱠝" - }, - { - "code": "malformed_tx_payload", - "message": "n" - }, - { - "code": "output_token_bundle_size_exceeds_limit", - "message": "\\d􉽜" - }, - { - "code": "shared_wallet_cannot_update_key", - "message": "[⾣<ꎆ4paf\u0013Uq𐓋|" - }, - { - "code": "wrong_mnemonic", - "message": "\u001fi8𤇁⋥-]􌇂󳃰" - }, - { - "code": "insufficient_collateral", - "message": "`\u0005v𒇺𝘼m4V{" - }, - { - "code": "missing_reward_account", - "message": "P&.\u001d]𤖬y`o𨙨'V$" - }, - { - "code": "unsupported_media_type", - "message": "\u0017\u0007󴊇󹎦" - }, - { - "code": "no_such_wallet", - "message": "c]ࠓ*𓁽𱖿\u001e⛥%v]\u0001" - }, - { - "code": "insufficient_collateral", - "message": "𗯥n\u000c" - }, - { - "code": "existing_key_witnesses", - "message": "앆󿍭\u0007" - }, - { - "code": "cannot_cover_fee", - "message": "Y秂" - }, - { - "code": "redeemer_target_not_found", - "message": "\u0011鯧2\u001fy)(s+" - }, - { - "code": "shared_wallet_incomplete", - "message": "e\u0013K􋉫x8\u000c>\u0010TS\u0003" - }, - { - "code": "node_not_yet_in_recent_era", - "info": { - "node_era": "byron", - "supported_recent_eras": [ - "babbage", - "alonzo" - ] - }, - "message": "𧰏@qs𬤻DL\u0017􆊛'" - }, - { - "code": "withdrawal_not_possible_without_vote", - "message": "􆺮-\u000b𧥬v~j󴂙}6<\u0003l" - }, - { - "code": "output_token_quantity_exceeds_limit", - "message": "먆𛊊?bi(𩟹󶂟𞴈" - }, - { - "code": "balance_tx_internal_error", - "message": "\u0003;xX􉶄" - }, - { - "code": "asset_not_present", - "message": "" + "message": "𨈃鸍𧾒􄧛5ml" }, { "code": "missing_reward_account", - "message": "\u000c\u0015\u0008u" - }, - { - "code": "cannot_cover_fee", - "message": "􆹕$m\u0010KA󰁸]a" - }, - { - "code": "query_param_missing", - "message": "IM*𮙸􋀁>\u001bn<\u001eYG" - }, - { - "code": "not_synced", - "message": "􊼺;" - }, - { - "code": "wallet_metadata_not_found", - "message": "$8:})󷶿_9􀄫\u0007}9B" - }, - { - "code": "soft_derivation_required", - "message": "\u0001x󷗏Oi\u0012h󼼎]" - }, - { - "code": "created_multidelegation_transaction", - "message": "\\\rk_JzT" - }, - { - "code": "node_not_yet_in_recent_era", - "info": { - "node_era": "allegra", - "supported_recent_eras": [ - "byron", - "alonzo", - "byron", - "babbage" - ] - }, - "message": "0" - }, - { - "code": "no_such_wallet", - "message": "󱹯𘄂cq󳊹D" - }, - { - "code": "past_horizon", - "message": "𫗙󴰵󿂷\u0007z~i" - }, - { - "code": "malformed_tx_payload", - "message": "GᎵ0ZC𐚻$4\"a\u0012" - }, - { - "code": "rejected_by_core_node", - "message": "\u0016*􁠥n]\u0005*\u0006rpM" - }, - { - "code": "unable_to_determine_current_epoch", - "message": "\u000fF\t\u0008\u0014􃼐o󺐕|)A^" - }, - { - "code": "network_query_failed", - "message": "*D" - }, - { - "code": "not_delegating_to", - "message": "0X􁂸𥕝!+^E\t\n" - }, - { - "code": "min_withdrawal_wrong", - "message": " \\Ay\u0011\u0014" - }, - { - "code": "redeemer_script_failure", - "message": "𢃲" - }, - { - "code": "method_not_allowed", - "message": "wO%\u001f\u0014\u00010󵡖VA" - }, - { - "code": "voting_in_invalid_era", - "message": "􅵯I)󳩂󻤁𧎥j3Z𮀣󱔰W" - }, - { - "code": "wallet_already_exists", - "message": "\u001e\u00073=\u001f4󽊼𐅯\n\"𨗁" - }, - { - "code": "cannot_cover_fee", - "message": "⻙" - }, - { - "code": "node_not_yet_in_recent_era", - "info": { - "node_era": "byron", - "supported_recent_eras": [ - "mary", - "babbage", - "byron", - "byron", - "babbage" - ] - }, - "message": "\u0010􋔫'`\u0006t󹁺𰡅|pB" - }, - { - "code": "pool_already_joined_same_vote", - "message": ";\u0018𮃁hy" - }, - { - "code": "same_vote", - "message": "\nd󾇢Y𦌕\u0013D𒒒骲k" - }, - { - "code": "address_already_exists", - "message": "/vY␟\u0007" - }, - { - "code": "already_withdrawing", - "message": "/I􎁂OE0󲅵A$\u001di\u0019f" - }, - { - "code": "block_header_not_found", - "message": "=" - }, - { - "code": "no_root_key", - "message": "SpS辪\u001f\u0019 " - }, - { - "code": "unable_to_determine_current_epoch", - "message": "\u0013\u0005,𬳭𱑪$ai" - }, - { - "code": "existing_key_witnesses", - "message": "7󳛇@\u000e@\"\u0006썞" - }, - { - "code": "insufficient_collateral", - "message": "<𭗂\u001f7\u0013𮰥" - }, - { - "code": "balance_tx_existing_total_collateral", - "message": ":𬩺\u0002V9淺~T𢷁t\u001f\u0010\u0019" - }, - { - "code": "insufficient_collateral", - "message": "i*a󲆒K*\u001aG𤜊𫼘[𦛢x" - }, - { - "code": "unexpected_error", - "message": "G盼\u0019🥧Si\u0001𡣕" - }, - { - "code": "redeemer_target_not_found", - "message": "0ettXv󸗵\u001f𢏞X𢡐{" - }, - { - "code": "translation_byron_tx_out_in_context", - "message": "\u0007" - }, - { - "code": "invalid_wallet_type", - "message": "􏻯\u0008(Fo􁖼#95" - }, - { - "code": "tx_not_in_node_era", - "message": "\u001b痰\u001cず𭼱𞲜\"" - }, - { - "code": "node_not_yet_in_recent_era", - "info": { - "node_era": "babbage", - "supported_recent_eras": [ - "allegra", - "babbage", - "allegra", - "allegra", - "shelley", - "babbage" - ] - }, - "message": ":\u0016􇑲m" - }, - { - "code": "shared_wallet_incomplete", - "message": "|y=}\u000cb󸺖󵿤鼔A\u0008" - }, - { - "code": "block_header_not_found", - "message": "\"~" - }, - { - "code": "shared_wallet_incomplete", - "message": "z\u000f󱳦:Z𧈶謰48􂆕悯" - }, - { - "code": "output_token_quantity_exceeds_limit", - "message": "𤐍&V'f" - }, - { - "code": "created_multidelegation_transaction", - "message": " zb+󲨁\u0005󹈞􌔖󴝰" - }, - { - "code": "balance_tx_existing_key_witnesses", - "message": ">M 𪷮:\u0013\u001bJX`\u001d􉖯" - }, - { - "code": "block_header_not_found", - "message": "Ae|X+\"i|Z6" - }, - { - "code": "not_synced", - "message": "Xp*" - }, - { - "code": "mempool_is_full", - "message": "\r\u0010r*!D\r$[B􇢓󵝖" - }, - { - "code": "no_utxos_available", - "message": "\u0018􍬜\n􄫏W" - }, - { - "code": "unsupported_media_type", - "message": "K]" - }, - { - "code": "unresolved_inputs", - "message": "{,3" - }, - { - "code": "no_such_pool", - "info": { - "pool_id": "2a291332313210231022320c3333233c10051a393017323c082d3e0f" - }, - "message": "\u001c\u0014\u001a󸫻Q\u0000\u0014m[2}k𰷕􇗻" - }, - { - "code": "query_param_missing", - "message": "V5\"󹁨\u000cz𥜾Yw)􃫖" - }, - { - "code": "not_implemented", - "message": "" - }, - { - "code": "hardened_derivation_required", - "message": "xﮎ" - }, - { - "code": "cannot_cover_fee", - "message": "~k[a\u0011" - }, - { - "code": "unsupported_media_type", - "message": "5X" - }, - { - "code": "wallet_not_responding", - "message": "􇤐_gb3t\u0005`" - }, - { - "code": "shared_wallet_no_such_cosigner", - "info": { - "cosigner_index": 5, - "credential_type": "payment" - }, - "message": "]7" - }, - { - "code": "withdrawal_not_beneficial", - "message": "t\u0017𫂡𩂗H\u0006d\u0006𢧑a'iP󳥑" - }, - { - "code": "no_such_wallet", - "message": "\u001c\u0011" - }, - { - "code": "pool_already_joined_same_vote", - "message": "\u0000􉅉d\u0013e" - }, - { - "code": "mempool_is_full", - "message": "{A𬭖\u0008\u0017y􎝺" - }, - { - "code": "created_multiaccount_transaction", - "message": ">L毌q𣊺S󳥪藯𤡽b" - }, - { - "code": "key_not_found_for_address", - "message": "􄿘2$C)c𝛤\u000e𡠤\u0012\u001d\u0004󾳃" - }, - { - "code": "redeemer_script_failure", - "message": "" - }, - { - "code": "created_invalid_transaction", - "message": "􂰲;p~kWn" - }, - { - "code": "mempool_is_full", - "message": "􃩂*Asz" - }, - { - "code": "network_unreachable", - "message": "{J" - }, - { - "code": "query_param_missing", - "message": "3Z5" - }, - { - "code": "not_delegating_to", - "message": "h" - }, - { - "code": "shared_wallet_cannot_update_key", - "message": "揱\u000f􎅾ᬈ" - }, - { - "code": "translation_error", - "message": "sEB%𫛷駏'" - }, - { - "code": "rejected_by_core_node", - "message": "" - }, - { - "code": "not_synced", - "message": "CZ\u0016g#9\u0002𛄠`I" - }, - { - "code": "redeemer_target_not_found", - "message": "\u0010F~YQj􆩋󹵄𝁟\u0005\u001d" - }, - { - "code": "balance_tx_existing_total_collateral", - "message": "m󻙞3/\t" - }, - { - "code": "not_found", - "message": "%HP\u0002yz󴥸\t𣨝𩴗)\"E\u001c" - }, - { - "code": "network_unreachable", - "message": "𝨃\\\u0019X党=l(㷊" - }, - { - "code": "utxo_too_small", - "info": { - "tx_output_index": 0, - "tx_output_lovelace_required_minimum": { - "quantity": 20663996575782212, - "unit": "lovelace" - }, - "tx_output_lovelace_specified": { - "quantity": 32782666421279309, - "unit": "lovelace" - } - }, - "message": "`6<" - }, - { - "code": "voting_in_invalid_era", - "message": "\u0001^흌\u0012/\u0004🁷K|􈍍" - }, - { - "code": "translation_error", - "message": "\u0005,󱈨\u0003.m=𫜍!D%>᪫" - }, - { - "code": "shared_wallet_no_such_cosigner", - "info": { - "cosigner_index": 3, - "credential_type": "delegation" - }, - "message": "%7𧱗􍩙𠃃t06|𔓂I}𭏙" - }, - { - "code": "created_invalid_transaction", - "message": "\rx" - }, - { - "code": "created_multidelegation_transaction", - "message": "v4r𠞭}8𡹆>\u0000*R1Yv" - }, - { - "code": "created_multidelegation_transaction", - "message": "5𧗔}W{󸨆𮧱S_􅚎" - }, - { - "code": "output_token_quantity_exceeds_limit", - "message": "􁮞&x(𢾽􂘎𮸆㤂" - }, - { - "code": "shared_wallet_key_already_exists", - "message": "!]􍨵M'󷴒\u0014" - }, - { - "code": "asset_not_present", - "message": "\u000bs\u0017#S\u000c9J\u000b\u001d_􉳪" + "message": "!2𨊚=" }, { "code": "invalid_coin_selection", - "message": "𥰢ka.􋍣nhI𩭧o􎈌鉶" - }, - { - "code": "balance_tx_internal_error", - "message": "􀰙wk\u001c" - }, - { - "code": "min_withdrawal_wrong", - "message": "r`<\u0010邌k^x/AꂯCI" - }, - { - "code": "hardened_derivation_required", - "message": "\u0017DA􀃲󼠃\u0000" - }, - { - "code": "balance_tx_conflicting_networks", - "message": "/}􍸅𧴿𛰼v" - }, - { - "code": "not_synced", - "message": "%э*檆\u0013_𥼠\u0006\u0014𖽈银K\u001fꐒ" - }, - { - "code": "missing_reward_account", - "message": " D𗭍=\u000fk\u0015f䔯m6oKW" - }, - { - "code": "missing_policy_public_key", - "message": "'s􀸱\tIU\u001fuA" - }, - { - "code": "no_utxos_available", - "message": "햧,𭚗" - }, - { - "code": "not_synced", - "message": "@\u0008𣤼#𩹥/\u0016蓯" - }, - { - "code": "not_implemented", - "message": "󷥉Tx\u0006bIyi鞈0􍘄󹛵󼅊Syl㟬󿐩\u0002󱴎6" - }, - { - "code": "wallet_metadata_not_found", - "message": "\u0012p􇜷󰈁" - }, - { - "code": "delegation_invalid", - "message": ":b𝗀iJW\u0013z󴌆bW铹㸆" - }, - { - "code": "not_found", - "message": "\u0006\u0006G|" - }, - { - "code": "transaction_already_balanced", - "message": "c\u0005 뮁𗯴\t\u000eg^\u001eg$\u00135" - }, - { - "code": "validity_interval_not_inside_script_timelock", - "message": "U𓉆{𱁇\u0005" - }, - { - "code": "unable_to_assign_input_output", - "message": "&]:\u0012p0VD" - }, - { - "code": "created_multidelegation_transaction", - "message": "dm!H" - }, - { - "code": "redeemer_target_not_found", - "message": "\u000eH}`4C!󿣚r\\𗪖𓅡t􁁋" - }, - { - "code": "inputs_depleted", - "message": "wL`𣵯\u0014K\u0008YT\u0015" - }, - { - "code": "translation_byron_tx_out_in_context", - "message": "&" - }, - { - "code": "not_synced", - "message": "$C" + "code": "network_misconfigured", + "message": "x\u0000" }, { "code": "delegation_invalid", - "message": "􌳷nv," + "message": "䎇\u0013O躰\u0019!^6U6ꪸ\u001d\u0008䡴" }, { - "code": "node_not_yet_in_recent_era", - "info": { - "node_era": "allegra", - "supported_recent_eras": [ - "allegra", - "mary", - "mary" - ] - }, - "message": "8𣦡{YO+\\\u0006K" - }, - { - "code": "balance_tx_existing_return_collateral", - "message": "`D" - }, - { - "code": "redeemer_invalid_data", - "message": "Y" - }, - { - "code": "hardened_derivation_required", - "message": "" - }, - { - "code": "translation_error", - "message": "+􈙙𠠵s\u0001襴0.y" - }, - { - "code": "start_time_later_than_end_time", - "message": "" - }, - { - "code": "created_multidelegation_transaction", - "message": "*\n𰄢| p{s􌸹𲈷" - }, - { - "code": "created_multiaccount_transaction", - "message": "krベ\u0014𩝤~𦲐^\u0003􏷏" - }, - { - "code": "missing_reward_account", - "message": "褔[n}G?M\u0002𱎾5" - }, - { - "code": "no_utxos_available", - "message": "'𮶂#𓂨 " - }, - { - "code": "missing_witnesses_in_transaction", - "info": { - "detected_number_of_key_wits": 7, - "expected_number_of_key_wits": 2 - }, - "message": "\u0006`1Gd" - }, - { - "code": "created_wrong_policy_script_template", - "message": "VnPNES􄳟b\u0004%󳉢/" - }, - { - "code": "query_param_missing", - "message": "𘎶𐾺M" - }, - { - "code": "balance_tx_conflicting_networks", - "message": "o󾌞\t27\u0002짛𢯛" - }, - { - "code": "balance_tx_inline_plutus_v3_script_not_supported_in_babbage", - "message": "\t𤋬󽒶Kc}\u0019𭸤\"𩱍􋛟h" - }, - { - "code": "missing_policy_public_key", - "message": "\u0005\u001eN^+ILZ" - }, - { - "code": "node_not_yet_in_recent_era", - "info": { - "node_era": "alonzo", - "supported_recent_eras": [] - }, - "message": "|𤽸0n" - }, - { - "code": "not_enough_money", - "info": { - "shortfall": { - "ada": { - "quantity": 29203954436170393, - "unit": "lovelace" - }, - "assets": [ - { - "asset_name": "0001010101000001000000010000010100010000000101000000010001000100", - "policy_id": "00010101010101010001010001010101010101000101010000010001", - "quantity": 1 - }, - { - "asset_name": "0100000000010000010101010000010101000101010000000001000101000000", - "policy_id": "00000100010000000101000101000001000100010001000001010001", - "quantity": 1 - }, - { - "asset_name": "0001000001000000010101010100010000000001010100000101000001010100", - "policy_id": "00010100000100010001000101000001010100010100000000000000", - "quantity": 0 - }, - { - "asset_name": "0001010001010000000000000101010101010101000100010101010001010000", - "policy_id": "01010100000000000001000100010101000000010101000000010101", - "quantity": 1 - } - ] - } - }, - "message": "\u0019o\u001ex:鲙" - }, - { - "code": "created_multidelegation_transaction", - "message": "𠝥\u0011[" - }, - { - "code": "not_acceptable", - "message": "\\\u0019\u001cz" - }, - { - "code": "unable_to_determine_current_epoch", - "message": "𛊐8" - }, - { - "code": "output_token_bundle_size_exceeds_limit", - "message": "D\u0008I" - }, - { - "code": "created_wrong_policy_script_template", - "message": "𩰲􆹒犔􏵏%J􈮽\u0004g𦜢/" - }, - { - "code": "redeemer_invalid_data", - "message": "v4󶔙" + "code": "missing_reward_account", + "message": "󸺝󰘵V|" } ], - "seed": -36971223 + "seed": 76464662 } \ No newline at end of file diff --git a/lib/unit/test/data/Cardano/Wallet/Api/ApiErrorNoSuchWallet.json b/lib/unit/test/data/Cardano/Wallet/Api/ApiErrorNoSuchWallet.json new file mode 100644 index 00000000000..3bcd36e443f --- /dev/null +++ b/lib/unit/test/data/Cardano/Wallet/Api/ApiErrorNoSuchWallet.json @@ -0,0 +1,35 @@ +{ + "samples": [ + { + "wallet_id": "@𗁄𧧽𨧯\u0018-a.B\"w\u0016叁'\u0012s2,ᢾ!\u000erTD\u0007fw" + }, + { + "wallet_id": "󳟭􅦫iᚠC\u001e􊡠L\u000b𰿐h-󱉋\u00012I󰉏䯾𮝣:󴒞􁩋(" + }, + { + "wallet_id": "\u001dqaaR𦝭&=𱇑\u001dZ\u0011#1M󸝙" + }, + { + "wallet_id": "PS􎅱\\*|\u0011@" + }, + { + "wallet_id": "\u0004&\u0008\n5^DI*K\u0011􆗴r\u0005I𰶼N!@&\u001c\u0008kd􂦠A" + }, + { + "wallet_id": "󳓫wU\ti𢊶\u0003d􀮊s𢚤K\u0016󴬅SN𦻙𢏯\u001c*󸖐䪘K􀴤\t\u0013u{󼛎" + }, + { + "wallet_id": "􈾜nJ'𘥵F\u0005UR󲖒寔\u001a󰽦OB7𥪥.󴺗\u0018H" + }, + { + "wallet_id": "S&􃆳𨟤𫃄㿝y\u0013]" + }, + { + "wallet_id": "RT𱸖\r𦵯􀜌\u0005💧" + }, + { + "wallet_id": "\u001c1\u000cboG\\\"U󵢏󳗀\u0018" + } + ], + "seed": 1010481003 +} \ No newline at end of file diff --git a/specifications/api/swagger.yaml b/specifications/api/swagger.yaml index 6ea600a5455..9242115ac99 100644 --- a/specifications/api/swagger.yaml +++ b/specifications/api/swagger.yaml @@ -4361,6 +4361,18 @@ x-errNoUtxosAvailable: &errNoUtxosAvailable type: string enum: ['no_utxos_available'] +x-errNoSuchWalletInitialized: &errNoSuchWalletInitialized + <<: *responsesErr + title: no_such_wallet_initialized + properties: + message: + type: string + description: | + May occur when the database for the requested wallet is not initialized. + code: + type: string + enum: ['no_such_wallet_initialized'] + x-errNoSuchWallet: &errNoSuchWallet <<: *responsesErr title: no_such_wallet @@ -4373,6 +4385,12 @@ x-errNoSuchWallet: &errNoSuchWallet code: type: string enum: ['no_such_wallet'] + info: + type: object + required: + - wallet_id + properties: + wallet_id: *walletId x-errNoSuchTransaction: &errNoSuchTransaction <<: *responsesErr @@ -5647,6 +5665,13 @@ x-responsesErr404WalletNotFound: &responsesErr404WalletNotFound application/json: schema: *errNoSuchWallet +x-responsesErr404DbNotInitialized: &responsesErr404DbNotInitialized + 404: + description: DB uninitialized + content: + application/json: + schema: *errNoSuchWalletInitialized + x-responsesErr503WalletMetadataNotFound: &responsesErr503WalletMetadataNotFound 503: description: No meta @@ -5726,6 +5751,7 @@ x-responsesListByronWallets: &responsesListByronWallets x-responsesGetUTxOsStatistics: &responsesGetUTxOsStatistics <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 200: description: Ok @@ -5735,6 +5761,7 @@ x-responsesGetUTxOsStatistics: &responsesGetUTxOsStatistics x-responsesGetWalletUtxoSnapshot: &responsesGetWalletUtxoSnapshot <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 200: description: Ok @@ -5792,6 +5819,7 @@ x-responsesPostByronWallet: &responsesPostByronWallet x-responsesGetWallet: &responsesGetWallet <<: *responsesErr400 <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 200: description: Ok @@ -5811,6 +5839,7 @@ x-responsesGetByronWallet: &responsesGetByronWallet x-responsesGetSharedWallet: &responsesGetSharedWallet <<: *responsesErr400 <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 200: description: Ok @@ -5821,6 +5850,7 @@ x-responsesGetSharedWallet: &responsesGetSharedWallet x-responsesPatchSharedWallet: &responsesPatchSharedWallet <<: *responsesErr400 <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 <<: *responsesErr503WalletMetadataNotFound 403: @@ -5847,6 +5877,7 @@ x-responsesCreateWalletMigrationPlan: &responsesCreateWalletMigrationPlan application/json: schema: *errNothingToMigrate <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 202: description: Accepted @@ -5865,6 +5896,7 @@ x-responsesMigrateWallet: &responsesMigrateWallet - <<: *errNoRootKey - <<: *errWrongEncryptionPassphrase <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 202: @@ -5879,6 +5911,7 @@ x-responsesMigrateWallet: &responsesMigrateWallet x-responsesDeleteWallet: &responsesDeleteWallet <<: *responsesErr400 <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 204: description: No Content @@ -5895,6 +5928,7 @@ x-responsesForceResyncWallet: &responsesForceResyncWallet x-responsesPutWallet: &responsesPutWallet <<: *responsesErr400 <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 200: @@ -5906,6 +5940,7 @@ x-responsesPutWallet: &responsesPutWallet x-responsesPutSharedWallet: &responsesPutSharedWallet <<: *responsesErr400 <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 200: @@ -5926,6 +5961,7 @@ x-responsesPutWalletPassphrase: &responsesPutWalletPassphrase - <<: *errWrongEncryptionPassphrase - <<: *errWrongMnemonic <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 204: @@ -5950,6 +5986,7 @@ x-responsesSelectCoins: &responsesSelectCoins - <<: *errOutputTokenQuantityExceedsLimit - <<: *errOutputTokenBundleSizeExceedsLimit <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 200: @@ -5971,6 +6008,7 @@ x-responsesDeleteTransaction: &responsesDeleteTransaction schema: oneOf: - <<: *errNoSuchWallet + - <<: *errNoSuchWalletInitialized - <<: *errNoSuchTransaction <<: *responsesErr406 204: @@ -5986,6 +6024,7 @@ x-responsesListTransactions: &responsesListTransactions - <<: *errMinWithdrawalWrong - <<: *errStartTimeLaterThanEndTime <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 200: description: Ok @@ -6008,6 +6047,7 @@ x-responsesGetTransaction: &responsesGetTransaction schema: oneOf: - <<: *errNoSuchWallet + - <<: *errNoSuchWalletInitialized - <<: *errNoSuchTransaction <<: *responsesErr406 200: @@ -6037,6 +6077,7 @@ x-responsesPostTransaction: &responsesPostTransaction - <<: *errWrongEncryptionPassphrase - <<: *errUnsupportedEra <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType <<: *responsesErr425MempoolIsFull @@ -6080,6 +6121,7 @@ x-responsesConstructTransaction: &responsesConstructTransaction - <<: *errVotingInInvalidEra - <<: *errWithdrawalNotPossibleWithoutVote <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 202: @@ -6099,6 +6141,7 @@ x-responsesSignTransaction: &responsesSignTransaction - <<: *errNoRootKey - <<: *errWrongEncryptionPassphrase <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 202: @@ -6110,6 +6153,7 @@ x-responsesSignTransaction: &responsesSignTransaction x-responsesDecodedTransaction: &responsesDecodedTransaction <<: *responsesErr400 <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 202: @@ -6121,6 +6165,7 @@ x-responsesDecodedTransaction: &responsesDecodedTransaction x-responsesSubmitTransaction: &responsesSubmitTransaction <<: *responsesErr400 <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 202: @@ -6186,6 +6231,7 @@ x-responsesPostTransactionFee: &responsesPostTransactionFee - <<: *errOutputTokenBundleSizeExceedsLimit - <<: *errTransactionIsTooBig <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 202: @@ -6201,6 +6247,7 @@ x-responsesGetDelegationFee: &responsesGetDelegationFee application/json: schema: *errCannotCoverFee <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 200: description: Ok @@ -6211,6 +6258,7 @@ x-responsesGetDelegationFee: &responsesGetDelegationFee x-responsesListAddresses: &responsesListAddresses <<: *responsesErr400 <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 200: description: Ok @@ -6383,6 +6431,7 @@ x-responsesJoinStakePool: &responsesJoinStakePool schema: oneOf: - <<: *errNoSuchWallet + - <<: *errNoSuchWalletInitialized - <<: *errNoSuchPool <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType @@ -6407,6 +6456,7 @@ x-responsesQuitStakePool: &responsesQuitStakePool - <<: *errNotDelegatingTo - <<: *errNonNullRewards <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 202: @@ -6545,6 +6595,7 @@ x-responsesBalanceTransaction: &responsesBalanceTransaction - <<: *errTranslationByronTxOutInContext <<: *responsesErr404WalletNotFound + <<: *responsesErr404DbNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 202: From b76246cbc15b1e24acb83e46b4d72f65404c9f39 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Thu, 16 May 2024 13:52:52 +0200 Subject: [PATCH 03/25] remove err403NoSuchWallet - part 1 fix --- .../Scenario/API/Shelley/CoinSelections.hs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/CoinSelections.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/CoinSelections.hs index deaab156844..bb8efb6307b 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/CoinSelections.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/CoinSelections.hs @@ -39,6 +39,10 @@ import Cardano.Wallet.Api.Types import Cardano.Wallet.Api.Types.Amount ( ApiAmount (ApiAmount) ) +import Cardano.Wallet.Api.Types.Error + ( ApiErrorInfo (..) + , ApiErrorNoSuchWallet (..) + ) import Cardano.Wallet.Primitive.NetworkId ( HasSNetworkId ) @@ -90,6 +94,7 @@ import Test.Integration.Framework.DSL , Headers (..) , Payload (..) , addField + , decodeErrorInfo , derivationPathValidationErrors , emptyWallet , expectErrorMessage @@ -107,13 +112,11 @@ import Test.Integration.Framework.DSL , selectCoinsWith , verify , verifyMsg - , walletId ) import Test.Integration.Framework.TestData ( errMsg400TxMetadataStringTooLong , errMsg403OutputTokenBundleSizeExceedsLimit , errMsg403OutputTokenQuantityExceedsLimit - , errMsg404NoWallet , errMsg406 , errMsg415 ) @@ -127,6 +130,8 @@ import qualified Data.List.NonEmpty as NE import qualified Data.Text as T import qualified Data.Text.Encoding as T import qualified Network.HTTP.Types as HTTP +import qualified Test.Integration.Framework.DSL as DSL +import qualified Test.Hspec.Expectations.Lifted as Lifted spec :: forall n @@ -220,12 +225,12 @@ spec = describe "SHELLEY_COIN_SELECTION" $ do let minUTxOValue' = ApiAmount . minUTxOValue $ _mainEra ctx let payments = AddressAmount addr minUTxOValue' mempty :| [] _ <- request @ApiWallet ctx (Link.deleteWallet @'Shelley w) Default Empty - selectCoins @_ @'Shelley ctx w payments - >>= flip - verify - [ expectResponseCode HTTP.status404 - , expectErrorMessage (errMsg404NoWallet $ w ^. walletId) - ] + rTx <- selectCoins @_ @'Shelley ctx w payments + verify rTx + [ expectResponseCode HTTP.status404 + ] + decodeErrorInfo rTx `Lifted.shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. DSL.walletId) it "WALLETS_COIN_SELECTION_03 - \ From 8bc81619803112741979d8288fa6a04393c80ac7 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Thu, 16 May 2024 15:33:51 +0200 Subject: [PATCH 04/25] refactor Shared.Wallet --- .../Integration/Scenario/API/Shared/Wallets.hs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Wallets.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Wallets.hs index c4992a769fd..31a13028bb8 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Wallets.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Wallets.hs @@ -64,6 +64,7 @@ import Cardano.Wallet.Api.Types.Amount import Cardano.Wallet.Api.Types.Error ( ApiErrorInfo (..) , ApiErrorSharedWalletNoSuchCosigner (..) + , ApiErrorNoSuchWallet (..) ) import Cardano.Wallet.Compat ( (^?) @@ -164,7 +165,6 @@ import Test.Integration.Framework.DSL , submitSharedTxWithWid , unsafeRequest , verify - , walletId , () ) import Test.Integration.Framework.TestData @@ -175,7 +175,6 @@ import Test.Integration.Framework.TestData , errMsg403TemplateInvalidScript , errMsg403TemplateInvalidUnknownCosigner , errMsg403WrongIndex - , errMsg404NoWallet , errMsg406 ) @@ -188,6 +187,7 @@ import qualified Data.Set as Set import qualified Data.Text as T import qualified Data.Text.Encoding as T import qualified Network.HTTP.Types as HTTP +import qualified Test.Integration.Framework.DSL as DSL spec :: forall n @@ -1036,7 +1036,7 @@ spec = describe "SHARED_WALLETS" $ do let putData = Json [json| { "one_change_address_mode": false } |] - let walIdOneChangeAddr = walOneAddr ^. walletId + let walIdOneChangeAddr = walOneAddr ^. DSL.walletId rPut <- request @ApiWallet ctx ("PUT", "v2/shared-wallets" walIdOneChangeAddr) Default putData verify rPut @@ -1044,7 +1044,7 @@ spec = describe "SHARED_WALLETS" $ do , expectField (#addressPoolGap . #getApiT . #getAddressPoolGap) (`shouldBe` 20) - , expectField walletId (`shouldBe` walIdOneChangeAddr) + , expectField DSL.walletId (`shouldBe` walIdOneChangeAddr) ] forM_ [1,1] $ \num -> realizeTx walOneAddr wFixture (num * minUTxOValue') destFixture @@ -1500,7 +1500,7 @@ spec = describe "SHARED_WALLETS" $ do let wal = getFromResponse Prelude.id rPost rl <- listFilteredSharedWallets - (Set.singleton (getWalletIdFromSharedWallet wal ^. walletId) ) ctx + (Set.singleton (getWalletIdFromSharedWallet wal ^. DSL.walletId) ) ctx verify (fmap (fmap (view #wallet)) <$> rl) [ expectResponseCode HTTP.status200 , expectListSize 1 @@ -1540,7 +1540,7 @@ spec = describe "SHARED_WALLETS" $ do [ expectResponseCode HTTP.status201 ] let wal = getFromResponse Prelude.id rPost - pure (getWalletIdFromSharedWallet wal ^. walletId) + pure (getWalletIdFromSharedWallet wal ^. DSL.walletId) let name = (^? (#wallet . traverse . #name . #getApiT . #getWalletName)) rl <- listFilteredSharedWallets (Set.fromList wids) ctx verify (fmap (map name) <$> rl) @@ -1567,7 +1567,7 @@ spec = describe "SHARED_WALLETS" $ do expectResponseCode HTTP.status204 rDel rl <- listFilteredSharedWallets - (Set.singleton $ getWalletIdFromSharedWallet wal ^. walletId) ctx + (Set.singleton $ getWalletIdFromSharedWallet wal ^. DSL.walletId) ctx verify rl [ expectResponseCode HTTP.status200 , expectListSize 0 @@ -1703,7 +1703,8 @@ spec = describe "SHARED_WALLETS" $ do r <- request @ApiUtxoStatistics ctx (Link.getUTxOsStatistics @'Shared w) Default Empty expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet $ w ^. walletId) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. DSL.walletId) describe "SHARED_WALLETS_UTXO_04 - HTTP headers" $ do let matrix = From cd2c47cb87922e81357af0cea01ede6f9da1a8ba Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Thu, 16 May 2024 15:45:12 +0200 Subject: [PATCH 05/25] refactor Shelley.StakePools --- .../Test/Integration/Scenario/API/Shelley/StakePools.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/StakePools.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/StakePools.hs index 4c7c8fc5d08..e7a6bdc2d31 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/StakePools.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/StakePools.hs @@ -55,6 +55,7 @@ import Cardano.Wallet.Api.Types.Amount import Cardano.Wallet.Api.Types.Error ( ApiErrorInfo (..) , ApiErrorNoSuchPool (..) + , ApiErrorNoSuchWallet (..) ) import Cardano.Wallet.Faucet ( Faucet (..) @@ -212,7 +213,6 @@ import Test.Integration.Framework.DSL , waitForTxImmutability , waitForTxStatus , waitNumberOfEpochBoundaries - , walletId , (.<) , (.>) , (.>=) @@ -220,7 +220,6 @@ import Test.Integration.Framework.DSL import Test.Integration.Framework.TestData ( errMsg403PoolAlreadyJoined , errMsg403WrongPass - , errMsg404NoWallet ) import qualified Cardano.Wallet.Api.Link as Link @@ -229,6 +228,7 @@ import qualified Data.Set as Set import qualified Data.Text as T import qualified Network.HTTP.Types.Status as HTTP import qualified Prelude +import qualified Test.Integration.Framework.DSL as DSL spec :: forall n. HasSNetworkId n => SpecWith Context spec = describe "SHELLEY_STAKE_POOLS" $ do @@ -262,7 +262,7 @@ spec = describe "SHELLEY_STAKE_POOLS" $ do it "STAKE_POOLS_JOIN_01 - Cannot join non-existent wallet" $ \ctx -> runResourceT $ do w <- emptyWallet ctx - let wid = w ^. walletId + let wid = w ^. DSL.walletId _ <- request @ApiWallet ctx @@ -272,7 +272,8 @@ spec = describe "SHELLEY_STAKE_POOLS" $ do let poolIdAbsent = PoolId $ BS.pack $ replicate 32 1 r <- joinStakePool @n ctx (SpecificPool poolIdAbsent) (w, fixturePassphrase) expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet wid) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet wid) it "STAKE_POOLS_JOIN_01 - Cannot join non-existent stakepool" $ \ctx -> runResourceT $ do w <- fixtureWallet ctx From 0977b1a2a7ae15e4b4bc110dcc4b133b820f14aa Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Thu, 16 May 2024 15:54:23 +0200 Subject: [PATCH 06/25] refactor Shared.Transactions --- .../Integration/Scenario/API/Shared/Transactions.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Transactions.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Transactions.hs index 507c036adf8..18db51d84d1 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Transactions.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Transactions.hs @@ -64,6 +64,7 @@ import Cardano.Wallet.Api.Types.Amount import Cardano.Wallet.Api.Types.Error ( ApiErrorInfo (..) , ApiErrorMissingWitnessesInTransaction (..) + , ApiErrorNoSuchWallet (..) , ApiErrorTxOutputLovelaceInsufficient (ApiErrorTxOutputLovelaceInsufficient) ) import Cardano.Wallet.Api.Types.Transaction @@ -205,7 +206,6 @@ import Test.Integration.Framework.DSL , verify , waitForNextEpoch , waitNumberOfEpochBoundaries - , walletId , (.>) ) import Test.Integration.Framework.Request @@ -214,7 +214,6 @@ import Test.Integration.Framework.Request import Test.Integration.Framework.TestData ( errMsg400StartTimeLaterThanEndTime , errMsg404CannotFindTx - , errMsg404NoWallet ) import qualified Cardano.Address.Script as CA @@ -230,6 +229,7 @@ import qualified Data.Set as Set import qualified Data.Text as T import qualified Data.Text.Encoding as T import qualified Network.HTTP.Types as HTTP +import qualified Test.Integration.Framework.DSL as DSL data TestCase a = TestCase { query :: T.Text @@ -1607,7 +1607,8 @@ spec = describe "SHARED_TRANSACTIONS" $ do (Link.listTransactions @'Shared w) Default Empty expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet $ w ^. walletId) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. DSL.walletId) it "SHARED_TRANSACTIONS_LIST_RANGE_01 - \ \Transaction at time t is SELECTED by small ranges that cover it" $ @@ -1739,7 +1740,8 @@ spec = describe "SHARED_TRANSACTIONS" $ do let link = Link.getTransaction @'Shared w (ApiTxId txid) r <- request @(ApiTransaction n) ctx link Default Empty expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet $ w ^. walletId) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. DSL.walletId) it "SHARED_TRANSACTIONS_GET_03 - \ \Using wrong transaction id" $ From 5798a1319f3637917588abc56c1deb67ea8ef97a Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Thu, 16 May 2024 16:00:33 +0200 Subject: [PATCH 07/25] refactor Shelley.TransactionsNew fix --- .../Scenario/API/Shelley/TransactionsNew.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs index afb2db0810a..71cde9dbaae 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs @@ -114,6 +114,7 @@ import Cardano.Wallet.Api.Types.Error ( ApiErrorInfo (..) , ApiErrorMissingWitnessesInTransaction (..) , ApiErrorNoSuchPool (..) + , ApiErrorNoSuchWallet (..) , ApiErrorTxOutputLovelaceInsufficient (ApiErrorTxOutputLovelaceInsufficient) ) import Cardano.Wallet.Api.Types.Transaction @@ -325,13 +326,9 @@ import Test.Integration.Framework.DSL , waitForNextEpoch , waitForTxImmutability , waitNumberOfEpochBoundaries - , walletId , (.<) , (.>) ) -import Test.Integration.Framework.TestData - ( errMsg404NoWallet - ) import UnliftIO.Exception ( fromEither ) @@ -353,6 +350,7 @@ import qualified Data.Set as Set import qualified Data.Text as T import qualified Data.Text.Encoding as T import qualified Network.HTTP.Types.Status as HTTP +import qualified Test.Integration.Framework.DSL as DSL import qualified Test.Integration.Plutus as PlutusScenario spec :: forall n. HasSNetworkId n => SpecWith Context @@ -2779,7 +2777,7 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do forM_ scenarios $ \(title, foreignByronWallet) -> it title $ \ctx -> runResourceT $ do wa <- fixtureWallet ctx wb <- foreignByronWallet ctx - let wid = wb ^. walletId + let wid = wb ^. DSL.walletId -- Construct tx payload <- mkTxPayload ctx wa (minUTxOValue (_mainEra ctx)) 1 @@ -2803,8 +2801,9 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do verify submittedTx [ expectResponseCode HTTP.status404 - , expectErrorMessage (errMsg404NoWallet wid) ] + decodeErrorInfo submittedTx `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet wid) it "TRANS_NEW_SUBMIT_03 - Can submit transaction encoded in base16" $ \ctx -> runResourceT $ do wa <- fixtureWallet ctx From 48bfe958dc8131af5a7292ae4416e1832d2daed8 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Thu, 16 May 2024 16:16:01 +0200 Subject: [PATCH 08/25] Shelley.Addresses --- .../Scenario/API/Shelley/Addresses.hs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Addresses.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Addresses.hs index 838f5cb6b45..a84b4a1aa92 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Addresses.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Addresses.hs @@ -38,6 +38,10 @@ import Cardano.Wallet.Api.Types import Cardano.Wallet.Api.Types.Amount ( ApiAmount (ApiAmount) ) +import Cardano.Wallet.Api.Types.Error + ( ApiErrorInfo (..) + , ApiErrorNoSuchWallet (..) + ) import Cardano.Wallet.Primitive.NetworkId ( HasSNetworkId ) @@ -85,6 +89,7 @@ import Test.Integration.Framework.DSL ( Context (..) , Headers (..) , Payload (..) + , decodeErrorInfo , emptyRandomWallet , emptyWallet , emptyWalletWith @@ -104,7 +109,6 @@ import Test.Integration.Framework.DSL , request , unsafeRequest , verify - , walletId ) import Test.Integration.Framework.TestData ( errMsg400ScriptDuplicateKeys @@ -113,7 +117,6 @@ import Test.Integration.Framework.TestData , errMsg400ScriptTimelocksContradictory , errMsg400ScriptWrongCoeffcient , errMsg403WrongIndex - , errMsg404NoWallet ) import qualified Cardano.Wallet.Api.Link as Link @@ -122,6 +125,7 @@ import qualified Data.Aeson.KeyMap as KeyMap import qualified Data.Aeson.Lens as Aeson import qualified Data.Text as T import qualified Network.HTTP.Types.Status as HTTP +import qualified Test.Integration.Framework.DSL as DSL spec :: forall n @@ -130,11 +134,12 @@ spec spec = describe "SHELLEY_ADDRESSES" $ do it "BYRON_ADDRESS_LIST - Byron wallet on Shelley ep" $ \ctx -> runResourceT $ do w <- emptyRandomWallet ctx - let wid = w ^. walletId + let wid = w ^. DSL.walletId let ep = ("GET", "v2/wallets/" <> wid <> "/addresses") r <- request @[ApiAddressWithPath n] ctx ep Default Empty expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet wid) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet wid) it "ADDRESS_LIST_01 - Can list known addresses on a default wallet" $ \ctx -> runResourceT $ do let g = fromIntegral $ getAddressPoolGap defaultAddressPoolGap @@ -287,7 +292,8 @@ spec = describe "SHELLEY_ADDRESSES" $ do r <- request @[ApiAddressWithPath n] ctx (Link.listAddresses @'Shelley w) Default Empty expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet $ w ^. walletId) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. DSL.walletId) it "ADDRESS_LIST_05 - bech32 HRP is correct - testnet" $ \ctx -> runResourceT $ do w <- emptyWallet ctx From fd55950142c0175cb5ba5e7bc185bb69678ab761 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Thu, 16 May 2024 16:30:55 +0200 Subject: [PATCH 09/25] refactor Byron.Migrations --- .../Scenario/API/Byron/Migrations.hs | 23 +++++++++++-------- .../Scenario/CLI/Shelley/Addresses.hs | 7 ++++-- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs index e24f3a50f9e..783723beabd 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs @@ -34,6 +34,10 @@ import Cardano.Wallet.Api.Types import Cardano.Wallet.Api.Types.Amount ( ApiAmount (ApiAmount) ) +import Cardano.Wallet.Api.Types.Error + ( ApiErrorInfo (..) + , ApiErrorNoSuchWallet (..) + ) import Cardano.Wallet.Primitive.NetworkId ( HasSNetworkId (..) ) @@ -80,6 +84,7 @@ import Test.Integration.Framework.DSL ( Context (..) , Headers (..) , Payload (..) + , decodeErrorInfo , emptyIcarusWallet , emptyRandomWallet , emptyWallet @@ -101,13 +106,11 @@ import Test.Integration.Framework.DSL , unsafeResponse , verify , waitForTxImmutability - , walletId , (.>) ) import Test.Integration.Framework.TestData ( errMsg403NothingToMigrate , errMsg403WrongPass - , errMsg404NoWallet ) import qualified Cardano.Faucet.Mnemonics as Mnemonics @@ -115,6 +118,8 @@ import qualified Cardano.Wallet.Api.Link as Link import qualified Cardano.Wallet.Api.Types as ApiTypes import qualified Data.Map.Strict as Map import qualified Network.HTTP.Types.Status as HTTP +import qualified Test.Hspec.Expectations.Lifted as Lifted +import qualified Test.Integration.Framework.DSL as DSL spec :: forall n. HasSNetworkId n => SpecWith Context spec = describe "BYRON_MIGRATIONS" $ do @@ -163,7 +168,7 @@ spec = describe "BYRON_MIGRATIONS" $ do verify response [ expectResponseCode HTTP.status403 , expectErrorMessage - (errMsg403NothingToMigrate $ sourceWallet ^. walletId) + (errMsg403NothingToMigrate $ sourceWallet ^. DSL.walletId) ] it "BYRON_CREATE_MIGRATION_PLAN_02r \ @@ -187,9 +192,9 @@ spec = describe "BYRON_MIGRATIONS" $ do (Json [json|{addresses: #{targetAddressIds}}|]) verify response [ expectResponseCode HTTP.status404 - , expectErrorMessage - (errMsg404NoWallet $ sourceWallet ^. walletId) ] + decodeErrorInfo response `Lifted.shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ sourceWallet ^. DSL.walletId) it "BYRON_CREATE_MIGRATION_PLAN_04 - \ \Cannot create a plan for a wallet that only contains dust." @@ -227,7 +232,7 @@ spec = describe "BYRON_MIGRATIONS" $ do verify response [ expectResponseCode HTTP.status403 , expectErrorMessage - (errMsg403NothingToMigrate $ sourceWallet ^. walletId) + (errMsg403NothingToMigrate $ sourceWallet ^. DSL.walletId) ] let byronCreateMigrationPlan05 fixtureByronWallet ctx = runResourceT $ do @@ -395,7 +400,7 @@ spec = describe "BYRON_MIGRATIONS" $ do $ \ctx -> forM_ [emptyRandomWallet, emptyIcarusWallet] $ \emptyByronWallet -> runResourceT $ do sourceWallet <- emptyByronWallet ctx - let sourceWalletId = sourceWallet ^. walletId + let sourceWalletId = sourceWallet ^. DSL.walletId targetWallet <- emptyWallet ctx targetAddresses <- listAddresses @n ctx targetWallet let targetAddressIds = targetAddresses <&> @@ -528,7 +533,7 @@ spec = describe "BYRON_MIGRATIONS" $ do verify response [ expectResponseCode HTTP.status403 , expectErrorMessage - (errMsg403NothingToMigrate (sourceWallet ^. walletId)) + (errMsg403NothingToMigrate (sourceWallet ^. DSL.walletId)) ] it "BYRON_MIGRATE_07 - \ @@ -571,7 +576,7 @@ spec = describe "BYRON_MIGRATIONS" $ do [ expectField (#balance . #available) (`shouldBe` ApiAmount 15) ] - let sourceWalletId = sourceWallet ^. walletId + let sourceWalletId = sourceWallet ^. DSL.walletId -- Analyse the source wallet's UTxO distribution: let expectedSourceDistribution = [(10, 5)] diff --git a/lib/integration/scenarios/Test/Integration/Scenario/CLI/Shelley/Addresses.hs b/lib/integration/scenarios/Test/Integration/Scenario/CLI/Shelley/Addresses.hs index 08fe2cc6741..32a94aa6f93 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/CLI/Shelley/Addresses.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/CLI/Shelley/Addresses.hs @@ -83,8 +83,7 @@ import Test.Integration.Framework.DSL , walletId ) import Test.Integration.Framework.TestData - ( errMsg404NoWallet - , falseWalletIds + ( falseWalletIds ) import Cardano.Wallet.Api.Types.Amount @@ -284,3 +283,7 @@ spec = describe "SHELLEY_CLI_ADDRESSES" $ do fixtureWallet' :: Context -> ResourceT IO String fixtureWallet' = fmap (T.unpack . view walletId) . fixtureWallet + + errMsg404NoWallet :: Text -> String + errMsg404NoWallet wid = + "I couldn't find a wallet with the given id: " ++ T.unpack wid From 3b2c25ea6268837698299309108d6d491193198f Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Fri, 17 May 2024 15:33:30 +0200 Subject: [PATCH 10/25] Shelley.Migrations --- .../Scenario/API/Shelley/Migrations.hs | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs index 0a5ca01f3ae..35bf6e93a6d 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs @@ -36,6 +36,10 @@ import Cardano.Wallet.Api.Types import Cardano.Wallet.Api.Types.Amount ( ApiAmount (ApiAmount) ) +import Cardano.Wallet.Api.Types.Error + ( ApiErrorInfo (..) + , ApiErrorNoSuchWallet (..) + ) import Cardano.Wallet.Faucet ( Faucet (..) ) @@ -97,6 +101,7 @@ import Test.Integration.Framework.DSL ( Context (..) , Headers (..) , Payload (..) + , decodeErrorInfo , emptyIcarusWallet , emptyRandomWallet , emptyWallet @@ -122,14 +127,12 @@ import Test.Integration.Framework.DSL , unsafeResponse , verify , waitForTxImmutability - , walletId , (.>) , (.>=) ) import Test.Integration.Framework.TestData ( errMsg403NothingToMigrate , errMsg403WrongPass - , errMsg404NoWallet ) import Text.Pretty.Simple ( pShowNoColor @@ -147,6 +150,7 @@ import qualified Data.Map.Strict as Map import qualified Data.Text.Lazy as TL import qualified Network.HTTP.Types.Status as HTTP import qualified Test.Hspec as Hspec +import qualified Test.Integration.Framework.DSL as DSL spec :: forall n. HasSNetworkId n => SpecWith Context spec = describe "SHELLEY_MIGRATIONS" $ do @@ -209,7 +213,7 @@ spec = describe "SHELLEY_MIGRATIONS" $ do response [ expectResponseCode HTTP.status403 , expectErrorMessage - (errMsg403NothingToMigrate $ sourceWallet ^. walletId) + (errMsg403NothingToMigrate $ sourceWallet ^. DSL.walletId) ] describe @@ -241,12 +245,11 @@ spec = describe "SHELLEY_MIGRATIONS" $ do ep Default (Json [json|{addresses: #{targetAddressIds}}|]) - verify - result + verify result [ expectResponseCode HTTP.status404 - , expectErrorMessage - (errMsg404NoWallet $ sourceWallet ^. walletId) ] + decodeErrorInfo result `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ sourceWallet ^. DSL.walletId) Hspec.it "SHELLEY_CREATE_MIGRATION_PLAN_04 - \ @@ -327,7 +330,7 @@ spec = describe "SHELLEY_MIGRATIONS" $ do response [ expectResponseCode HTTP.status403 , expectErrorMessage - (errMsg403NothingToMigrate $ sourceWallet ^. walletId) + (errMsg403NothingToMigrate $ sourceWallet ^. DSL.walletId) ] it @@ -931,7 +934,7 @@ spec = describe "SHELLEY_MIGRATIONS" $ do \Migrating an empty wallet should fail." $ \ctx -> runResourceT $ do sourceWallet <- emptyWallet ctx - let sourceWalletId = sourceWallet ^. walletId + let sourceWalletId = sourceWallet ^. DSL.walletId targetWallet <- emptyWallet ctx targetAddresses <- listAddresses @n ctx targetWallet let targetAddressIds = @@ -1077,7 +1080,7 @@ spec = describe "SHELLEY_MIGRATIONS" $ do response [ expectResponseCode HTTP.status403 , expectErrorMessage - (errMsg403NothingToMigrate (sourceWallet ^. walletId)) + (errMsg403NothingToMigrate (sourceWallet ^. DSL.walletId)) ] it From d7a72a4383b10e9aa8439151ac8c9ca84ca2154f Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Fri, 17 May 2024 15:46:27 +0200 Subject: [PATCH 11/25] refactor Shelley.Transaction --- .../Scenario/API/Shelley/Transactions.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Transactions.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Transactions.hs index 1f42b6f85bb..7ad59e74df7 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Transactions.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Transactions.hs @@ -54,6 +54,7 @@ import Cardano.Wallet.Api.Types.Amount ) import Cardano.Wallet.Api.Types.Error ( ApiErrorInfo (..) + , ApiErrorNoSuchWallet (ApiErrorNoSuchWallet) , ApiErrorTxOutputLovelaceInsufficient (ApiErrorTxOutputLovelaceInsufficient) ) import Cardano.Wallet.Api.Types.SchemaMetadata @@ -221,7 +222,6 @@ import Test.Integration.Framework.TestData , errMsg403WrongPass , errMsg404CannotFindTx , errMsg404NoAsset - , errMsg404NoWallet , steveToken , txMetadata_ADP_1005 ) @@ -846,7 +846,8 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do Default payload expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet $ w ^. walletId) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) describe "TRANS_CREATE_08 - Bad payload" $ do let matrix = @@ -1708,7 +1709,8 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do Default payload expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet $ w ^. walletId) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) it "TRANS_LIST_01 - Can list Incoming and Outgoing transactions" $ \ctx -> runResourceT $ do @@ -2200,7 +2202,8 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do Default Empty expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet $ w ^. walletId) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) it "TRANS_LIST_RANGE_01 - \ @@ -2378,7 +2381,9 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do let link = Link.getTransaction @'Shelley w (ApiTxId txid) r <- request @(ApiTransaction n) ctx link Default Empty expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet $ w ^. walletId) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + it "TRANS_GET_03 - Using wrong transaction id" $ \ctx -> runResourceT $ do (wSrc, wDest) <- (,) <$> fixtureWallet ctx <*> emptyWallet ctx From b5bd8852c2173f0b39759c58442750bfc1a21c4e Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Fri, 17 May 2024 15:56:49 +0200 Subject: [PATCH 12/25] sort out DSL and ApiError naming overlap --- .../Integration/Scenario/API/Byron/Migrations.hs | 16 ++++++++-------- .../Scenario/API/Shared/Transactions.hs | 8 ++++---- .../Integration/Scenario/API/Shared/Wallets.hs | 16 ++++++++-------- .../Scenario/API/Shelley/Addresses.hs | 8 ++++---- .../Scenario/API/Shelley/CoinSelections.hs | 6 +++--- .../Scenario/API/Shelley/Migrations.hs | 14 +++++++------- .../Scenario/API/Shelley/StakePools.hs | 6 +++--- .../Scenario/API/Shelley/TransactionsNew.hs | 6 +++--- 8 files changed, 40 insertions(+), 40 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs index 783723beabd..ecf61d416be 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs @@ -36,7 +36,7 @@ import Cardano.Wallet.Api.Types.Amount ) import Cardano.Wallet.Api.Types.Error ( ApiErrorInfo (..) - , ApiErrorNoSuchWallet (..) + , ApiErrorNoSuchWallet (ApiErrorNoSuchWallet) ) import Cardano.Wallet.Primitive.NetworkId ( HasSNetworkId (..) @@ -106,6 +106,7 @@ import Test.Integration.Framework.DSL , unsafeResponse , verify , waitForTxImmutability + , walletId , (.>) ) import Test.Integration.Framework.TestData @@ -119,7 +120,6 @@ import qualified Cardano.Wallet.Api.Types as ApiTypes import qualified Data.Map.Strict as Map import qualified Network.HTTP.Types.Status as HTTP import qualified Test.Hspec.Expectations.Lifted as Lifted -import qualified Test.Integration.Framework.DSL as DSL spec :: forall n. HasSNetworkId n => SpecWith Context spec = describe "BYRON_MIGRATIONS" $ do @@ -168,7 +168,7 @@ spec = describe "BYRON_MIGRATIONS" $ do verify response [ expectResponseCode HTTP.status403 , expectErrorMessage - (errMsg403NothingToMigrate $ sourceWallet ^. DSL.walletId) + (errMsg403NothingToMigrate $ sourceWallet ^. walletId) ] it "BYRON_CREATE_MIGRATION_PLAN_02r \ @@ -194,7 +194,7 @@ spec = describe "BYRON_MIGRATIONS" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo response `Lifted.shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ sourceWallet ^. DSL.walletId) + (NoSuchWallet $ ApiErrorNoSuchWallet $ sourceWallet ^. walletId) it "BYRON_CREATE_MIGRATION_PLAN_04 - \ \Cannot create a plan for a wallet that only contains dust." @@ -232,7 +232,7 @@ spec = describe "BYRON_MIGRATIONS" $ do verify response [ expectResponseCode HTTP.status403 , expectErrorMessage - (errMsg403NothingToMigrate $ sourceWallet ^. DSL.walletId) + (errMsg403NothingToMigrate $ sourceWallet ^. walletId) ] let byronCreateMigrationPlan05 fixtureByronWallet ctx = runResourceT $ do @@ -400,7 +400,7 @@ spec = describe "BYRON_MIGRATIONS" $ do $ \ctx -> forM_ [emptyRandomWallet, emptyIcarusWallet] $ \emptyByronWallet -> runResourceT $ do sourceWallet <- emptyByronWallet ctx - let sourceWalletId = sourceWallet ^. DSL.walletId + let sourceWalletId = sourceWallet ^. walletId targetWallet <- emptyWallet ctx targetAddresses <- listAddresses @n ctx targetWallet let targetAddressIds = targetAddresses <&> @@ -533,7 +533,7 @@ spec = describe "BYRON_MIGRATIONS" $ do verify response [ expectResponseCode HTTP.status403 , expectErrorMessage - (errMsg403NothingToMigrate (sourceWallet ^. DSL.walletId)) + (errMsg403NothingToMigrate (sourceWallet ^. walletId)) ] it "BYRON_MIGRATE_07 - \ @@ -576,7 +576,7 @@ spec = describe "BYRON_MIGRATIONS" $ do [ expectField (#balance . #available) (`shouldBe` ApiAmount 15) ] - let sourceWalletId = sourceWallet ^. DSL.walletId + let sourceWalletId = sourceWallet ^. walletId -- Analyse the source wallet's UTxO distribution: let expectedSourceDistribution = [(10, 5)] diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Transactions.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Transactions.hs index 18db51d84d1..5507ef7a85b 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Transactions.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Transactions.hs @@ -64,7 +64,7 @@ import Cardano.Wallet.Api.Types.Amount import Cardano.Wallet.Api.Types.Error ( ApiErrorInfo (..) , ApiErrorMissingWitnessesInTransaction (..) - , ApiErrorNoSuchWallet (..) + , ApiErrorNoSuchWallet (ApiErrorNoSuchWallet) , ApiErrorTxOutputLovelaceInsufficient (ApiErrorTxOutputLovelaceInsufficient) ) import Cardano.Wallet.Api.Types.Transaction @@ -206,6 +206,7 @@ import Test.Integration.Framework.DSL , verify , waitForNextEpoch , waitNumberOfEpochBoundaries + , walletId , (.>) ) import Test.Integration.Framework.Request @@ -229,7 +230,6 @@ import qualified Data.Set as Set import qualified Data.Text as T import qualified Data.Text.Encoding as T import qualified Network.HTTP.Types as HTTP -import qualified Test.Integration.Framework.DSL as DSL data TestCase a = TestCase { query :: T.Text @@ -1608,7 +1608,7 @@ spec = describe "SHARED_TRANSACTIONS" $ do Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. DSL.walletId) + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) it "SHARED_TRANSACTIONS_LIST_RANGE_01 - \ \Transaction at time t is SELECTED by small ranges that cover it" $ @@ -1741,7 +1741,7 @@ spec = describe "SHARED_TRANSACTIONS" $ do r <- request @(ApiTransaction n) ctx link Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. DSL.walletId) + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) it "SHARED_TRANSACTIONS_GET_03 - \ \Using wrong transaction id" $ diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Wallets.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Wallets.hs index 31a13028bb8..7e69267623e 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Wallets.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Wallets.hs @@ -63,8 +63,8 @@ import Cardano.Wallet.Api.Types.Amount ) import Cardano.Wallet.Api.Types.Error ( ApiErrorInfo (..) + , ApiErrorNoSuchWallet (ApiErrorNoSuchWallet) , ApiErrorSharedWalletNoSuchCosigner (..) - , ApiErrorNoSuchWallet (..) ) import Cardano.Wallet.Compat ( (^?) @@ -165,6 +165,7 @@ import Test.Integration.Framework.DSL , submitSharedTxWithWid , unsafeRequest , verify + , walletId , () ) import Test.Integration.Framework.TestData @@ -187,7 +188,6 @@ import qualified Data.Set as Set import qualified Data.Text as T import qualified Data.Text.Encoding as T import qualified Network.HTTP.Types as HTTP -import qualified Test.Integration.Framework.DSL as DSL spec :: forall n @@ -1036,7 +1036,7 @@ spec = describe "SHARED_WALLETS" $ do let putData = Json [json| { "one_change_address_mode": false } |] - let walIdOneChangeAddr = walOneAddr ^. DSL.walletId + let walIdOneChangeAddr = walOneAddr ^. walletId rPut <- request @ApiWallet ctx ("PUT", "v2/shared-wallets" walIdOneChangeAddr) Default putData verify rPut @@ -1044,7 +1044,7 @@ spec = describe "SHARED_WALLETS" $ do , expectField (#addressPoolGap . #getApiT . #getAddressPoolGap) (`shouldBe` 20) - , expectField DSL.walletId (`shouldBe` walIdOneChangeAddr) + , expectField walletId (`shouldBe` walIdOneChangeAddr) ] forM_ [1,1] $ \num -> realizeTx walOneAddr wFixture (num * minUTxOValue') destFixture @@ -1500,7 +1500,7 @@ spec = describe "SHARED_WALLETS" $ do let wal = getFromResponse Prelude.id rPost rl <- listFilteredSharedWallets - (Set.singleton (getWalletIdFromSharedWallet wal ^. DSL.walletId) ) ctx + (Set.singleton (getWalletIdFromSharedWallet wal ^. walletId) ) ctx verify (fmap (fmap (view #wallet)) <$> rl) [ expectResponseCode HTTP.status200 , expectListSize 1 @@ -1540,7 +1540,7 @@ spec = describe "SHARED_WALLETS" $ do [ expectResponseCode HTTP.status201 ] let wal = getFromResponse Prelude.id rPost - pure (getWalletIdFromSharedWallet wal ^. DSL.walletId) + pure (getWalletIdFromSharedWallet wal ^. walletId) let name = (^? (#wallet . traverse . #name . #getApiT . #getWalletName)) rl <- listFilteredSharedWallets (Set.fromList wids) ctx verify (fmap (map name) <$> rl) @@ -1567,7 +1567,7 @@ spec = describe "SHARED_WALLETS" $ do expectResponseCode HTTP.status204 rDel rl <- listFilteredSharedWallets - (Set.singleton $ getWalletIdFromSharedWallet wal ^. DSL.walletId) ctx + (Set.singleton $ getWalletIdFromSharedWallet wal ^. walletId) ctx verify rl [ expectResponseCode HTTP.status200 , expectListSize 0 @@ -1704,7 +1704,7 @@ spec = describe "SHARED_WALLETS" $ do Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. DSL.walletId) + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) describe "SHARED_WALLETS_UTXO_04 - HTTP headers" $ do let matrix = diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Addresses.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Addresses.hs index a84b4a1aa92..a24f617296a 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Addresses.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Addresses.hs @@ -40,7 +40,7 @@ import Cardano.Wallet.Api.Types.Amount ) import Cardano.Wallet.Api.Types.Error ( ApiErrorInfo (..) - , ApiErrorNoSuchWallet (..) + , ApiErrorNoSuchWallet (ApiErrorNoSuchWallet) ) import Cardano.Wallet.Primitive.NetworkId ( HasSNetworkId @@ -109,6 +109,7 @@ import Test.Integration.Framework.DSL , request , unsafeRequest , verify + , walletId ) import Test.Integration.Framework.TestData ( errMsg400ScriptDuplicateKeys @@ -125,7 +126,6 @@ import qualified Data.Aeson.KeyMap as KeyMap import qualified Data.Aeson.Lens as Aeson import qualified Data.Text as T import qualified Network.HTTP.Types.Status as HTTP -import qualified Test.Integration.Framework.DSL as DSL spec :: forall n @@ -134,7 +134,7 @@ spec spec = describe "SHELLEY_ADDRESSES" $ do it "BYRON_ADDRESS_LIST - Byron wallet on Shelley ep" $ \ctx -> runResourceT $ do w <- emptyRandomWallet ctx - let wid = w ^. DSL.walletId + let wid = w ^. walletId let ep = ("GET", "v2/wallets/" <> wid <> "/addresses") r <- request @[ApiAddressWithPath n] ctx ep Default Empty expectResponseCode HTTP.status404 r @@ -293,7 +293,7 @@ spec = describe "SHELLEY_ADDRESSES" $ do (Link.listAddresses @'Shelley w) Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. DSL.walletId) + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) it "ADDRESS_LIST_05 - bech32 HRP is correct - testnet" $ \ctx -> runResourceT $ do w <- emptyWallet ctx diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/CoinSelections.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/CoinSelections.hs index bb8efb6307b..996b2071622 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/CoinSelections.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/CoinSelections.hs @@ -41,7 +41,7 @@ import Cardano.Wallet.Api.Types.Amount ) import Cardano.Wallet.Api.Types.Error ( ApiErrorInfo (..) - , ApiErrorNoSuchWallet (..) + , ApiErrorNoSuchWallet (ApiErrorNoSuchWallet) ) import Cardano.Wallet.Primitive.NetworkId ( HasSNetworkId @@ -112,6 +112,7 @@ import Test.Integration.Framework.DSL , selectCoinsWith , verify , verifyMsg + , walletId ) import Test.Integration.Framework.TestData ( errMsg400TxMetadataStringTooLong @@ -130,7 +131,6 @@ import qualified Data.List.NonEmpty as NE import qualified Data.Text as T import qualified Data.Text.Encoding as T import qualified Network.HTTP.Types as HTTP -import qualified Test.Integration.Framework.DSL as DSL import qualified Test.Hspec.Expectations.Lifted as Lifted spec @@ -230,7 +230,7 @@ spec = describe "SHELLEY_COIN_SELECTION" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo rTx `Lifted.shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. DSL.walletId) + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) it "WALLETS_COIN_SELECTION_03 - \ diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs index 35bf6e93a6d..ffabc7514c7 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs @@ -38,7 +38,7 @@ import Cardano.Wallet.Api.Types.Amount ) import Cardano.Wallet.Api.Types.Error ( ApiErrorInfo (..) - , ApiErrorNoSuchWallet (..) + , ApiErrorNoSuchWallet (ApiErrorNoSuchWallet) ) import Cardano.Wallet.Faucet ( Faucet (..) @@ -127,6 +127,7 @@ import Test.Integration.Framework.DSL , unsafeResponse , verify , waitForTxImmutability + , walletId , (.>) , (.>=) ) @@ -150,7 +151,6 @@ import qualified Data.Map.Strict as Map import qualified Data.Text.Lazy as TL import qualified Network.HTTP.Types.Status as HTTP import qualified Test.Hspec as Hspec -import qualified Test.Integration.Framework.DSL as DSL spec :: forall n. HasSNetworkId n => SpecWith Context spec = describe "SHELLEY_MIGRATIONS" $ do @@ -213,7 +213,7 @@ spec = describe "SHELLEY_MIGRATIONS" $ do response [ expectResponseCode HTTP.status403 , expectErrorMessage - (errMsg403NothingToMigrate $ sourceWallet ^. DSL.walletId) + (errMsg403NothingToMigrate $ sourceWallet ^. walletId) ] describe @@ -249,7 +249,7 @@ spec = describe "SHELLEY_MIGRATIONS" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo result `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ sourceWallet ^. DSL.walletId) + (NoSuchWallet $ ApiErrorNoSuchWallet $ sourceWallet ^. walletId) Hspec.it "SHELLEY_CREATE_MIGRATION_PLAN_04 - \ @@ -330,7 +330,7 @@ spec = describe "SHELLEY_MIGRATIONS" $ do response [ expectResponseCode HTTP.status403 , expectErrorMessage - (errMsg403NothingToMigrate $ sourceWallet ^. DSL.walletId) + (errMsg403NothingToMigrate $ sourceWallet ^. walletId) ] it @@ -934,7 +934,7 @@ spec = describe "SHELLEY_MIGRATIONS" $ do \Migrating an empty wallet should fail." $ \ctx -> runResourceT $ do sourceWallet <- emptyWallet ctx - let sourceWalletId = sourceWallet ^. DSL.walletId + let sourceWalletId = sourceWallet ^. walletId targetWallet <- emptyWallet ctx targetAddresses <- listAddresses @n ctx targetWallet let targetAddressIds = @@ -1080,7 +1080,7 @@ spec = describe "SHELLEY_MIGRATIONS" $ do response [ expectResponseCode HTTP.status403 , expectErrorMessage - (errMsg403NothingToMigrate (sourceWallet ^. DSL.walletId)) + (errMsg403NothingToMigrate (sourceWallet ^. walletId)) ] it diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/StakePools.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/StakePools.hs index e7a6bdc2d31..dfb63364e82 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/StakePools.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/StakePools.hs @@ -55,7 +55,7 @@ import Cardano.Wallet.Api.Types.Amount import Cardano.Wallet.Api.Types.Error ( ApiErrorInfo (..) , ApiErrorNoSuchPool (..) - , ApiErrorNoSuchWallet (..) + , ApiErrorNoSuchWallet (ApiErrorNoSuchWallet) ) import Cardano.Wallet.Faucet ( Faucet (..) @@ -213,6 +213,7 @@ import Test.Integration.Framework.DSL , waitForTxImmutability , waitForTxStatus , waitNumberOfEpochBoundaries + , walletId , (.<) , (.>) , (.>=) @@ -228,7 +229,6 @@ import qualified Data.Set as Set import qualified Data.Text as T import qualified Network.HTTP.Types.Status as HTTP import qualified Prelude -import qualified Test.Integration.Framework.DSL as DSL spec :: forall n. HasSNetworkId n => SpecWith Context spec = describe "SHELLEY_STAKE_POOLS" $ do @@ -262,7 +262,7 @@ spec = describe "SHELLEY_STAKE_POOLS" $ do it "STAKE_POOLS_JOIN_01 - Cannot join non-existent wallet" $ \ctx -> runResourceT $ do w <- emptyWallet ctx - let wid = w ^. DSL.walletId + let wid = w ^. walletId _ <- request @ApiWallet ctx diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs index 71cde9dbaae..8f60b7bd020 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs @@ -114,7 +114,7 @@ import Cardano.Wallet.Api.Types.Error ( ApiErrorInfo (..) , ApiErrorMissingWitnessesInTransaction (..) , ApiErrorNoSuchPool (..) - , ApiErrorNoSuchWallet (..) + , ApiErrorNoSuchWallet (ApiErrorNoSuchWallet) , ApiErrorTxOutputLovelaceInsufficient (ApiErrorTxOutputLovelaceInsufficient) ) import Cardano.Wallet.Api.Types.Transaction @@ -326,6 +326,7 @@ import Test.Integration.Framework.DSL , waitForNextEpoch , waitForTxImmutability , waitNumberOfEpochBoundaries + , walletId , (.<) , (.>) ) @@ -350,7 +351,6 @@ import qualified Data.Set as Set import qualified Data.Text as T import qualified Data.Text.Encoding as T import qualified Network.HTTP.Types.Status as HTTP -import qualified Test.Integration.Framework.DSL as DSL import qualified Test.Integration.Plutus as PlutusScenario spec :: forall n. HasSNetworkId n => SpecWith Context @@ -2777,7 +2777,7 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do forM_ scenarios $ \(title, foreignByronWallet) -> it title $ \ctx -> runResourceT $ do wa <- fixtureWallet ctx wb <- foreignByronWallet ctx - let wid = wb ^. DSL.walletId + let wid = wb ^. walletId -- Construct tx payload <- mkTxPayload ctx wa (minUTxOValue (_mainEra ctx)) 1 From fca2c6489ab2ac307c716aa5cea55d6c2d99cfea Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Fri, 17 May 2024 16:11:58 +0200 Subject: [PATCH 13/25] Shelley.Wallets --- .../Scenario/API/Shelley/Wallets.hs | 48 +++++++++++++------ 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs index 9c68a179aa0..629a3948dd1 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs @@ -49,6 +49,10 @@ import Cardano.Wallet.Api.Types import Cardano.Wallet.Api.Types.Amount ( ApiAmount (ApiAmount) ) +import Cardano.Wallet.Api.Types.Error + ( ApiErrorInfo (..) + , ApiErrorNoSuchWallet (ApiErrorNoSuchWallet) + ) import Cardano.Wallet.Network.RestorationMode ( RestorationMode (..) ) @@ -135,6 +139,7 @@ import Test.Integration.Framework.DSL , Headers (..) , Payload (..) , counterexample + , decodeErrorInfo , emptyByronWalletWith , emptyRandomWallet , emptyWallet @@ -173,7 +178,6 @@ import Test.Integration.Framework.TestData ( arabicWalletName , errMsg403WrongMnemonic , errMsg403WrongPass - , errMsg404NoWallet , errMsg406 , errMsg415 , kanjiWalletName @@ -734,7 +738,8 @@ spec = describe "SHELLEY_WALLETS" $ do rg <- request @ApiWallet ctx (Link.getWallet @'Shelley w) Default Empty expectResponseCode HTTP.status404 rg - expectErrorMessage (errMsg404NoWallet $ w ^. walletId) rg + decodeErrorInfo rg `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) it "WALLETS_LIST_01 - Created a wallet can be listed" $ \ctx -> runResourceT $ do m18 <- Mnemonics.generateSome Mnemonics.M18 @@ -894,7 +899,8 @@ spec = describe "SHELLEY_WALLETS" $ do let newName = updateNamePayload "new name" ru <- request @ApiWallet ctx ("PUT", endpoint) Default newName expectResponseCode HTTP.status404 ru - expectErrorMessage (errMsg404NoWallet wid) ru + decodeErrorInfo ru `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet wid) describe "WALLETS_UPDATE_04 - HTTP headers" $ do let matrix = @@ -1078,7 +1084,8 @@ spec = describe "SHELLEY_WALLETS" $ do let updEndp = delEndp ("passphrase" :: Text) rup <- request @ApiWallet ctx ("PUT", updEndp) Default payload expectResponseCode HTTP.status404 rup - expectErrorMessage (errMsg404NoWallet walId) rup + decodeErrorInfo rup `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet walId) it "WALLETS_UPDATE_PASS_04 - Deleted wallet is not available, mnemonic" $ \ctx -> runResourceT $ do @@ -1090,7 +1097,8 @@ spec = describe "SHELLEY_WALLETS" $ do let updEndp = delEndp ("passphrase" :: Text) rup <- request @ApiWallet ctx ("PUT", updEndp) Default payload expectResponseCode HTTP.status404 rup - expectErrorMessage (errMsg404NoWallet walId) rup + decodeErrorInfo rup `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet walId) describe "WALLETS_UPDATE_PASS_05,06 - Transaction after updating passphrase" $ do @@ -1279,7 +1287,8 @@ spec = describe "SHELLEY_WALLETS" $ do r <- request @ApiUtxoStatistics ctx (Link.getUTxOsStatistics @'Shelley w) Default Empty expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet $ w ^. walletId) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) describe "WALLETS_UTXO_04 - HTTP headers" $ do let matrix = @@ -1378,8 +1387,9 @@ spec = describe "SHELLEY_WALLETS" $ do verify r [ expectResponseCode HTTP.status404 - , expectErrorMessage (errMsg404NoWallet $ w ^. walletId) ] + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) it "WALLETS_SIGNATURES_01 - can verify signature" $ \ctx -> runResourceT $ do let mnemonic = unsafeMnemonic @15 @@ -1481,8 +1491,9 @@ spec = describe "SHELLEY_WALLETS" $ do verify r [ expectResponseCode HTTP.status404 - , expectErrorMessage (errMsg404NoWallet $ w ^. walletId) ] + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) it "BYRON_WALLETS_UTXO -\ \ Cannot show Byron wal utxo with shelley ep (404)" $ \ctx -> runResourceT $ do @@ -1494,7 +1505,8 @@ spec = describe "SHELLEY_WALLETS" $ do ("statistics/utxos" :: Text) r <- request @ApiUtxoStatistics ctx ("GET", endpoint) Default Empty expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet wid) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet wid) it "BYRON_WALLETS_UPDATE_PASS -\ \ Cannot update Byron wal with shelley ep (404)" $ \ctx -> runResourceT $ do @@ -1507,7 +1519,8 @@ spec = describe "SHELLEY_WALLETS" $ do ("passphrase" :: Text) rup <- request @ApiWallet ctx ("PUT", endpoint) Default payload expectResponseCode HTTP.status404 rup - expectErrorMessage (errMsg404NoWallet wid) rup + decodeErrorInfo rup `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet wid) it "BYRON_WALLETS_UPDATE -\ \ Cannot update Byron wal with shelley ep (404)" $ \ctx -> runResourceT $ do @@ -1517,21 +1530,24 @@ spec = describe "SHELLEY_WALLETS" $ do let newName = updateNamePayload "new name" ru <- request @ApiWallet ctx ("PUT", endpoint) Default newName expectResponseCode HTTP.status404 ru - expectErrorMessage (errMsg404NoWallet wid) ru + decodeErrorInfo ru `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet wid) it "BYRON_WALLETS_GET_02 - Byron ep does not show Shelley wallet" $ \ctx -> runResourceT $ do w <- emptyWallet ctx r <- request @ApiByronWallet ctx (Link.getWallet @'Byron w) Default Empty expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet $ w ^. walletId) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) it "BYRON_WALLETS_GET_03 - Shelley ep does not show Byron wallet" $ \ctx -> runResourceT $ do w <- emptyRandomWallet ctx r <- request @ApiWallet ctx (Link.getWallet @'Shelley w) Default Empty expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet $ w ^. walletId) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) it "BYRON_WALLETS_LIST_02,03 - \ \Byron wallets listed only via Byron endpoints + \ @@ -1622,13 +1638,15 @@ spec = describe "SHELLEY_WALLETS" $ do w <- emptyWallet ctx r <- request @ApiByronWallet ctx (Link.deleteWallet @'Byron w) Default Empty expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet $ w ^. walletId) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) it "BYRON_WALLETS_DELETE_03 - Shelley ep does not delete Byron wallet" $ \ctx -> runResourceT $ do w <- emptyRandomWallet ctx r <- request @ApiByronWallet ctx (Link.deleteWallet @'Shelley w) Default Empty expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet $ w ^. walletId) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) it "WALLETS_NETWORK_SHELLEY - Wallet has the same tip as network/information" $ \ctx -> runResourceT $ do let getNetworkInfo = request @ApiNetworkInformation ctx From 607903efe6bc532ecdfcebe4f24112e422d8f83e Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Fri, 17 May 2024 16:22:45 +0200 Subject: [PATCH 14/25] Byron.Transactions --- .../Scenario/API/Byron/Transactions.hs | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Transactions.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Transactions.hs index a08f9291600..3c7ae5a57ca 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Transactions.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Transactions.hs @@ -33,7 +33,8 @@ import Cardano.Wallet.Api.Types.Amount ( ApiAmount (ApiAmount) ) import Cardano.Wallet.Api.Types.Error - ( ApiErrorInfo (UtxoTooSmall) + ( ApiErrorInfo (..) + , ApiErrorNoSuchWallet (ApiErrorNoSuchWallet) , ApiErrorTxOutputLovelaceInsufficient (ApiErrorTxOutputLovelaceInsufficient) ) import Cardano.Wallet.Api.Types.Transaction @@ -93,6 +94,7 @@ import Test.Integration.Framework.DSL , Headers (..) , Payload (..) , between + , decodeErrorInfo , emptyIcarusWallet , emptyRandomWallet , emptyWallet @@ -132,7 +134,6 @@ import Test.Integration.Framework.Request import Test.Integration.Framework.TestData ( errMsg400StartTimeLaterThanEndTime , errMsg404NoAsset - , errMsg404NoWallet , steveToken ) @@ -555,7 +556,8 @@ spec = describe "BYRON_TRANSACTIONS" $ do let endpoint = "v2/wallets/" <> wid <> "/transactions" r <- request @(ApiTransaction n) ctx ("POST", endpoint) Default payload expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet wid) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet wid) it "BYRON_TRANS_DELETE -\ \ Cannot delete tx on Byron wallet using shelley ep" $ \ctx -> runResourceT $ do @@ -565,7 +567,8 @@ spec = describe "BYRON_TRANSACTIONS" $ do let endpoint = "v2/wallets/" <> wid <> "/transactions/" <> txid r <- request @ApiTxId ctx ("DELETE", endpoint) Default Empty expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet wid) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet wid) it "BYRON_TRANS_ESTIMATE -\ \ Cannot estimate tx on Byron wallet using shelley ep" $ \ctx -> runResourceT $ do @@ -586,7 +589,8 @@ spec = describe "BYRON_TRANSACTIONS" $ do let endpoint = "v2/wallets/" <> wid <> "/payment-fees" r <- request @ApiFee ctx ("POST", endpoint) Default payload expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet wid) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet wid) it "BYRON_TX_LIST_02 -\ \ Byron endpoint does not list Shelley wallet transactions" $ \ctx -> runResourceT $ do @@ -596,8 +600,9 @@ spec = describe "BYRON_TRANSACTIONS" $ do r <- request @([ApiTransaction n]) ctx ep Default Empty verify r [ expectResponseCode HTTP.status404 - , expectErrorMessage (errMsg404NoWallet wid) ] + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet wid) it "BYRON_TX_LIST_03 -\ \ Shelley endpoint does not list Byron wallet transactions" $ \ctx -> runResourceT $ do @@ -607,8 +612,9 @@ spec = describe "BYRON_TRANSACTIONS" $ do r <- request @([ApiTransaction n]) ctx ep Default Empty verify r [ expectResponseCode HTTP.status404 - , expectErrorMessage (errMsg404NoWallet wid) ] + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet wid) it "BYRON_RESTORE_09 - Ledger wallet" $ \ctx -> runResourceT $ do -- NOTE @@ -778,7 +784,8 @@ spec = describe "BYRON_TRANSACTIONS" $ do let link = Link.listTransactions @'Byron w r <- request @([ApiTransaction n]) ctx link Default Empty expectResponseCode HTTP.status404 r - expectErrorMessage (errMsg404NoWallet $ w ^. walletId) r + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) describe "BYRON_TX_LIST_ADDRESS - Transactions can be filtered by address" $ forM_ [ (fixtureRandomWallet, emptyRandomWallet, "Byron wallet") From 4196e24cc51dcce10c1ffac7b3c6f29575782a40 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Fri, 17 May 2024 16:28:12 +0200 Subject: [PATCH 15/25] Byron.Wallets --- .../Test/Integration/Scenario/API/Byron/Wallets.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Wallets.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Wallets.hs index 31fb75d6ff4..9a893e0e5c9 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Wallets.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Wallets.hs @@ -28,6 +28,10 @@ import Cardano.Wallet.Api.Types import Cardano.Wallet.Api.Types.Amount ( ApiAmount (ApiAmount) ) +import Cardano.Wallet.Api.Types.Error + ( ApiErrorInfo (..) + , ApiErrorNoSuchWallet (ApiErrorNoSuchWallet) + ) import Cardano.Wallet.Primitive.NetworkId ( HasSNetworkId ) @@ -75,6 +79,7 @@ import Test.Integration.Framework.DSL ( Context (..) , Headers (..) , Payload (..) + , decodeErrorInfo , emptyByronWalletFromXPrvWith , emptyByronWalletWith , emptyIcarusWallet @@ -106,7 +111,6 @@ import Test.Integration.Framework.TestData ( arabicWalletName , errMsg400NumberOfWords , errMsg403WrongPass - , errMsg404NoWallet , kanjiWalletName , polishWalletName , russianWalletName @@ -129,7 +133,8 @@ spec = describe "BYRON_WALLETS" $ do _ <- request @ApiByronWallet ctx (Link.deleteWallet @'Byron w) Default Empty rg <- request @ApiByronWallet ctx (Link.getWallet @'Byron w) Default Empty expectResponseCode HTTP.status404 rg - expectErrorMessage (errMsg404NoWallet $ w ^. walletId) rg + decodeErrorInfo rg `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) it "BYRON_LIST_01 - Byron Wallets are listed from oldest to newest" $ \ctx -> runResourceT $ do From 1b40fa357b8cb423a605c21f222e13e1a08c52a7 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Fri, 17 May 2024 16:34:31 +0200 Subject: [PATCH 16/25] Byron.Addresses --- .../Test/Integration/Scenario/API/Byron/Addresses.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Addresses.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Addresses.hs index 3106b4e66d0..619ea9e4aa1 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Addresses.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Addresses.hs @@ -34,6 +34,10 @@ import Cardano.Wallet.Api.Types , ApiT (..) , WalletStyle (..) ) +import Cardano.Wallet.Api.Types.Error + ( ApiErrorInfo (..) + , ApiErrorNoSuchWallet (ApiErrorNoSuchWallet) + ) import Cardano.Wallet.Primitive.NetworkId ( HasSNetworkId (..) ) @@ -63,6 +67,7 @@ import Test.Integration.Framework.DSL ( Context , Headers (..) , Payload (..) + , decodeErrorInfo , emptyIcarusWallet , emptyIcarusWalletMws , emptyRandomWallet @@ -90,7 +95,6 @@ import Test.Integration.Framework.TestData ( errMsg403CouldntIdentifyAddrAsMine , errMsg403NotAByronWallet , errMsg403WrongPass - , errMsg404NoWallet ) import Web.HttpApiData ( ToHttpApiData (..) @@ -98,6 +102,7 @@ import Web.HttpApiData import qualified Cardano.Wallet.Api.Link as Link import qualified Network.HTTP.Types.Status as HTTP +import qualified Test.Hspec.Expectations.Lifted as Lifted spec :: forall n @@ -190,8 +195,9 @@ scenario_ADDRESS_LIST_04 fixture = it title $ \ctx -> runResourceT $ do r <- request @[ApiAddressWithPath n] ctx (Link.listAddresses @'Byron w) Default Empty verify r [ expectResponseCode HTTP.status404 - , expectErrorMessage $ errMsg404NoWallet $ w ^. walletId ] + decodeErrorInfo r `Lifted.shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) where title = "ADDRESS_LIST_04 - Delete wallet" From 60f1249f8c8ef1bc3168582b75c6635aa90db581 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Fri, 17 May 2024 16:40:51 +0200 Subject: [PATCH 17/25] Byron.CoinSelections --- .../Integration/Scenario/API/Byron/CoinSelections.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/CoinSelections.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/CoinSelections.hs index 7dc3e6f1c33..204ea902f71 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/CoinSelections.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/CoinSelections.hs @@ -25,6 +25,10 @@ import Cardano.Wallet.Api.Types import Cardano.Wallet.Api.Types.Amount ( ApiAmount (ApiAmount) ) +import Cardano.Wallet.Api.Types.Error + ( ApiErrorInfo (..) + , ApiErrorNoSuchWallet (ApiErrorNoSuchWallet) + ) import Cardano.Wallet.Primitive.NetworkId ( HasSNetworkId ) @@ -50,6 +54,7 @@ import Test.Integration.Framework.DSL ( Context (..) , Headers (..) , Payload (..) + , decodeErrorInfo , emptyIcarusWallet , emptyRandomWallet , emptyWallet @@ -68,7 +73,6 @@ import Test.Integration.Framework.DSL ) import Test.Integration.Framework.TestData ( errMsg403NotAnIcarusWallet - , errMsg404NoWallet ) import qualified Cardano.Wallet.Api.Link as Link @@ -150,7 +154,9 @@ spec = describe "BYRON_COIN_SELECTION" $ do let minUTxOValue' = ApiAmount . minUTxOValue $ _mainEra ctx let payments = pure (AddressAmount addr minUTxOValue' mempty) _ <- request @ApiByronWallet ctx (Link.deleteWallet @'Byron icW) Default Empty - selectCoins @_ @'Byron ctx icW payments >>= flip verify + r <- selectCoins @_ @'Byron ctx icW payments + verify r [ expectResponseCode HTTP.status404 - , expectErrorMessage (errMsg404NoWallet $ icW ^. walletId) ] + decodeErrorInfo r `shouldBe` + (NoSuchWallet $ ApiErrorNoSuchWallet $ icW ^. walletId) From 655796261649c915eb3a654758d3dba64fd7f021 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Fri, 17 May 2024 16:43:01 +0200 Subject: [PATCH 18/25] revert CLI changes --- .../Test/Integration/Scenario/CLI/Shelley/Addresses.hs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/CLI/Shelley/Addresses.hs b/lib/integration/scenarios/Test/Integration/Scenario/CLI/Shelley/Addresses.hs index 32a94aa6f93..08fe2cc6741 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/CLI/Shelley/Addresses.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/CLI/Shelley/Addresses.hs @@ -83,7 +83,8 @@ import Test.Integration.Framework.DSL , walletId ) import Test.Integration.Framework.TestData - ( falseWalletIds + ( errMsg404NoWallet + , falseWalletIds ) import Cardano.Wallet.Api.Types.Amount @@ -283,7 +284,3 @@ spec = describe "SHELLEY_CLI_ADDRESSES" $ do fixtureWallet' :: Context -> ResourceT IO String fixtureWallet' = fmap (T.unpack . view walletId) . fixtureWallet - - errMsg404NoWallet :: Text -> String - errMsg404NoWallet wid = - "I couldn't find a wallet with the given id: " ++ T.unpack wid From 64dc4ab53f5b16cf032cf326abbed797f62606c5 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Wed, 22 May 2024 16:32:08 +0200 Subject: [PATCH 19/25] reqquested review changes --- .../Cardano/Wallet/Api/Http/Server/Error.hs | 2 +- lib/api/src/Cardano/Wallet/Api/Types/Error.hs | 2 +- .../Scenario/API/Byron/Addresses.hs | 2 +- .../Scenario/API/Byron/CoinSelections.hs | 2 +- .../Scenario/API/Byron/Migrations.hs | 2 +- .../Scenario/API/Byron/Transactions.hs | 12 ++++---- .../Integration/Scenario/API/Byron/Wallets.hs | 2 +- .../Scenario/API/Shared/Transactions.hs | 4 +-- .../Scenario/API/Shared/Wallets.hs | 2 +- .../Scenario/API/Shelley/Addresses.hs | 4 +-- .../Scenario/API/Shelley/CoinSelections.hs | 2 +- .../Scenario/API/Shelley/Migrations.hs | 2 +- .../Scenario/API/Shelley/StakePools.hs | 2 +- .../Scenario/API/Shelley/Transactions.hs | 9 +++--- .../Scenario/API/Shelley/TransactionsNew.hs | 2 +- .../Scenario/API/Shelley/Wallets.hs | 28 +++++++++---------- specifications/api/swagger.yaml | 16 +++++------ 17 files changed, 47 insertions(+), 48 deletions(-) diff --git a/lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs b/lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs index 597c8b2199e..ead427a540e 100644 --- a/lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs +++ b/lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs @@ -263,7 +263,7 @@ instance IsServerError ErrNoSuchWallet where instance IsServerError ErrWalletNotInitialized where toServerError = \case ErrWalletNotInitialized -> - apiError err404 NoSuchWalletInitialized $ mconcat + apiError err404 WalletNotInitialized $ mconcat [ "The database for the requested wallet is not initialized. " ] diff --git a/lib/api/src/Cardano/Wallet/Api/Types/Error.hs b/lib/api/src/Cardano/Wallet/Api/Types/Error.hs index 97ecf387662..709ab77ad84 100644 --- a/lib/api/src/Cardano/Wallet/Api/Types/Error.hs +++ b/lib/api/src/Cardano/Wallet/Api/Types/Error.hs @@ -165,7 +165,7 @@ data ApiErrorInfo | NoSuchTransaction | NoSuchWallet !ApiErrorNoSuchWallet - | NoSuchWalletInitialized + | WalletNotInitialized | NoUtxosAvailable | NodeNotYetInRecentEra !ApiErrorNodeNotYetInRecentEra diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Addresses.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Addresses.hs index 619ea9e4aa1..6388acc204a 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Addresses.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Addresses.hs @@ -197,7 +197,7 @@ scenario_ADDRESS_LIST_04 fixture = it title $ \ctx -> runResourceT $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo r `Lifted.shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) where title = "ADDRESS_LIST_04 - Delete wallet" diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/CoinSelections.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/CoinSelections.hs index 204ea902f71..d425f75f941 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/CoinSelections.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/CoinSelections.hs @@ -159,4 +159,4 @@ spec = describe "BYRON_COIN_SELECTION" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ icW ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ icW ^. walletId) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs index ecf61d416be..5e1930b41ff 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs @@ -194,7 +194,7 @@ spec = describe "BYRON_MIGRATIONS" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo response `Lifted.shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ sourceWallet ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ sourceWallet ^. walletId) it "BYRON_CREATE_MIGRATION_PLAN_04 - \ \Cannot create a plan for a wallet that only contains dust." diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Transactions.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Transactions.hs index 3c7ae5a57ca..747f8c9209b 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Transactions.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Transactions.hs @@ -557,7 +557,7 @@ spec = describe "BYRON_TRANSACTIONS" $ do r <- request @(ApiTransaction n) ctx ("POST", endpoint) Default payload expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet wid) it "BYRON_TRANS_DELETE -\ \ Cannot delete tx on Byron wallet using shelley ep" $ \ctx -> runResourceT $ do @@ -568,7 +568,7 @@ spec = describe "BYRON_TRANSACTIONS" $ do r <- request @ApiTxId ctx ("DELETE", endpoint) Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet wid) it "BYRON_TRANS_ESTIMATE -\ \ Cannot estimate tx on Byron wallet using shelley ep" $ \ctx -> runResourceT $ do @@ -590,7 +590,7 @@ spec = describe "BYRON_TRANSACTIONS" $ do r <- request @ApiFee ctx ("POST", endpoint) Default payload expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet wid) it "BYRON_TX_LIST_02 -\ \ Byron endpoint does not list Shelley wallet transactions" $ \ctx -> runResourceT $ do @@ -602,7 +602,7 @@ spec = describe "BYRON_TRANSACTIONS" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet wid) it "BYRON_TX_LIST_03 -\ \ Shelley endpoint does not list Byron wallet transactions" $ \ctx -> runResourceT $ do @@ -614,7 +614,7 @@ spec = describe "BYRON_TRANSACTIONS" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet wid) it "BYRON_RESTORE_09 - Ledger wallet" $ \ctx -> runResourceT $ do -- NOTE @@ -785,7 +785,7 @@ spec = describe "BYRON_TRANSACTIONS" $ do r <- request @([ApiTransaction n]) ctx link Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) describe "BYRON_TX_LIST_ADDRESS - Transactions can be filtered by address" $ forM_ [ (fixtureRandomWallet, emptyRandomWallet, "Byron wallet") diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Wallets.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Wallets.hs index 9a893e0e5c9..0055e85a01d 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Wallets.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Wallets.hs @@ -134,7 +134,7 @@ spec = describe "BYRON_WALLETS" $ do rg <- request @ApiByronWallet ctx (Link.getWallet @'Byron w) Default Empty expectResponseCode HTTP.status404 rg decodeErrorInfo rg `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) it "BYRON_LIST_01 - Byron Wallets are listed from oldest to newest" $ \ctx -> runResourceT $ do diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Transactions.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Transactions.hs index 5507ef7a85b..4fd1c1feeea 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Transactions.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Transactions.hs @@ -1608,7 +1608,7 @@ spec = describe "SHARED_TRANSACTIONS" $ do Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) it "SHARED_TRANSACTIONS_LIST_RANGE_01 - \ \Transaction at time t is SELECTED by small ranges that cover it" $ @@ -1741,7 +1741,7 @@ spec = describe "SHARED_TRANSACTIONS" $ do r <- request @(ApiTransaction n) ctx link Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) it "SHARED_TRANSACTIONS_GET_03 - \ \Using wrong transaction id" $ diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Wallets.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Wallets.hs index 7e69267623e..45d3c3f19e7 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Wallets.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Wallets.hs @@ -1704,7 +1704,7 @@ spec = describe "SHARED_WALLETS" $ do Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) describe "SHARED_WALLETS_UTXO_04 - HTTP headers" $ do let matrix = diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Addresses.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Addresses.hs index a24f617296a..0edc72f5763 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Addresses.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Addresses.hs @@ -139,7 +139,7 @@ spec = describe "SHELLEY_ADDRESSES" $ do r <- request @[ApiAddressWithPath n] ctx ep Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet wid) it "ADDRESS_LIST_01 - Can list known addresses on a default wallet" $ \ctx -> runResourceT $ do let g = fromIntegral $ getAddressPoolGap defaultAddressPoolGap @@ -293,7 +293,7 @@ spec = describe "SHELLEY_ADDRESSES" $ do (Link.listAddresses @'Shelley w) Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) it "ADDRESS_LIST_05 - bech32 HRP is correct - testnet" $ \ctx -> runResourceT $ do w <- emptyWallet ctx diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/CoinSelections.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/CoinSelections.hs index 996b2071622..a1362fadc6b 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/CoinSelections.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/CoinSelections.hs @@ -230,7 +230,7 @@ spec = describe "SHELLEY_COIN_SELECTION" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo rTx `Lifted.shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) it "WALLETS_COIN_SELECTION_03 - \ diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs index ffabc7514c7..d6ea1a47cea 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs @@ -249,7 +249,7 @@ spec = describe "SHELLEY_MIGRATIONS" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo result `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ sourceWallet ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ sourceWallet ^. walletId) Hspec.it "SHELLEY_CREATE_MIGRATION_PLAN_04 - \ diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/StakePools.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/StakePools.hs index dfb63364e82..b7b8e9fd065 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/StakePools.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/StakePools.hs @@ -273,7 +273,7 @@ spec = describe "SHELLEY_STAKE_POOLS" $ do r <- joinStakePool @n ctx (SpecificPool poolIdAbsent) (w, fixturePassphrase) expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet wid) it "STAKE_POOLS_JOIN_01 - Cannot join non-existent stakepool" $ \ctx -> runResourceT $ do w <- fixtureWallet ctx diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Transactions.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Transactions.hs index 7ad59e74df7..125098951b3 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Transactions.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Transactions.hs @@ -847,7 +847,7 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do payload expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) describe "TRANS_CREATE_08 - Bad payload" $ do let matrix = @@ -1710,7 +1710,7 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do payload expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) it "TRANS_LIST_01 - Can list Incoming and Outgoing transactions" $ \ctx -> runResourceT $ do @@ -2203,7 +2203,7 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) it "TRANS_LIST_RANGE_01 - \ @@ -2382,8 +2382,7 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do r <- request @(ApiTransaction n) ctx link Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) - + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) it "TRANS_GET_03 - Using wrong transaction id" $ \ctx -> runResourceT $ do (wSrc, wDest) <- (,) <$> fixtureWallet ctx <*> emptyWallet ctx diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs index 8f60b7bd020..7abfb4bc6e6 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs @@ -2803,7 +2803,7 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo submittedTx `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet wid) it "TRANS_NEW_SUBMIT_03 - Can submit transaction encoded in base16" $ \ctx -> runResourceT $ do wa <- fixtureWallet ctx diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs index 629a3948dd1..37a0020b841 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs @@ -739,7 +739,7 @@ spec = describe "SHELLEY_WALLETS" $ do (Link.getWallet @'Shelley w) Default Empty expectResponseCode HTTP.status404 rg decodeErrorInfo rg `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) it "WALLETS_LIST_01 - Created a wallet can be listed" $ \ctx -> runResourceT $ do m18 <- Mnemonics.generateSome Mnemonics.M18 @@ -900,7 +900,7 @@ spec = describe "SHELLEY_WALLETS" $ do ru <- request @ApiWallet ctx ("PUT", endpoint) Default newName expectResponseCode HTTP.status404 ru decodeErrorInfo ru `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet wid) describe "WALLETS_UPDATE_04 - HTTP headers" $ do let matrix = @@ -1085,7 +1085,7 @@ spec = describe "SHELLEY_WALLETS" $ do rup <- request @ApiWallet ctx ("PUT", updEndp) Default payload expectResponseCode HTTP.status404 rup decodeErrorInfo rup `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet walId) + NoSuchWallet (ApiErrorNoSuchWallet walId) it "WALLETS_UPDATE_PASS_04 - Deleted wallet is not available, mnemonic" $ \ctx -> runResourceT $ do @@ -1098,7 +1098,7 @@ spec = describe "SHELLEY_WALLETS" $ do rup <- request @ApiWallet ctx ("PUT", updEndp) Default payload expectResponseCode HTTP.status404 rup decodeErrorInfo rup `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet walId) + NoSuchWallet (ApiErrorNoSuchWallet walId) describe "WALLETS_UPDATE_PASS_05,06 - Transaction after updating passphrase" $ do @@ -1288,7 +1288,7 @@ spec = describe "SHELLEY_WALLETS" $ do Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) describe "WALLETS_UTXO_04 - HTTP headers" $ do let matrix = @@ -1389,7 +1389,7 @@ spec = describe "SHELLEY_WALLETS" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) it "WALLETS_SIGNATURES_01 - can verify signature" $ \ctx -> runResourceT $ do let mnemonic = unsafeMnemonic @15 @@ -1493,7 +1493,7 @@ spec = describe "SHELLEY_WALLETS" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) it "BYRON_WALLETS_UTXO -\ \ Cannot show Byron wal utxo with shelley ep (404)" $ \ctx -> runResourceT $ do @@ -1506,7 +1506,7 @@ spec = describe "SHELLEY_WALLETS" $ do r <- request @ApiUtxoStatistics ctx ("GET", endpoint) Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet wid) it "BYRON_WALLETS_UPDATE_PASS -\ \ Cannot update Byron wal with shelley ep (404)" $ \ctx -> runResourceT $ do @@ -1520,7 +1520,7 @@ spec = describe "SHELLEY_WALLETS" $ do rup <- request @ApiWallet ctx ("PUT", endpoint) Default payload expectResponseCode HTTP.status404 rup decodeErrorInfo rup `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet wid) it "BYRON_WALLETS_UPDATE -\ \ Cannot update Byron wal with shelley ep (404)" $ \ctx -> runResourceT $ do @@ -1531,7 +1531,7 @@ spec = describe "SHELLEY_WALLETS" $ do ru <- request @ApiWallet ctx ("PUT", endpoint) Default newName expectResponseCode HTTP.status404 ru decodeErrorInfo ru `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet wid) it "BYRON_WALLETS_GET_02 - Byron ep does not show Shelley wallet" $ \ctx -> runResourceT $ do w <- emptyWallet ctx @@ -1539,7 +1539,7 @@ spec = describe "SHELLEY_WALLETS" $ do (Link.getWallet @'Byron w) Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) it "BYRON_WALLETS_GET_03 - Shelley ep does not show Byron wallet" $ \ctx -> runResourceT $ do w <- emptyRandomWallet ctx @@ -1547,7 +1547,7 @@ spec = describe "SHELLEY_WALLETS" $ do (Link.getWallet @'Shelley w) Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) it "BYRON_WALLETS_LIST_02,03 - \ \Byron wallets listed only via Byron endpoints + \ @@ -1639,14 +1639,14 @@ spec = describe "SHELLEY_WALLETS" $ do r <- request @ApiByronWallet ctx (Link.deleteWallet @'Byron w) Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) it "BYRON_WALLETS_DELETE_03 - Shelley ep does not delete Byron wallet" $ \ctx -> runResourceT $ do w <- emptyRandomWallet ctx r <- request @ApiByronWallet ctx (Link.deleteWallet @'Shelley w) Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - (NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) it "WALLETS_NETWORK_SHELLEY - Wallet has the same tip as network/information" $ \ctx -> runResourceT $ do let getNetworkInfo = request @ApiNetworkInformation ctx diff --git a/specifications/api/swagger.yaml b/specifications/api/swagger.yaml index 9242115ac99..a720e3ed842 100644 --- a/specifications/api/swagger.yaml +++ b/specifications/api/swagger.yaml @@ -4361,9 +4361,9 @@ x-errNoUtxosAvailable: &errNoUtxosAvailable type: string enum: ['no_utxos_available'] -x-errNoSuchWalletInitialized: &errNoSuchWalletInitialized +x-errWalletNotInitialized: &errWalletNotInitialized <<: *responsesErr - title: no_such_wallet_initialized + title: wallet_not_initialized properties: message: type: string @@ -4371,7 +4371,7 @@ x-errNoSuchWalletInitialized: &errNoSuchWalletInitialized May occur when the database for the requested wallet is not initialized. code: type: string - enum: ['no_such_wallet_initialized'] + enum: ['wallet_not_initialized'] x-errNoSuchWallet: &errNoSuchWallet <<: *responsesErr @@ -5667,10 +5667,10 @@ x-responsesErr404WalletNotFound: &responsesErr404WalletNotFound x-responsesErr404DbNotInitialized: &responsesErr404DbNotInitialized 404: - description: DB uninitialized + description: Wallet not yet initialized content: application/json: - schema: *errNoSuchWalletInitialized + schema: *errWalletNotInitialized x-responsesErr503WalletMetadataNotFound: &responsesErr503WalletMetadataNotFound 503: @@ -6008,7 +6008,7 @@ x-responsesDeleteTransaction: &responsesDeleteTransaction schema: oneOf: - <<: *errNoSuchWallet - - <<: *errNoSuchWalletInitialized + - <<: *errWalletNotInitialized - <<: *errNoSuchTransaction <<: *responsesErr406 204: @@ -6047,7 +6047,7 @@ x-responsesGetTransaction: &responsesGetTransaction schema: oneOf: - <<: *errNoSuchWallet - - <<: *errNoSuchWalletInitialized + - <<: *errWalletNotInitialized - <<: *errNoSuchTransaction <<: *responsesErr406 200: @@ -6431,7 +6431,7 @@ x-responsesJoinStakePool: &responsesJoinStakePool schema: oneOf: - <<: *errNoSuchWallet - - <<: *errNoSuchWalletInitialized + - <<: *errWalletNotInitialized - <<: *errNoSuchPool <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType From c664feb3c4f9eac7cc8b06422f5d433abb5c6b07 Mon Sep 17 00:00:00 2001 From: Jonathan Knowles Date: Thu, 23 May 2024 06:37:36 +0000 Subject: [PATCH 20/25] Make `WalletId` an instance of `Data`. --- lib/wallet/src/Cardano/Wallet/Primitive/Types.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/wallet/src/Cardano/Wallet/Primitive/Types.hs b/lib/wallet/src/Cardano/Wallet/Primitive/Types.hs index f77af0999ef..b46eafd16c8 100644 --- a/lib/wallet/src/Cardano/Wallet/Primitive/Types.hs +++ b/lib/wallet/src/Cardano/Wallet/Primitive/Types.hs @@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingVia #-} {-# LANGUAGE DuplicateRecordFields #-} @@ -263,7 +264,8 @@ import Data.ByteString ( ByteString ) import Data.Data - ( Proxy (..) + ( Data + , Proxy (..) ) import Data.Generics.Labels () @@ -387,7 +389,7 @@ walletNameMaxLength :: Int walletNameMaxLength = 255 newtype WalletId = WalletId { getWalletId :: Digest Blake2b_160 } - deriving (Generic, Eq, Ord, Show) + deriving (Data, Generic, Eq, Ord, Show) instance NFData WalletId From 00fd690e487096aeb3edd93ac33e8bbb8ebc8953 Mon Sep 17 00:00:00 2001 From: Jonathan Knowles Date: Thu, 23 May 2024 06:38:33 +0000 Subject: [PATCH 21/25] Use `ApiT WalletId` instead of `Text` for `ApiErrorNoSuchWallet`. --- .../Cardano/Wallet/Api/Http/Server/Error.hs | 3 +- lib/api/src/Cardano/Wallet/Api/Types/Error.hs | 6 +++- .../Scenario/API/Byron/Addresses.hs | 3 +- .../Scenario/API/Byron/CoinSelections.hs | 3 +- .../Scenario/API/Byron/Migrations.hs | 2 +- .../Scenario/API/Byron/Transactions.hs | 12 ++++---- .../Integration/Scenario/API/Byron/Wallets.hs | 2 +- .../Scenario/API/Shared/Transactions.hs | 5 ++-- .../Scenario/API/Shared/Wallets.hs | 2 +- .../Scenario/API/Shelley/Addresses.hs | 4 +-- .../Scenario/API/Shelley/CoinSelections.hs | 3 +- .../Scenario/API/Shelley/Migrations.hs | 3 +- .../Scenario/API/Shelley/StakePools.hs | 4 +-- .../Scenario/API/Shelley/Transactions.hs | 8 +++--- .../Scenario/API/Shelley/TransactionsNew.hs | 2 +- .../Scenario/API/Shelley/Wallets.hs | 28 +++++++++---------- 16 files changed, 45 insertions(+), 45 deletions(-) diff --git a/lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs b/lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs index ead427a540e..2583575a194 100644 --- a/lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs +++ b/lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs @@ -103,6 +103,7 @@ import Cardano.Wallet.Api.Http.Server.Error.IsServerError import Cardano.Wallet.Api.Types ( ApiCosignerIndex (..) , ApiCredentialType (..) + , ApiT (ApiT) , Iso8601Time (..) , toApiEra ) @@ -253,7 +254,7 @@ instance IsServerError ErrNoSuchWallet where toServerError = \case ErrNoSuchWallet wid -> flip (apiError err404) message $ - NoSuchWallet ApiErrorNoSuchWallet { walletId = toText wid } + NoSuchWallet ApiErrorNoSuchWallet { walletId = ApiT wid } where message = mconcat [ "I couldn't find a wallet with the given id: " diff --git a/lib/api/src/Cardano/Wallet/Api/Types/Error.hs b/lib/api/src/Cardano/Wallet/Api/Types/Error.hs index 709ab77ad84..ac8b69d86ac 100644 --- a/lib/api/src/Cardano/Wallet/Api/Types/Error.hs +++ b/lib/api/src/Cardano/Wallet/Api/Types/Error.hs @@ -46,6 +46,7 @@ import Cardano.Wallet.Api.Types ( ApiCosignerIndex (..) , ApiCredentialType (..) , ApiEra + , ApiT ) import Cardano.Wallet.Api.Types.Amount ( ApiAmount @@ -53,6 +54,9 @@ import Cardano.Wallet.Api.Types.Amount import Cardano.Wallet.Api.Types.WalletAssets ( ApiWalletAssets ) +import Cardano.Wallet.Primitive.Types + ( WalletId + ) import Cardano.Wallet.Primitive.Types.Pool ( PoolId ) @@ -332,7 +336,7 @@ data ApiErrorNoSuchPool = ApiErrorNoSuchPool deriving anyclass NFData data ApiErrorNoSuchWallet = ApiErrorNoSuchWallet - { walletId :: !Text + { walletId :: !(ApiT WalletId) } deriving (Data, Eq, Generic, Show, Typeable) deriving (FromJSON, ToJSON) via DefaultRecord ApiErrorNoSuchWallet diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Addresses.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Addresses.hs index 6388acc204a..7241886aa9c 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Addresses.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Addresses.hs @@ -89,7 +89,6 @@ import Test.Integration.Framework.DSL , randomAddresses , request , verify - , walletId ) import Test.Integration.Framework.TestData ( errMsg403CouldntIdentifyAddrAsMine @@ -197,7 +196,7 @@ scenario_ADDRESS_LIST_04 fixture = it title $ \ctx -> runResourceT $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo r `Lifted.shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ w ^. #id) where title = "ADDRESS_LIST_04 - Delete wallet" diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/CoinSelections.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/CoinSelections.hs index d425f75f941..75fc7599e58 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/CoinSelections.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/CoinSelections.hs @@ -69,7 +69,6 @@ import Test.Integration.Framework.DSL , runResourceT , selectCoins , verify - , walletId ) import Test.Integration.Framework.TestData ( errMsg403NotAnIcarusWallet @@ -159,4 +158,4 @@ spec = describe "BYRON_COIN_SELECTION" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ icW ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ icW ^. #id) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs index 5e1930b41ff..afd23786f7c 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs @@ -194,7 +194,7 @@ spec = describe "BYRON_MIGRATIONS" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo response `Lifted.shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ sourceWallet ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet $ sourceWallet ^. #id) it "BYRON_CREATE_MIGRATION_PLAN_04 - \ \Cannot create a plan for a wallet that only contains dust." diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Transactions.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Transactions.hs index 747f8c9209b..5cb25b2ffa8 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Transactions.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Transactions.hs @@ -557,7 +557,7 @@ spec = describe "BYRON_TRANSACTIONS" $ do r <- request @(ApiTransaction n) ctx ("POST", endpoint) Default payload expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "BYRON_TRANS_DELETE -\ \ Cannot delete tx on Byron wallet using shelley ep" $ \ctx -> runResourceT $ do @@ -568,7 +568,7 @@ spec = describe "BYRON_TRANSACTIONS" $ do r <- request @ApiTxId ctx ("DELETE", endpoint) Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "BYRON_TRANS_ESTIMATE -\ \ Cannot estimate tx on Byron wallet using shelley ep" $ \ctx -> runResourceT $ do @@ -590,7 +590,7 @@ spec = describe "BYRON_TRANSACTIONS" $ do r <- request @ApiFee ctx ("POST", endpoint) Default payload expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "BYRON_TX_LIST_02 -\ \ Byron endpoint does not list Shelley wallet transactions" $ \ctx -> runResourceT $ do @@ -602,7 +602,7 @@ spec = describe "BYRON_TRANSACTIONS" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "BYRON_TX_LIST_03 -\ \ Shelley endpoint does not list Byron wallet transactions" $ \ctx -> runResourceT $ do @@ -614,7 +614,7 @@ spec = describe "BYRON_TRANSACTIONS" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "BYRON_RESTORE_09 - Ledger wallet" $ \ctx -> runResourceT $ do -- NOTE @@ -785,7 +785,7 @@ spec = describe "BYRON_TRANSACTIONS" $ do r <- request @([ApiTransaction n]) ctx link Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) describe "BYRON_TX_LIST_ADDRESS - Transactions can be filtered by address" $ forM_ [ (fixtureRandomWallet, emptyRandomWallet, "Byron wallet") diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Wallets.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Wallets.hs index 0055e85a01d..deb9b6f1992 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Wallets.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Wallets.hs @@ -134,7 +134,7 @@ spec = describe "BYRON_WALLETS" $ do rg <- request @ApiByronWallet ctx (Link.getWallet @'Byron w) Default Empty expectResponseCode HTTP.status404 rg decodeErrorInfo rg `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "BYRON_LIST_01 - Byron Wallets are listed from oldest to newest" $ \ctx -> runResourceT $ do diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Transactions.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Transactions.hs index 4fd1c1feeea..1b2ef7fe40f 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Transactions.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Transactions.hs @@ -206,7 +206,6 @@ import Test.Integration.Framework.DSL , verify , waitForNextEpoch , waitNumberOfEpochBoundaries - , walletId , (.>) ) import Test.Integration.Framework.Request @@ -1608,7 +1607,7 @@ spec = describe "SHARED_TRANSACTIONS" $ do Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "SHARED_TRANSACTIONS_LIST_RANGE_01 - \ \Transaction at time t is SELECTED by small ranges that cover it" $ @@ -1741,7 +1740,7 @@ spec = describe "SHARED_TRANSACTIONS" $ do r <- request @(ApiTransaction n) ctx link Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "SHARED_TRANSACTIONS_GET_03 - \ \Using wrong transaction id" $ diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Wallets.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Wallets.hs index 45d3c3f19e7..8c85f1a3df7 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Wallets.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shared/Wallets.hs @@ -1704,7 +1704,7 @@ spec = describe "SHARED_WALLETS" $ do Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) describe "SHARED_WALLETS_UTXO_04 - HTTP headers" $ do let matrix = diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Addresses.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Addresses.hs index 0edc72f5763..ebf1340dd5c 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Addresses.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Addresses.hs @@ -139,7 +139,7 @@ spec = describe "SHELLEY_ADDRESSES" $ do r <- request @[ApiAddressWithPath n] ctx ep Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "ADDRESS_LIST_01 - Can list known addresses on a default wallet" $ \ctx -> runResourceT $ do let g = fromIntegral $ getAddressPoolGap defaultAddressPoolGap @@ -293,7 +293,7 @@ spec = describe "SHELLEY_ADDRESSES" $ do (Link.listAddresses @'Shelley w) Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "ADDRESS_LIST_05 - bech32 HRP is correct - testnet" $ \ctx -> runResourceT $ do w <- emptyWallet ctx diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/CoinSelections.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/CoinSelections.hs index a1362fadc6b..f598d7b3eb4 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/CoinSelections.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/CoinSelections.hs @@ -112,7 +112,6 @@ import Test.Integration.Framework.DSL , selectCoinsWith , verify , verifyMsg - , walletId ) import Test.Integration.Framework.TestData ( errMsg400TxMetadataStringTooLong @@ -230,7 +229,7 @@ spec = describe "SHELLEY_COIN_SELECTION" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo rTx `Lifted.shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "WALLETS_COIN_SELECTION_03 - \ diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs index d6ea1a47cea..d73fbaf7fa0 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs @@ -249,7 +249,8 @@ spec = describe "SHELLEY_MIGRATIONS" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo result `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ sourceWallet ^. walletId) + NoSuchWallet + (ApiErrorNoSuchWallet (sourceWallet ^. #id)) Hspec.it "SHELLEY_CREATE_MIGRATION_PLAN_04 - \ diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/StakePools.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/StakePools.hs index b7b8e9fd065..2a6b4995d28 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/StakePools.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/StakePools.hs @@ -213,7 +213,6 @@ import Test.Integration.Framework.DSL , waitForTxImmutability , waitForTxStatus , waitNumberOfEpochBoundaries - , walletId , (.<) , (.>) , (.>=) @@ -262,7 +261,6 @@ spec = describe "SHELLEY_STAKE_POOLS" $ do it "STAKE_POOLS_JOIN_01 - Cannot join non-existent wallet" $ \ctx -> runResourceT $ do w <- emptyWallet ctx - let wid = w ^. walletId _ <- request @ApiWallet ctx @@ -273,7 +271,7 @@ spec = describe "SHELLEY_STAKE_POOLS" $ do r <- joinStakePool @n ctx (SpecificPool poolIdAbsent) (w, fixturePassphrase) expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "STAKE_POOLS_JOIN_01 - Cannot join non-existent stakepool" $ \ctx -> runResourceT $ do w <- fixtureWallet ctx diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Transactions.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Transactions.hs index 125098951b3..c4f4689bde1 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Transactions.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Transactions.hs @@ -847,7 +847,7 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do payload expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) describe "TRANS_CREATE_08 - Bad payload" $ do let matrix = @@ -1710,7 +1710,7 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do payload expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "TRANS_LIST_01 - Can list Incoming and Outgoing transactions" $ \ctx -> runResourceT $ do @@ -2203,7 +2203,7 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "TRANS_LIST_RANGE_01 - \ @@ -2382,7 +2382,7 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do r <- request @(ApiTransaction n) ctx link Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "TRANS_GET_03 - Using wrong transaction id" $ \ctx -> runResourceT $ do (wSrc, wDest) <- (,) <$> fixtureWallet ctx <*> emptyWallet ctx diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs index 7abfb4bc6e6..f2880e2bc04 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs @@ -2803,7 +2803,7 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo submittedTx `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet (wb ^. #id)) it "TRANS_NEW_SUBMIT_03 - Can submit transaction encoded in base16" $ \ctx -> runResourceT $ do wa <- fixtureWallet ctx diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs index 37a0020b841..c314e6e0756 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs @@ -739,7 +739,7 @@ spec = describe "SHELLEY_WALLETS" $ do (Link.getWallet @'Shelley w) Default Empty expectResponseCode HTTP.status404 rg decodeErrorInfo rg `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "WALLETS_LIST_01 - Created a wallet can be listed" $ \ctx -> runResourceT $ do m18 <- Mnemonics.generateSome Mnemonics.M18 @@ -900,7 +900,7 @@ spec = describe "SHELLEY_WALLETS" $ do ru <- request @ApiWallet ctx ("PUT", endpoint) Default newName expectResponseCode HTTP.status404 ru decodeErrorInfo ru `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) describe "WALLETS_UPDATE_04 - HTTP headers" $ do let matrix = @@ -1085,7 +1085,7 @@ spec = describe "SHELLEY_WALLETS" $ do rup <- request @ApiWallet ctx ("PUT", updEndp) Default payload expectResponseCode HTTP.status404 rup decodeErrorInfo rup `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet walId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "WALLETS_UPDATE_PASS_04 - Deleted wallet is not available, mnemonic" $ \ctx -> runResourceT $ do @@ -1098,7 +1098,7 @@ spec = describe "SHELLEY_WALLETS" $ do rup <- request @ApiWallet ctx ("PUT", updEndp) Default payload expectResponseCode HTTP.status404 rup decodeErrorInfo rup `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet walId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) describe "WALLETS_UPDATE_PASS_05,06 - Transaction after updating passphrase" $ do @@ -1288,7 +1288,7 @@ spec = describe "SHELLEY_WALLETS" $ do Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) describe "WALLETS_UTXO_04 - HTTP headers" $ do let matrix = @@ -1389,7 +1389,7 @@ spec = describe "SHELLEY_WALLETS" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "WALLETS_SIGNATURES_01 - can verify signature" $ \ctx -> runResourceT $ do let mnemonic = unsafeMnemonic @15 @@ -1493,7 +1493,7 @@ spec = describe "SHELLEY_WALLETS" $ do [ expectResponseCode HTTP.status404 ] decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "BYRON_WALLETS_UTXO -\ \ Cannot show Byron wal utxo with shelley ep (404)" $ \ctx -> runResourceT $ do @@ -1506,7 +1506,7 @@ spec = describe "SHELLEY_WALLETS" $ do r <- request @ApiUtxoStatistics ctx ("GET", endpoint) Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "BYRON_WALLETS_UPDATE_PASS -\ \ Cannot update Byron wal with shelley ep (404)" $ \ctx -> runResourceT $ do @@ -1520,7 +1520,7 @@ spec = describe "SHELLEY_WALLETS" $ do rup <- request @ApiWallet ctx ("PUT", endpoint) Default payload expectResponseCode HTTP.status404 rup decodeErrorInfo rup `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "BYRON_WALLETS_UPDATE -\ \ Cannot update Byron wal with shelley ep (404)" $ \ctx -> runResourceT $ do @@ -1531,7 +1531,7 @@ spec = describe "SHELLEY_WALLETS" $ do ru <- request @ApiWallet ctx ("PUT", endpoint) Default newName expectResponseCode HTTP.status404 ru decodeErrorInfo ru `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet wid) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "BYRON_WALLETS_GET_02 - Byron ep does not show Shelley wallet" $ \ctx -> runResourceT $ do w <- emptyWallet ctx @@ -1539,7 +1539,7 @@ spec = describe "SHELLEY_WALLETS" $ do (Link.getWallet @'Byron w) Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "BYRON_WALLETS_GET_03 - Shelley ep does not show Byron wallet" $ \ctx -> runResourceT $ do w <- emptyRandomWallet ctx @@ -1547,7 +1547,7 @@ spec = describe "SHELLEY_WALLETS" $ do (Link.getWallet @'Shelley w) Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "BYRON_WALLETS_LIST_02,03 - \ \Byron wallets listed only via Byron endpoints + \ @@ -1639,14 +1639,14 @@ spec = describe "SHELLEY_WALLETS" $ do r <- request @ApiByronWallet ctx (Link.deleteWallet @'Byron w) Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "BYRON_WALLETS_DELETE_03 - Shelley ep does not delete Byron wallet" $ \ctx -> runResourceT $ do w <- emptyRandomWallet ctx r <- request @ApiByronWallet ctx (Link.deleteWallet @'Shelley w) Default Empty expectResponseCode HTTP.status404 r decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) + NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "WALLETS_NETWORK_SHELLEY - Wallet has the same tip as network/information" $ \ctx -> runResourceT $ do let getNetworkInfo = request @ApiNetworkInformation ctx From c9a339a268705a3900497da5d2929dbc09713965 Mon Sep 17 00:00:00 2001 From: Jonathan Knowles Date: Thu, 23 May 2024 06:43:37 +0000 Subject: [PATCH 22/25] Regenerate `ApiErrorNoSuchWallet.json`. This is necessary, as type `ApiErrorNoSuchWallet` uses a real `WalletId` instead of just `Text`. --- .../Wallet/Api/ApiErrorNoSuchWallet.json | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/unit/test/data/Cardano/Wallet/Api/ApiErrorNoSuchWallet.json b/lib/unit/test/data/Cardano/Wallet/Api/ApiErrorNoSuchWallet.json index 3bcd36e443f..a8571baada5 100644 --- a/lib/unit/test/data/Cardano/Wallet/Api/ApiErrorNoSuchWallet.json +++ b/lib/unit/test/data/Cardano/Wallet/Api/ApiErrorNoSuchWallet.json @@ -1,35 +1,35 @@ { "samples": [ { - "wallet_id": "@𗁄𧧽𨧯\u0018-a.B\"w\u0016叁'\u0012s2,ᢾ!\u000erTD\u0007fw" + "wallet_id": "6524d51c49d87740db3a3c2e62d82267b543a6cf" }, { - "wallet_id": "󳟭􅦫iᚠC\u001e􊡠L\u000b𰿐h-󱉋\u00012I󰉏䯾𮝣:󴒞􁩋(" + "wallet_id": "a987b59400280be6b47b1b13ea5e386062a67e81" }, { - "wallet_id": "\u001dqaaR𦝭&=𱇑\u001dZ\u0011#1M󸝙" + "wallet_id": "c1793e140462743013585c89bd6cf6a69d7f59b3" }, { - "wallet_id": "PS􎅱\\*|\u0011@" + "wallet_id": "946b649eef71f01477178fcb069ab403d048b8a3" }, { - "wallet_id": "\u0004&\u0008\n5^DI*K\u0011􆗴r\u0005I𰶼N!@&\u001c\u0008kd􂦠A" + "wallet_id": "5debea5568c412cf9293f0c67977f874ca7f5aca" }, { - "wallet_id": "󳓫wU\ti𢊶\u0003d􀮊s𢚤K\u0016󴬅SN𦻙𢏯\u001c*󸖐䪘K􀴤\t\u0013u{󼛎" + "wallet_id": "d0bbaac33e0a4fbf14c5db9654809c4fefb70e0b" }, { - "wallet_id": "􈾜nJ'𘥵F\u0005UR󲖒寔\u001a󰽦OB7𥪥.󴺗\u0018H" + "wallet_id": "53348b8491a6fdce3936c8a9bfcbcec0f29869af" }, { - "wallet_id": "S&􃆳𨟤𫃄㿝y\u0013]" + "wallet_id": "a4c90e0ad19156a347082bd7b21d6ba730b532fe" }, { - "wallet_id": "RT𱸖\r𦵯􀜌\u0005💧" + "wallet_id": "ace2e09835abf46b70213c2f60bf142c774ebdbe" }, { - "wallet_id": "\u001c1\u000cboG\\\"U󵢏󳗀\u0018" + "wallet_id": "556a4cd62a3dda336ab5d2582f8e0fa16a1fc853" } ], - "seed": 1010481003 + "seed": 1466306521 } \ No newline at end of file From 0f2d84a80d9d310334e0775cbb381a775a8361a1 Mon Sep 17 00:00:00 2001 From: Jonathan Knowles Date: Thu, 23 May 2024 06:48:53 +0000 Subject: [PATCH 23/25] Rename `Err404DbNotInitialized` to `Err404WalletNotInitialized`. --- specifications/api/swagger.yaml | 48 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/specifications/api/swagger.yaml b/specifications/api/swagger.yaml index a720e3ed842..5ced3e3e51c 100644 --- a/specifications/api/swagger.yaml +++ b/specifications/api/swagger.yaml @@ -5665,7 +5665,7 @@ x-responsesErr404WalletNotFound: &responsesErr404WalletNotFound application/json: schema: *errNoSuchWallet -x-responsesErr404DbNotInitialized: &responsesErr404DbNotInitialized +x-responsesErr404WalletNotInitialized: &responsesErr404WalletNotInitialized 404: description: Wallet not yet initialized content: @@ -5751,7 +5751,7 @@ x-responsesListByronWallets: &responsesListByronWallets x-responsesGetUTxOsStatistics: &responsesGetUTxOsStatistics <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 200: description: Ok @@ -5761,7 +5761,7 @@ x-responsesGetUTxOsStatistics: &responsesGetUTxOsStatistics x-responsesGetWalletUtxoSnapshot: &responsesGetWalletUtxoSnapshot <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 200: description: Ok @@ -5819,7 +5819,7 @@ x-responsesPostByronWallet: &responsesPostByronWallet x-responsesGetWallet: &responsesGetWallet <<: *responsesErr400 <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 200: description: Ok @@ -5839,7 +5839,7 @@ x-responsesGetByronWallet: &responsesGetByronWallet x-responsesGetSharedWallet: &responsesGetSharedWallet <<: *responsesErr400 <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 200: description: Ok @@ -5850,7 +5850,7 @@ x-responsesGetSharedWallet: &responsesGetSharedWallet x-responsesPatchSharedWallet: &responsesPatchSharedWallet <<: *responsesErr400 <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 <<: *responsesErr503WalletMetadataNotFound 403: @@ -5877,7 +5877,7 @@ x-responsesCreateWalletMigrationPlan: &responsesCreateWalletMigrationPlan application/json: schema: *errNothingToMigrate <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 202: description: Accepted @@ -5896,7 +5896,7 @@ x-responsesMigrateWallet: &responsesMigrateWallet - <<: *errNoRootKey - <<: *errWrongEncryptionPassphrase <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 202: @@ -5911,7 +5911,7 @@ x-responsesMigrateWallet: &responsesMigrateWallet x-responsesDeleteWallet: &responsesDeleteWallet <<: *responsesErr400 <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 204: description: No Content @@ -5928,7 +5928,7 @@ x-responsesForceResyncWallet: &responsesForceResyncWallet x-responsesPutWallet: &responsesPutWallet <<: *responsesErr400 <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 200: @@ -5940,7 +5940,7 @@ x-responsesPutWallet: &responsesPutWallet x-responsesPutSharedWallet: &responsesPutSharedWallet <<: *responsesErr400 <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 200: @@ -5961,7 +5961,7 @@ x-responsesPutWalletPassphrase: &responsesPutWalletPassphrase - <<: *errWrongEncryptionPassphrase - <<: *errWrongMnemonic <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 204: @@ -5986,7 +5986,7 @@ x-responsesSelectCoins: &responsesSelectCoins - <<: *errOutputTokenQuantityExceedsLimit - <<: *errOutputTokenBundleSizeExceedsLimit <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 200: @@ -6024,7 +6024,7 @@ x-responsesListTransactions: &responsesListTransactions - <<: *errMinWithdrawalWrong - <<: *errStartTimeLaterThanEndTime <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 200: description: Ok @@ -6077,7 +6077,7 @@ x-responsesPostTransaction: &responsesPostTransaction - <<: *errWrongEncryptionPassphrase - <<: *errUnsupportedEra <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType <<: *responsesErr425MempoolIsFull @@ -6121,7 +6121,7 @@ x-responsesConstructTransaction: &responsesConstructTransaction - <<: *errVotingInInvalidEra - <<: *errWithdrawalNotPossibleWithoutVote <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 202: @@ -6141,7 +6141,7 @@ x-responsesSignTransaction: &responsesSignTransaction - <<: *errNoRootKey - <<: *errWrongEncryptionPassphrase <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 202: @@ -6153,7 +6153,7 @@ x-responsesSignTransaction: &responsesSignTransaction x-responsesDecodedTransaction: &responsesDecodedTransaction <<: *responsesErr400 <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 202: @@ -6165,7 +6165,7 @@ x-responsesDecodedTransaction: &responsesDecodedTransaction x-responsesSubmitTransaction: &responsesSubmitTransaction <<: *responsesErr400 <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 202: @@ -6231,7 +6231,7 @@ x-responsesPostTransactionFee: &responsesPostTransactionFee - <<: *errOutputTokenBundleSizeExceedsLimit - <<: *errTransactionIsTooBig <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 202: @@ -6247,7 +6247,7 @@ x-responsesGetDelegationFee: &responsesGetDelegationFee application/json: schema: *errCannotCoverFee <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 200: description: Ok @@ -6258,7 +6258,7 @@ x-responsesGetDelegationFee: &responsesGetDelegationFee x-responsesListAddresses: &responsesListAddresses <<: *responsesErr400 <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 200: description: Ok @@ -6456,7 +6456,7 @@ x-responsesQuitStakePool: &responsesQuitStakePool - <<: *errNotDelegatingTo - <<: *errNonNullRewards <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 202: @@ -6595,7 +6595,7 @@ x-responsesBalanceTransaction: &responsesBalanceTransaction - <<: *errTranslationByronTxOutInContext <<: *responsesErr404WalletNotFound - <<: *responsesErr404DbNotInitialized + <<: *responsesErr404WalletNotInitialized <<: *responsesErr406 <<: *responsesErr415UnsupportedMediaType 202: From 5253bc6298e001b30878675a5babddcc9552bd46 Mon Sep 17 00:00:00 2001 From: Jonathan Knowles Date: Thu, 23 May 2024 08:04:00 +0000 Subject: [PATCH 24/25] Fix order of imports, placed out of order by prior merge. --- .../Test/Integration/Scenario/API/Byron/Migrations.hs | 6 +++--- .../Test/Integration/Scenario/API/Shelley/Migrations.hs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs index 2604b0bcfdc..51d95f7447f 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Byron/Migrations.hs @@ -33,13 +33,13 @@ import Cardano.Wallet.Api.Types import Cardano.Wallet.Api.Types.Amount ( ApiAmount (ApiAmount) ) +import Cardano.Wallet.Api.Types.Era + ( ApiEra (..) + ) import Cardano.Wallet.Api.Types.Error ( ApiErrorInfo (..) , ApiErrorNoSuchWallet (ApiErrorNoSuchWallet) ) -import Cardano.Wallet.Api.Types.Era - ( ApiEra (..) - ) import Cardano.Wallet.Primitive.NetworkId ( HasSNetworkId (..) ) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs index 6a99149c183..dd15e6fd615 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Migrations.hs @@ -35,13 +35,13 @@ import Cardano.Wallet.Api.Types import Cardano.Wallet.Api.Types.Amount ( ApiAmount (ApiAmount) ) +import Cardano.Wallet.Api.Types.Era + ( ApiEra (..) + ) import Cardano.Wallet.Api.Types.Error ( ApiErrorInfo (..) , ApiErrorNoSuchWallet (ApiErrorNoSuchWallet) ) -import Cardano.Wallet.Api.Types.Era - ( ApiEra (..) - ) import Cardano.Wallet.Faucet ( Faucet (..) ) From 7050122bff531f2e12834fe4900dab4cc014df70 Mon Sep 17 00:00:00 2001 From: Jonathan Knowles Date: Thu, 23 May 2024 09:46:00 +0000 Subject: [PATCH 25/25] Revert use of `decodeErrorInfo` for `WALLETS_SIGNATURES_03`. This particular test happens to use `rawRequest` instead of `request`. Whereas the `request` function attempts to decode the response into a JSON `Value`, the `rawRequest` function does not perform any decoding. This causes the subsequent `decodeErrorInfo` to fail with: ``` uncaught exception: ErrorCall decodeErrorInfo: Expected a 'ClientError', but encountered something else: Left (RawClientError "{\"code\":\"no_such_wallet\",\"info\":{\"wallet_id\":\"acab1951ad1ef5808eb9756b02d1ff85caf0e702\"},\"message\":\"I couldn't find a wallet with the given id: acab1951ad1ef5808eb9756b02d1ff85caf0e702\"}") CallStack (from HasCallStack): error, called at framework/Test/Integration/Framework/DSL.hs:742:13 in cardano-wallet-integration-2024.5.5-KhWmuWPIqBp7pTemTBE3I2-framework:Test.Integration.Framework.DSL decodeErrorInfo, called at scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs:1495:9 in cardano-wallet-integration-2024.5.5-AcHGWrd1jBGKoKhY01VJRG-scenarios:Test.Integration.Scenario.API.Shelley.Wallets ``` --- .../Test/Integration/Scenario/API/Shelley/Wallets.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs index c314e6e0756..5dfccf321fa 100644 --- a/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs +++ b/lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs @@ -178,6 +178,7 @@ import Test.Integration.Framework.TestData ( arabicWalletName , errMsg403WrongMnemonic , errMsg403WrongPass + , errMsg404NoWallet , errMsg406 , errMsg415 , kanjiWalletName @@ -1489,11 +1490,12 @@ spec = describe "SHELLEY_WALLETS" $ do (Headers [(HTTP.hAccept, "*/*"), (HTTP.hContentType, "application/json")]) (Json payload) + -- TODO: ADP-3306 + -- Use `expectErrorInfo` instead of `expectErrorMessage` here: verify r [ expectResponseCode HTTP.status404 + , expectErrorMessage (errMsg404NoWallet $ w ^. walletId) ] - decodeErrorInfo r `shouldBe` - NoSuchWallet (ApiErrorNoSuchWallet (w ^. #id)) it "BYRON_WALLETS_UTXO -\ \ Cannot show Byron wal utxo with shelley ep (404)" $ \ctx -> runResourceT $ do