diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-05-23 14:57:00 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-05-23 14:57:00 +0200 |
commit | cdd2930a9951a552d221b8a8b8e9c0df35ad8be2 (patch) | |
tree | 2389f0cad26e47d2315650f2f9e698120c5f2182 /src/testing | |
parent | 2035294adbcafc93c70d2cb7d27ce1a74d5a61ca (diff) | |
download | exchange-cdd2930a9951a552d221b8a8b8e9c0df35ad8be2.tar.xz |
-misc fixes to reserve history
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/test_exchange_p2p.c | 8 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_purse_deposit.c | 17 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_purse_merge.c | 14 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_reserve_history.c | 11 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_reserve_purse.c | 8 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_reserve_status.c | 17 |
6 files changed, 58 insertions, 17 deletions
diff --git a/src/testing/test_exchange_p2p.c b/src/testing/test_exchange_p2p.c index 50422b2c9..aad0465b7 100644 --- a/src/testing/test_exchange_p2p.c +++ b/src/testing/test_exchange_p2p.c @@ -197,14 +197,12 @@ run (void *cls, "create-reserve-1", "EUR:1", MHD_HTTP_OK), -#if FIXME /* POST history doesn't yet support P2P transfers */ - TALER_TESTING_cmd_reserves_status ( + TALER_TESTING_cmd_reserve_status ( "push-check-post-merge-reserve-balance-post", "create-reserve-1", "EUR:1", MHD_HTTP_OK), -#endif /* Test conflicting merge */ TALER_TESTING_cmd_purse_merge ( "purse-merge-into-reserve", @@ -374,8 +372,6 @@ run (void *cls, "payto://x-taler-bank/localhost/2", MHD_HTTP_NO_CONTENT, false), - TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys", - config_file), TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-wire-fees", config_file, "EUR:0.01", @@ -391,6 +387,8 @@ run (void *cls, GNUNET_TIME_UNIT_MINUTES, GNUNET_TIME_UNIT_DAYS, 1), + TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys", + config_file), TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", 1), TALER_TESTING_cmd_batch ("withdraw", diff --git a/src/testing/testing_api_cmd_purse_deposit.c b/src/testing/testing_api_cmd_purse_deposit.c index b15ba97cf..86ed1b185 100644 --- a/src/testing/testing_api_cmd_purse_deposit.c +++ b/src/testing/testing_api_cmd_purse_deposit.c @@ -73,6 +73,12 @@ struct PurseDepositState struct TALER_PurseContractPublicKeyP purse_pub; /** + * The reserve we are being deposited into. + * Set as a trait once we know the reserve. + */ + struct TALER_ReservePublicKeyP reserve_pub; + + /** * PurseDeposit handle while operation is running. */ struct TALER_EXCHANGE_PurseDepositHandle *dh; @@ -151,6 +157,7 @@ deposit_cb (void *cls, { const struct TALER_TESTING_Command *purse_cmd; const struct TALER_ReserveSignatureP *reserve_sig; + const struct TALER_ReservePublicKeyP *reserve_pub; const struct GNUNET_TIME_Timestamp *merge_timestamp; purse_cmd = TALER_TESTING_interpreter_lookup_command (ds->is, @@ -165,6 +172,15 @@ deposit_cb (void *cls, return; } if (GNUNET_OK != + TALER_TESTING_get_trait_reserve_pub (purse_cmd, + &reserve_pub)) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (ds->is); + return; + } + ds->reserve_pub = *reserve_pub; + if (GNUNET_OK != TALER_TESTING_get_trait_timestamp (purse_cmd, 0, &merge_timestamp)) @@ -370,6 +386,7 @@ deposit_traits (void *cls, struct TALER_TESTING_Trait traits[] = { /* history entry MUST be first due to response code logic below! */ TALER_TESTING_make_trait_reserve_history (&ds->reserve_history), + TALER_TESTING_make_trait_reserve_pub (&ds->reserve_pub), TALER_TESTING_make_trait_purse_pub (&ds->purse_pub), TALER_TESTING_trait_end () }; diff --git a/src/testing/testing_api_cmd_purse_merge.c b/src/testing/testing_api_cmd_purse_merge.c index 456ba66fc..50e0ac1bc 100644 --- a/src/testing/testing_api_cmd_purse_merge.c +++ b/src/testing/testing_api_cmd_purse_merge.c @@ -131,21 +131,16 @@ merge_cb (void *cls, ds->dh = NULL; if (MHD_HTTP_OK == dr->hr.http_status) { - const struct TALER_EXCHANGE_Keys *keys; - const struct TALER_EXCHANGE_GlobalFee *gf; - ds->reserve_history.type = TALER_EXCHANGE_RTT_MERGE; - keys = TALER_EXCHANGE_get_keys (ds->is->exchange); - GNUNET_assert (NULL != keys); - gf = TALER_EXCHANGE_get_global_fee (keys, - ds->merge_timestamp); - GNUNET_assert (NULL != gf); ds->reserve_history.amount = ds->value_after_fees; - ds->reserve_history.details.merge_details.purse_fee = gf->fees.purse; + TALER_amount_set_zero (ds->value_after_fees.currency, + &ds->reserve_history.details.merge_details.purse_fee); ds->reserve_history.details.merge_details.h_contract_terms = ds->h_contract_terms; ds->reserve_history.details.merge_details.merge_pub = ds->merge_pub; + ds->reserve_history.details.merge_details.purse_pub + = ds->purse_pub; ds->reserve_history.details.merge_details.reserve_sig = *dr->reserve_sig; ds->reserve_history.details.merge_details.merge_timestamp @@ -356,6 +351,7 @@ merge_traits (void *cls, struct TALER_TESTING_Trait traits[] = { /* history entry MUST be first due to response code logic below! */ TALER_TESTING_make_trait_reserve_history (&ds->reserve_history), + TALER_TESTING_make_trait_reserve_pub (&ds->reserve_pub), TALER_TESTING_make_trait_timestamp (0, &ds->merge_timestamp), TALER_TESTING_trait_end () diff --git a/src/testing/testing_api_cmd_reserve_history.c b/src/testing/testing_api_cmd_reserve_history.c index ec190d5ce..6cee5af15 100644 --- a/src/testing/testing_api_cmd_reserve_history.c +++ b/src/testing/testing_api_cmd_reserve_history.c @@ -122,7 +122,12 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub, history_length, history, found)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Entry for batch step `%s' missing in history\n", + step->label); return GNUNET_SYSERR; + } } return GNUNET_OK; } @@ -251,6 +256,9 @@ reserve_history_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Entry for command `%s' missing in history\n", cmd->label); + json_dumpf (rs->hr.reply, + stderr, + JSON_INDENT (2)); TALER_TESTING_interpreter_fail (ss->is); return; } @@ -262,6 +270,9 @@ reserve_history_cb (void *cls, "History entry at index %u of type %d not justified by command history\n", i, rs->details.ok.history[i].type); + json_dumpf (rs->hr.reply, + stderr, + JSON_INDENT (2)); TALER_TESTING_interpreter_fail (ss->is); return; } diff --git a/src/testing/testing_api_cmd_reserve_purse.c b/src/testing/testing_api_cmd_reserve_purse.c index b57fff2bd..ffdd00053 100644 --- a/src/testing/testing_api_cmd_reserve_purse.c +++ b/src/testing/testing_api_cmd_reserve_purse.c @@ -47,6 +47,11 @@ struct ReservePurseState struct TALER_ReservePrivateKeyP reserve_priv; /** + * Reserve public key. + */ + struct TALER_ReservePublicKeyP reserve_pub; + + /** * Reserve signature generated for the request * (client-side). */ @@ -176,6 +181,8 @@ purse_run (void *cls, GNUNET_CRYPTO_eddsa_key_create (&ds->purse_priv.eddsa_priv); GNUNET_CRYPTO_eddsa_key_get_public (&ds->purse_priv.eddsa_priv, &ds->purse_pub.eddsa_pub); + GNUNET_CRYPTO_eddsa_key_get_public (&ds->reserve_priv.eddsa_priv, + &ds->reserve_pub.eddsa_pub); GNUNET_CRYPTO_eddsa_key_create (&ds->merge_priv.eddsa_priv); GNUNET_CRYPTO_ecdhe_key_create (&ds->contract_priv.ecdhe_priv); ds->purse_expiration = GNUNET_TIME_absolute_to_timestamp ( @@ -261,6 +268,7 @@ purse_traits (void *cls, TALER_TESTING_make_trait_merge_priv (&ds->merge_priv), TALER_TESTING_make_trait_contract_priv (&ds->contract_priv), TALER_TESTING_make_trait_reserve_priv (&ds->reserve_priv), + TALER_TESTING_make_trait_reserve_pub (&ds->reserve_pub), TALER_TESTING_make_trait_reserve_sig (&ds->reserve_sig), TALER_TESTING_trait_end () }; diff --git a/src/testing/testing_api_cmd_reserve_status.c b/src/testing/testing_api_cmd_reserve_status.c index 63f50772f..1d104cc3e 100644 --- a/src/testing/testing_api_cmd_reserve_status.c +++ b/src/testing/testing_api_cmd_reserve_status.c @@ -87,7 +87,7 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_TESTING_Command *cmd, unsigned int history_length, const struct TALER_EXCHANGE_ReserveHistoryEntry *history, - int *found) + bool *found) { if (TALER_TESTING_cmd_is_batch (cmd)) { @@ -114,7 +114,12 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub, history_length, history, found)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Entry for batch step `%s' missing in history\n", + step->label); return GNUNET_SYSERR; + } } return GNUNET_OK; } @@ -186,7 +191,7 @@ reserve_status_cb (void *cls, __LINE__); json_dumpf (rs->hr.reply, stderr, - 0); + JSON_INDENT (2)); TALER_TESTING_interpreter_fail (ss->is); return; } @@ -209,7 +214,7 @@ reserve_status_cb (void *cls, return; } { - int found[rs->details.ok.history_len]; + bool found[rs->details.ok.history_len]; memset (found, 0, @@ -228,6 +233,9 @@ reserve_status_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Entry for command `%s' missing in history\n", cmd->label); + json_dumpf (rs->hr.reply, + stderr, + JSON_INDENT (2)); TALER_TESTING_interpreter_fail (ss->is); return; } @@ -239,6 +247,9 @@ reserve_status_cb (void *cls, "History entry at index %u of type %d not justified by command status\n", i, rs->details.ok.history[i].type); + json_dumpf (rs->hr.reply, + stderr, + JSON_INDENT (2)); TALER_TESTING_interpreter_fail (ss->is); return; } |