summaryrefslogtreecommitdiff
path: root/src/mint-lib/test_mint_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-07-09 12:47:49 +0200
committerChristian Grothoff <christian@grothoff.org>2015-07-09 12:47:49 +0200
commita24171d0fadbed579985e0267670ce524a1a5ab8 (patch)
treee2d70c12753886f7f9de48f65579b5305b1ed50f /src/mint-lib/test_mint_api.c
parent8b91516fc37ddb5883c4fff59d84d5c245a7afa7 (diff)
downloadexchange-a24171d0fadbed579985e0267670ce524a1a5ab8.tar.gz
exchange-a24171d0fadbed579985e0267670ce524a1a5ab8.tar.bz2
exchange-a24171d0fadbed579985e0267670ce524a1a5ab8.zip
fix mint to actually include signature in deposit error reply
Diffstat (limited to 'src/mint-lib/test_mint_api.c')
-rw-r--r--src/mint-lib/test_mint_api.c60
1 files changed, 57 insertions, 3 deletions
diff --git a/src/mint-lib/test_mint_api.c b/src/mint-lib/test_mint_api.c
index c99b4be49..acbe441b5 100644
--- a/src/mint-lib/test_mint_api.c
+++ b/src/mint-lib/test_mint_api.c
@@ -503,6 +503,10 @@ withdraw_status_cb (void *cls,
cmd->details.withdraw_status.wsh = NULL;
if (cmd->expected_response_code != http_status)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected response code %u to command %s\n",
+ http_status,
+ cmd->label);
GNUNET_break (0);
fail (is);
return;
@@ -575,7 +579,7 @@ withdraw_status_cb (void *cls,
return;
}
}
- /* FIXME: support other status codes! */
+ break;
default:
/* Unsupported status code (by test harness) */
GNUNET_break (0);
@@ -608,6 +612,10 @@ withdraw_sign_cb (void *cls,
cmd->details.withdraw_sign.wsh = NULL;
if (cmd->expected_response_code != http_status)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected response code %u to command %s\n",
+ http_status,
+ cmd->label);
GNUNET_break (0);
fail (is);
return;
@@ -624,7 +632,9 @@ withdraw_sign_cb (void *cls,
cmd->details.withdraw_sign.sig.rsa_signature
= GNUNET_CRYPTO_rsa_signature_dup (sig->rsa_signature);
break;
- /* FIXME: support other status codes here */
+ case MHD_HTTP_PAYMENT_REQUIRED:
+ /* nothing to check */
+ break;
default:
/* Unsupported status code (by test harness) */
GNUNET_break (0);
@@ -656,7 +666,10 @@ deposit_cb (void *cls,
cmd->details.deposit.dh = NULL;
if (cmd->expected_response_code != http_status)
{
- GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected response code %u to command %s\n",
+ http_status,
+ cmd->label);
fail (is);
return;
}
@@ -1235,16 +1248,20 @@ run (void *cls,
.expected_response_code = MHD_HTTP_OK,
.details.admin_add_incoming.wire = "{ \"type\":\"TEST\", \"bank\":\"source bank\", \"account\":42 }",
.details.admin_add_incoming.amount = "EUR:5.01" },
+ /* Withdraw a 5 EUR coin, at fee of 1 ct */
{ .oc = OC_WITHDRAW_SIGN,
.label = "withdraw-coin-1",
.expected_response_code = MHD_HTTP_OK,
.details.withdraw_sign.reserve_reference = "create-reserve-1",
.details.withdraw_sign.amount = "EUR:5" },
+ /* Check that deposit and withdraw operation are in history, and
+ that the balance is now at zero */
{ .oc = OC_WITHDRAW_STATUS,
.label = "withdraw-status-1",
.expected_response_code = MHD_HTTP_OK,
.details.withdraw_status.reserve_reference = "create-reserve-1",
.details.withdraw_status.expected_balance = "EUR:0" },
+ /* Try to deposit the 5 EUR coin (in full) */
{ .oc = OC_DEPOSIT,
.label = "deposit-simple",
.expected_response_code = MHD_HTTP_OK,
@@ -1253,6 +1270,43 @@ run (void *cls,
.details.deposit.wire_details = "{ \"type\":\"TEST\", \"bank\":\"dest bank\", \"account\":42 }",
.details.deposit.contract = "{ \"items\"={ \"name\":\"ice cream\", \"value\":1 } }",
.details.deposit.transaction_id = 1 },
+
+ /* Try to overdraw funds ... */
+ { .oc = OC_WITHDRAW_SIGN,
+ .label = "withdraw-coin-2",
+ .expected_response_code = MHD_HTTP_PAYMENT_REQUIRED,
+ .details.withdraw_sign.reserve_reference = "create-reserve-1",
+ .details.withdraw_sign.amount = "EUR:5" },
+ /* Try to double-spend the 5 EUR coin with different wire details */
+ { .oc = OC_DEPOSIT,
+ .label = "deposit-double-1",
+ .expected_response_code = MHD_HTTP_FORBIDDEN,
+ .details.deposit.amount = "EUR:5",
+ .details.deposit.coin_ref = "withdraw-coin-1",
+ .details.deposit.wire_details = "{ \"type\":\"TEST\", \"bank\":\"dest bank\", \"account\":43 }",
+ .details.deposit.contract = "{ \"items\"={ \"name\":\"ice cream\", \"value\":1 } }",
+ .details.deposit.transaction_id = 1 },
+ /* Try to double-spend the 5 EUR coin at the same merchant (but different
+ transaction ID) */
+ { .oc = OC_DEPOSIT,
+ .label = "deposit-double-2",
+ .expected_response_code = MHD_HTTP_FORBIDDEN,
+ .details.deposit.amount = "EUR:5",
+ .details.deposit.coin_ref = "withdraw-coin-1",
+ .details.deposit.wire_details = "{ \"type\":\"TEST\", \"bank\":\"dest bank\", \"account\":42 }",
+ .details.deposit.contract = "{ \"items\"={ \"name\":\"ice cream\", \"value\":1 } }",
+ .details.deposit.transaction_id = 2 },
+ /* Try to double-spend the 5 EUR coin at the same merchant (but different
+ contract) */
+ { .oc = OC_DEPOSIT,
+ .label = "deposit-double-3",
+ .expected_response_code = MHD_HTTP_FORBIDDEN,
+ .details.deposit.amount = "EUR:5",
+ .details.deposit.coin_ref = "withdraw-coin-1",
+ .details.deposit.wire_details = "{ \"type\":\"TEST\", \"bank\":\"dest bank\", \"account\":42 }",
+ .details.deposit.contract = "{ \"items\"={ \"name\":\"ice cream\", \"value\":2 } }",
+ .details.deposit.transaction_id = 1 },
+
{ .oc = OC_END }
};