diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-01-03 01:10:23 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-01-03 01:10:23 +0100 |
commit | d9f16db0efca71d47455ee2efab7eabf4003a0a0 (patch) | |
tree | 83662bce8342dd5778ad53595d2e47a7896788ae /src/exchangedb | |
parent | 41b5dde70945b6cb468e412caf6ab7ecd7f56651 (diff) |
add testcase for 'select_refunds_by_coin'
Diffstat (limited to 'src/exchangedb')
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 2 | ||||
-rw-r--r-- | src/exchangedb/test_exchangedb.c | 73 |
2 files changed, 73 insertions, 2 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 9c91259ba..7e1ef54eb 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -3082,7 +3082,7 @@ get_refunds_cb (void *cls, &merchant_pub), GNUNET_PQ_result_spec_auto_from_type ("merchant_sig", &merchant_sig), - GNUNET_PQ_result_spec_auto_from_type ("h_contract", + GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms", &h_contract), GNUNET_PQ_result_spec_uint64 ("rtransaction_id", &rtransaction_id), diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 5891a08a0..62ff2a743 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -1394,6 +1394,72 @@ wire_missing_cb (void *cls, /** + * Callback invoked with information about refunds applicable + * to a particular coin. + * + * @param cls closure with the `struct TALER_EXCHANGEDB_Refund *` we expect to get + * @param merchant_pub public key of merchant who authorized refund + * @param merchant_sig signature of merchant authorizing refund + * @param h_contract hash of contract being refunded + * @param rtransaction_id refund transaction ID + * @param amount_with_fee amount being refunded + * @param refund_fee fee the exchange keeps for the refund processing + * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop + */ +static int +check_refund_cb (void *cls, + const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct TALER_MerchantSignatureP *merchant_sig, + const struct GNUNET_HashCode *h_contract, + uint64_t rtransaction_id, + const struct TALER_Amount *amount_with_fee, + const struct TALER_Amount *refund_fee) +{ + const struct TALER_EXCHANGEDB_Refund *refund = cls; + + if (0 != memcmp (merchant_pub, + &refund->merchant_pub, + sizeof (struct TALER_MerchantPublicKeyP))) + { + GNUNET_break (0); + result = 66; + } + if (0 != memcmp (merchant_sig, + &refund->merchant_sig, + sizeof (struct TALER_MerchantSignatureP))) + { + GNUNET_break (0); + result = 66; + } + if (0 != memcmp (h_contract, + &refund->h_contract_terms, + sizeof (struct GNUNET_HashCode))) + { + GNUNET_break (0); + result = 66; + } + if (rtransaction_id != refund->rtransaction_id) + { + GNUNET_break (0); + result = 66; + } + if (0 != TALER_amount_cmp (amount_with_fee, + &refund->refund_amount)) + { + GNUNET_break (0); + result = 66; + } + if (0 != TALER_amount_cmp (refund_fee, + &refund->refund_fee)) + { + GNUNET_break (0); + result = 66; + } + return GNUNET_OK; +} + + +/** * Main function that will be run by the scheduler. * * @param cls closure with config @@ -1897,7 +1963,12 @@ run (void *cls) plugin->insert_refund (plugin->cls, session, &refund)); - + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->select_refunds_by_coin (plugin->cls, + session, + &refund.coin.coin_pub, + &check_refund_cb, + &refund)); /* test payback / revocation */ RND_BLK (&master_sig); |