summaryrefslogtreecommitdiff
path: root/src/backenddb/test_merchantdb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backenddb/test_merchantdb.c')
-rw-r--r--src/backenddb/test_merchantdb.c124
1 files changed, 45 insertions, 79 deletions
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index 4c2ef5c9..94f47f70 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -304,9 +304,6 @@ lookup_instances_cb (void *cls,
}
-
-
-
/**
* Tests @e insert_instance.
*
@@ -2359,6 +2356,11 @@ struct DepositData
struct TALER_CoinSpendPublicKeyP coin_pub;
/**
+ * Signature of the coin that has been deposited.
+ */
+ struct TALER_CoinSpendSignatureP coin_sig;
+
+ /**
* URL of the exchange.
*/
const char *exchange_url;
@@ -2397,39 +2399,6 @@ struct DepositData
/**
- * Private key for my_sign_cb().
- */
-static const struct TALER_ExchangePrivateKeyP *msc_exchange_priv;
-
-/**
- * Function that signs the message in @a purpose with the
- * exchange's signing key from #msc_exchange_priv.
- *
- * The @a purpose data is the beginning of the data of which the signature is
- * to be created. The `size` field in @a purpose must correctly indicate the
- * number of bytes of the data structure, including its header. *
- * @param purpose the message to sign
- * @param[out] pub set to the current public signing key of the exchange
- * @param[out] sig signature over purpose using current signing key
- * @return #TALER_EC_NONE on success
- */
-static enum TALER_ErrorCode
-my_sign_cb (
- const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
- struct TALER_ExchangePublicKeyP *pub,
- struct TALER_ExchangeSignatureP *sig)
-{
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_eddsa_sign_ (&msc_exchange_priv->eddsa_priv,
- purpose,
- &sig->eddsa_signature));
- GNUNET_CRYPTO_eddsa_key_get_public (&msc_exchange_priv->eddsa_priv,
- &pub->eddsa_pub);
- return TALER_EC_NONE;
-}
-
-
-/**
* Generates deposit data for an order.
*
* @param instance the instance to make the deposit to.
@@ -2448,7 +2417,6 @@ make_deposit (const struct InstanceData *instance,
struct TALER_CoinSpendPrivateKeyP coin_priv;
struct GNUNET_TIME_Timestamp now;
struct TALER_Amount amount_without_fee;
- struct TALER_ExchangePublicKeyP exchange_pub;
now = GNUNET_TIME_timestamp_get ();
deposit->timestamp = now;
@@ -2476,22 +2444,12 @@ make_deposit (const struct InstanceData *instance,
&deposit->amount_with_fee,
&deposit->deposit_fee));
deposit->h_wire = account->h_wire;
- msc_exchange_priv = &signkey->exchange_priv;
- GNUNET_assert (TALER_EC_NONE ==
- TALER_exchange_online_deposit_confirmation_sign (
- &my_sign_cb,
- &deposit->h_contract_terms,
- &deposit->h_wire,
- NULL,
- now,
- now,
- now,
- &amount_without_fee,
- &deposit->coin_pub,
- &instance->merchant_pub,
- &exchange_pub,
- &deposit->exchange_sig));
- msc_exchange_priv = NULL;
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
+ &deposit->exchange_sig,
+ sizeof (deposit->exchange_sig));
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
+ &deposit->coin_sig,
+ sizeof (deposit->coin_sig));
}
@@ -2534,21 +2492,38 @@ test_insert_deposit (const struct InstanceData *instance,
const struct DepositData *deposit,
enum GNUNET_DB_QueryStatus expected_result)
{
- TEST_COND_RET_ON_FAIL (expected_result ==
- plugin->insert_deposit (plugin->cls,
- instance->instance.id,
- deposit->timestamp,
- &deposit->h_contract_terms,
- &deposit->coin_pub,
- deposit->exchange_url,
- &deposit->amount_with_fee,
- &deposit->deposit_fee,
- &deposit->refund_fee,
- &deposit->wire_fee,
- &deposit->h_wire,
- &deposit->exchange_sig,
- &signkey->exchange_pub),
- "Insert deposit failed\n");
+ uint64_t row;
+ struct TALER_Amount awf;
+
+ GNUNET_assert (0 <=
+ TALER_amount_subtract (&awf,
+ &deposit->amount_with_fee,
+ &deposit->deposit_fee));
+ TEST_COND_RET_ON_FAIL (
+ expected_result ==
+ plugin->insert_deposit_confirmation (plugin->cls,
+ instance->instance.id,
+ deposit->timestamp,
+ &deposit->h_contract_terms,
+ deposit->exchange_url,
+ &awf,
+ &deposit->wire_fee,
+ &deposit->h_wire,
+ &deposit->exchange_sig,
+ &signkey->exchange_pub,
+ &row),
+ "Insert deposit confirmation failed\n");
+ TEST_COND_RET_ON_FAIL (
+ expected_result ==
+ plugin->insert_deposit (plugin->cls,
+ 0,
+ row,
+ &deposit->coin_pub,
+ &deposit->coin_sig,
+ &deposit->amount_with_fee,
+ &deposit->deposit_fee,
+ &deposit->refund_fee),
+ "Insert deposit failed\n");
return 0;
}
@@ -2588,7 +2563,6 @@ struct TestLookupDeposits_Closure
* @param amount_with_fee amount of the deposit with fees.
* @param deposit_fee fee charged for the deposit.
* @param refund_fee fee charged in case of a refund.
- * @param wire_fee fee charged when the money is wired.
*/
static void
lookup_deposits_cb (void *cls,
@@ -2596,8 +2570,7 @@ lookup_deposits_cb (void *cls,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *amount_with_fee,
const struct TALER_Amount *deposit_fee,
- const struct TALER_Amount *refund_fee,
- const struct TALER_Amount *wire_fee)
+ const struct TALER_Amount *refund_fee)
{
struct TestLookupDeposits_Closure *cmp = cls;
if (NULL == cmp)
@@ -2625,14 +2598,7 @@ lookup_deposits_cb (void *cls,
refund_fee)) &&
(0 ==
TALER_amount_cmp (&cmp->deposits_to_cmp[i].refund_fee,
- refund_fee)) &&
- (GNUNET_OK ==
- TALER_amount_cmp_currency (
- &cmp->deposits_to_cmp[i].wire_fee,
- wire_fee)) &&
- (0 ==
- TALER_amount_cmp (&cmp->deposits_to_cmp[i].wire_fee,
- wire_fee)))
+ refund_fee)))
{
cmp->results_matching[i] += 1;
}