From 4844b0a3d8056de51dc5b18471a347fc531a285c Mon Sep 17 00:00:00 2001 From: ttt161 Date: Wed, 19 Aug 2026 09:20:38 +0300 Subject: [PATCH 1/2] use withdrwal new body if defined --- rebar.config | 17 +++++++++----- rebar.lock | 2 +- src/wapi_withdrawal_backend.erl | 6 +++-- test/wapi_wallet_dummy_data.hrl | 6 +++-- test/wapi_withdrawal_tests_SUITE.erl | 34 ++++++++++++++++++++++++++++ 5 files changed, 54 insertions(+), 11 deletions(-) diff --git a/rebar.config b/rebar.config index 4b857ab..792868d 100644 --- a/rebar.config +++ b/rebar.config @@ -34,7 +34,7 @@ {dmt_client, {git, "https://github.com/valitydev/dmt-client.git", {tag, "v2.0.3"}}}, {damsel, {git, "https://github.com/valitydev/damsel.git", {tag, "v2.2.43"}}}, {identdocstore_proto, {git, "https://github.com/valitydev/identdocstore-proto.git", {branch, "master"}}}, - {fistful_proto, {git, "https://github.com/valitydev/fistful-proto.git", {tag, "v2.0.1"}}}, + {fistful_proto, {git, "https://github.com/valitydev/fistful-proto.git", {branch, "master"}}}, {fistful_reporter_proto, {git, "https://github.com/valitydev/fistful-reporter-proto.git", {branch, "master"}}}, {file_storage_proto, {git, "https://github.com/valitydev/file-storage-proto.git", {branch, "master"}}}, {bender_client, {git, "https://github.com/valitydev/bender-client-erlang.git", {tag, "v1.1.0"}}}, @@ -45,7 +45,8 @@ {token_keeper_client, {git, "https://github.com/valitydev/token-keeper-client.git", {tag, "v1.1.0"}}}, {uac, {git, "https://github.com/valitydev/erlang_uac.git", {branch, master}}}, {tds_proto, {git, "https://github.com/valitydev/tds-proto.git", {branch, master}}}, - {opentelemetry_api, "1.4.0"}, + %{opentelemetry_api, "1.4.0"}, + {opentelemetry_api, {git, "https://github.com/open-telemetry/opentelemetry-erlang.git", {tag, "v1.4.0"}}}, %% NOTE %% Pinning to version "1.11.2" from hex here causes constant upgrading and recompilation of the entire project @@ -79,7 +80,8 @@ %% Libraries generated with swagger-codegen-erlang from valitydev/swag-wallets {swag_server_wallet, {git, "https://github.com/valitydev/swag-wallets", {ref, "8cd59f5"}}}, {swag_client_wallet, {git, "https://github.com/valitydev/swag-wallets", {ref, "2b52418"}}}, - {meck, "0.9.2"} + %{meck, "0.9.2"} + {meck, {git, "https://github.com/eproxus/meck.git", {tag, "0.9.2"}}} ]}, {cover_enabled, true}, {cover_excl_apps, [ @@ -91,9 +93,12 @@ ]}. {project_plugins, [ - {rebar3_lint, "3.2.6"}, - {erlfmt, "1.5.0"}, - {covertool, "2.0.7"} + %{rebar3_lint, "3.2.6"}, + %{erlfmt, "1.5.0"}, + %{covertool, "2.0.7"} + {rebar3_lint, {git, "https://github.com/project-fifo/rebar3_lint.git", {tag, "3.2.6"}}}, + {erlfmt, {git, "https://github.com/WhatsApp/erlfmt.git", {tag, "v1.5.0"}}}, + {covertool, {git, "https://github.com/covertool/covertool.git", {tag, "2.0.7"}}} ]}. %% Linter config. diff --git a/rebar.lock b/rebar.lock index 1d8b679..c347224 100644 --- a/rebar.lock +++ b/rebar.lock @@ -33,7 +33,7 @@ 0}, {<<"fistful_proto">>, {git,"https://github.com/valitydev/fistful-proto.git", - {ref,"7c61ac50ddb658bee477538f32133f815bc45876"}}, + {ref,"360c737c83b627af5084a1e47e31755fb30c2239"}}, 0}, {<<"fistful_reporter_proto">>, {git,"https://github.com/valitydev/fistful-reporter-proto.git", diff --git a/src/wapi_withdrawal_backend.erl b/src/wapi_withdrawal_backend.erl index 47b44fe..d707adc 100644 --- a/src/wapi_withdrawal_backend.erl +++ b/src/wapi_withdrawal_backend.erl @@ -450,17 +450,19 @@ unmarshal(withdrawal, #wthd_WithdrawalState{ wallet_id = WalletID, party_id = PartyID, destination_id = DestinationID, - body = Body, + body = Body0, external_id = ExternalID, status = Status, created_at = CreatedAt, metadata = Metadata, quote = Quote, contact_info = ContactInfo, - effective_final_cash_flow = EffectiveFinalCashFlow + effective_final_cash_flow = EffectiveFinalCashFlow, + new_body = NewBody }) -> UnmarshaledMetadata = maybe_unmarshal(context, Metadata), Fee = maybe_unmarshal_fee(Status, EffectiveFinalCashFlow), + Body = genlib:define(NewBody, Body0), genlib_map:compact( maps:merge( #{ diff --git a/test/wapi_wallet_dummy_data.hrl b/test/wapi_wallet_dummy_data.hrl index dad30fd..4d16fbf 100644 --- a/test/wapi_wallet_dummy_data.hrl +++ b/test/wapi_wallet_dummy_data.hrl @@ -44,8 +44,10 @@ -define(PAYMENT_SERVICE_REF(ID), #'fistful_base_PaymentServiceRef'{id = ID}). -define(CRYPTO_CURRENCY_REF(ID), #'fistful_base_CryptoCurrencyRef'{id = ID}). --define(CASH, #'fistful_base_Cash'{ - amount = ?INTEGER, +-define(CASH, ?CASH(?INTEGER)). + +-define(CASH(Amount), #'fistful_base_Cash'{ + amount = Amount, currency = #'fistful_base_CurrencyRef'{ symbolic_code = ?RUB } diff --git a/test/wapi_withdrawal_tests_SUITE.erl b/test/wapi_withdrawal_tests_SUITE.erl index 7c43da6..1e1c3c0 100644 --- a/test/wapi_withdrawal_tests_SUITE.erl +++ b/test/wapi_withdrawal_tests_SUITE.erl @@ -41,6 +41,7 @@ get_failed_wo_colon/1, get_fail_withdrawal_notfound/1, get_by_external_id_ok/1, + get_with_new_body_ok/1, create_quote_ok/1, get_quote_fail_wallet_notfound/1, get_quote_fail_destination_notfound/1, @@ -90,6 +91,7 @@ groups() -> get_failed_wo_colon, get_fail_withdrawal_notfound, get_by_external_id_ok, + get_with_new_body_ok, create_quote_ok, get_quote_fail_wallet_notfound, get_quote_fail_destination_notfound, @@ -436,6 +438,38 @@ get_by_external_id_ok(C) -> wapi_ct_helper:cfg(context, C) ). +-spec get_with_new_body_ok(config()) -> _. +get_with_new_body_ok(C) -> + PartyID = ?config(party, C), + Withdrawal0 = ?WITHDRAWAL(PartyID), + Withdrawal = Withdrawal0#wthd_WithdrawalState{ + new_body = ?CASH(100500) + }, + _ = wapi_ct_helper_bouncer:mock_assert_withdrawal_op_ctx(<<"GetWithdrawal">>, ?STRING, PartyID, C), + _ = wapi_ct_helper:mock_services( + [ + {fistful_withdrawal, fun + ('GetContext', _) -> {ok, ?DEFAULT_CONTEXT(PartyID)}; + ('Get', _) -> {ok, Withdrawal} + end} + ], + C + ), + {ok, #{ + <<"body">> := #{ + <<"amount">> := 100500, + <<"currency">> := <<"RUB">> + } + }} = call_api( + fun swag_client_wallet_withdrawals_api:get_withdrawal/3, + #{ + binding => #{ + <<"withdrawalID">> => ?STRING + } + }, + wapi_ct_helper:cfg(context, C) + ). + -spec create_quote_ok(config()) -> _. create_quote_ok(C) -> _ = get_quote_start_mocks(C, fun() -> {ok, ?WITHDRAWAL_QUOTE} end), From 6ca6032a7f36bd76affa7385f04b2b9a7060d01d Mon Sep 17 00:00:00 2001 From: ttt161 Date: Wed, 19 Aug 2026 10:16:11 +0300 Subject: [PATCH 2/2] cleanup --- rebar.config | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/rebar.config b/rebar.config index 792868d..4f457f9 100644 --- a/rebar.config +++ b/rebar.config @@ -45,8 +45,7 @@ {token_keeper_client, {git, "https://github.com/valitydev/token-keeper-client.git", {tag, "v1.1.0"}}}, {uac, {git, "https://github.com/valitydev/erlang_uac.git", {branch, master}}}, {tds_proto, {git, "https://github.com/valitydev/tds-proto.git", {branch, master}}}, - %{opentelemetry_api, "1.4.0"}, - {opentelemetry_api, {git, "https://github.com/open-telemetry/opentelemetry-erlang.git", {tag, "v1.4.0"}}}, + {opentelemetry_api, "1.4.0"}, %% NOTE %% Pinning to version "1.11.2" from hex here causes constant upgrading and recompilation of the entire project @@ -80,8 +79,7 @@ %% Libraries generated with swagger-codegen-erlang from valitydev/swag-wallets {swag_server_wallet, {git, "https://github.com/valitydev/swag-wallets", {ref, "8cd59f5"}}}, {swag_client_wallet, {git, "https://github.com/valitydev/swag-wallets", {ref, "2b52418"}}}, - %{meck, "0.9.2"} - {meck, {git, "https://github.com/eproxus/meck.git", {tag, "0.9.2"}}} + {meck, "0.9.2"} ]}, {cover_enabled, true}, {cover_excl_apps, [ @@ -93,12 +91,9 @@ ]}. {project_plugins, [ - %{rebar3_lint, "3.2.6"}, - %{erlfmt, "1.5.0"}, - %{covertool, "2.0.7"} - {rebar3_lint, {git, "https://github.com/project-fifo/rebar3_lint.git", {tag, "3.2.6"}}}, - {erlfmt, {git, "https://github.com/WhatsApp/erlfmt.git", {tag, "v1.5.0"}}}, - {covertool, {git, "https://github.com/covertool/covertool.git", {tag, "2.0.7"}}} + {rebar3_lint, "3.2.6"}, + {erlfmt, "1.5.0"}, + {covertool, "2.0.7"} ]}. %% Linter config.