diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-06-04 21:59:55 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-06-04 22:00:02 +0200 |
commit | a17781ba8d5f875b5150e524174c5f144aa6c0ba (patch) | |
tree | c01f11a3810428471e6399b4961942732a21a1f1 /src/testing | |
parent | 6512456dc2559577867fdce1f7fe7f1b5a12291f (diff) | |
download | exchange-a17781ba8d5f875b5150e524174c5f144aa6c0ba.tar.xz |
-more work on p2p payments and tests thereof
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/Makefile.am | 8 | ||||
-rw-r--r-- | src/testing/test_exchange_p2p.c | 16 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_purse_deposit.c | 29 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_reserve_purse.c | 2 |
4 files changed, 32 insertions, 23 deletions
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am index fefb7c984..7da713beb 100644 --- a/src/testing/Makefile.am +++ b/src/testing/Makefile.am @@ -127,10 +127,6 @@ libtalertesting_la_LIBADD = \ AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH; -noinst_PROGRAMS = \ - test_exchange_p2p_cs \ - test_exchange_p2p_rsa - .NOTPARALLEL: check_PROGRAMS = \ @@ -152,7 +148,9 @@ check_PROGRAMS = \ test_exchange_management_api_rsa \ test_kyc_api \ test_taler_exchange_aggregator-postgres \ - test_taler_exchange_wirewatch-postgres + test_taler_exchange_wirewatch-postgres \ + test_exchange_p2p_cs \ + test_exchange_p2p_rsa if HAVE_TWISTER check_PROGRAMS += \ test_exchange_api_twisted_cs \ diff --git a/src/testing/test_exchange_p2p.c b/src/testing/test_exchange_p2p.c index 647c56c8f..ba6d5bbf2 100644 --- a/src/testing/test_exchange_p2p.c +++ b/src/testing/test_exchange_p2p.c @@ -116,16 +116,16 @@ run (void *cls, * Move money to the exchange's bank account. */ CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1", - "EUR:5.01"), + "EUR:5.04"), CMD_TRANSFER_TO_EXCHANGE ("create-reserve-2", "EUR:5.01"), TALER_TESTING_cmd_reserve_poll ("poll-reserve-1", "create-reserve-1", - "EUR:5.01", + "EUR:5.04", GNUNET_TIME_UNIT_MINUTES, MHD_HTTP_OK), TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1", - "EUR:5.01", + "EUR:5.04", bc.user42_payto, bc.exchange_payto, "create-reserve-1"), @@ -155,7 +155,7 @@ run (void *cls, */ TALER_TESTING_cmd_status ("status-1", "create-reserve-1", - "EUR:0", + "EUR:0.03", MHD_HTTP_OK), TALER_TESTING_cmd_end () }; @@ -195,13 +195,13 @@ run (void *cls, TALER_TESTING_cmd_status ( "push-check-post-merge-reserve-balance-get", "create-reserve-1", - "EUR:1", + "EUR:1.03", MHD_HTTP_OK), /* POST history doesn't yet support P2P transfers */ TALER_TESTING_cmd_reserve_status ( "push-check-post-merge-reserve-balance-post", "create-reserve-1", - "EUR:1", + "EUR:1.03", MHD_HTTP_OK), /* Test conflicting merge */ TALER_TESTING_cmd_purse_merge ( @@ -249,13 +249,13 @@ run (void *cls, TALER_TESTING_cmd_status ( "pull-check-post-merge-reserve-balance-get", "create-reserve-1", - "EUR:2", + "EUR:2.02", MHD_HTTP_OK), /* POST history doesn't yet support P2P transfers */ TALER_TESTING_cmd_reserve_status ( "push-check-post-merge-reserve-balance-post", "create-reserve-1", - "EUR:2", + "EUR:2.02", MHD_HTTP_OK), /* create 2nd purse for a deposit conflict */ TALER_TESTING_cmd_purse_create_with_reserve ( diff --git a/src/testing/testing_api_cmd_purse_deposit.c b/src/testing/testing_api_cmd_purse_deposit.c index fa1b900da..0fa0998d2 100644 --- a/src/testing/testing_api_cmd_purse_deposit.c +++ b/src/testing/testing_api_cmd_purse_deposit.c @@ -201,9 +201,6 @@ deposit_cb (void *cls, /* Deposits complete, create trait! */ ds->reserve_history.type = TALER_EXCHANGE_RTT_MERGE; - ds->reserve_history.amount - = dr->details.success.purse_value_after_fees; -#if 0 { const struct TALER_EXCHANGE_Keys *keys; const struct TALER_EXCHANGE_GlobalFee *gf; @@ -213,12 +210,26 @@ deposit_cb (void *cls, gf = TALER_EXCHANGE_get_global_fee (keys, *merge_timestamp); GNUNET_assert (NULL != gf); + + /* Note: change when flags below changes! */ + if (true) + { + /* If we paid a purse fee, we need to subtract the + purse fee from the reserve history amount */ + TALER_amount_subtract (&ds->reserve_history.amount, + &dr->details.success.purse_value_after_fees, + &gf->fees.purse); + ds->reserve_history.details.merge_details.purse_fee = gf->fees.purse; + } + else + { + ds->reserve_history.amount + = dr->details.success.purse_value_after_fees; + TALER_amount_set_zero ( + ds->reserve_history.amount.currency, + &ds->reserve_history.details.merge_details.purse_fee); + } } -#endif - /* Note: change when flags below changes! */ - TALER_amount_set_zero ( - ds->reserve_history.amount.currency, - &ds->reserve_history.details.merge_details.purse_fee); ds->reserve_history.details.merge_details.h_contract_terms = dr->details.success.h_contract_terms; ds->reserve_history.details.merge_details.merge_pub @@ -234,7 +245,7 @@ deposit_cb (void *cls, ds->reserve_history.details.merge_details.min_age = ds->min_age; ds->reserve_history.details.merge_details.flags - = TALER_WAMF_MODE_CREATE_FROM_PURSE_QUOTA; + = TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE; ds->purse_complete = true; } } diff --git a/src/testing/testing_api_cmd_reserve_purse.c b/src/testing/testing_api_cmd_reserve_purse.c index 42aff80e3..4106600cb 100644 --- a/src/testing/testing_api_cmd_reserve_purse.c +++ b/src/testing/testing_api_cmd_reserve_purse.c @@ -208,7 +208,7 @@ purse_run (void *cls, &ds->contract_priv, ds->contract_terms, true /* upload contract */, - false /* do not pay purse fee -- FIXME: make this a choice to test this case; then update testing_api_cmd_purse_deposit flags logic to match! */, + true /* do pay purse fee -- FIXME: make this a choice to test this case; then update testing_api_cmd_purse_deposit flags logic to match! */, ds->merge_timestamp, &purse_cb, ds); |