2018-01-21 15:39:48 +01:00
|
|
|
/*
|
|
|
|
This file is part of TALER
|
2020-01-13 00:27:48 +01:00
|
|
|
Copyright (C) 2014--2020 Taler Systems SA
|
2018-01-21 15:39:48 +01:00
|
|
|
|
2018-01-23 10:28:24 +01:00
|
|
|
TALER is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as
|
|
|
|
published by the Free Software Foundation; either version 3, or
|
|
|
|
(at your option) any later version.
|
2018-01-21 15:39:48 +01:00
|
|
|
|
2018-01-23 10:28:24 +01:00
|
|
|
TALER is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2018-01-21 15:39:48 +01:00
|
|
|
|
2018-01-23 10:28:24 +01:00
|
|
|
You should have received a copy of the GNU General Public
|
|
|
|
License along with TALER; see the file COPYING. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>
|
2018-01-21 15:39:48 +01:00
|
|
|
*/
|
|
|
|
/**
|
2020-01-13 00:27:48 +01:00
|
|
|
* @file lib/test_exchange_api.c
|
2018-01-21 15:39:48 +01:00
|
|
|
* @brief testcase to test exchange's HTTP API interface
|
|
|
|
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
|
|
|
|
* @author Christian Grothoff
|
2018-01-23 10:28:24 +01:00
|
|
|
* @author Marcello Stanisci
|
2018-01-21 15:39:48 +01:00
|
|
|
*/
|
|
|
|
#include "platform.h"
|
|
|
|
#include "taler_util.h"
|
|
|
|
#include "taler_signatures.h"
|
|
|
|
#include "taler_exchange_service.h"
|
|
|
|
#include "taler_json_lib.h"
|
|
|
|
#include <gnunet/gnunet_util_lib.h>
|
|
|
|
#include <microhttpd.h>
|
|
|
|
#include "taler_bank_service.h"
|
|
|
|
#include "taler_fakebank_lib.h"
|
|
|
|
#include "taler_testing_lib.h"
|
|
|
|
|
|
|
|
/**
|
2018-01-21 20:10:05 +01:00
|
|
|
* Configuration file we use. One (big) configuration is used
|
|
|
|
* for the various components for this test.
|
2018-01-21 15:39:48 +01:00
|
|
|
*/
|
2018-01-21 20:10:05 +01:00
|
|
|
#define CONFIG_FILE "test_exchange_api.conf"
|
2018-01-21 15:39:48 +01:00
|
|
|
|
2019-08-25 16:18:24 +02:00
|
|
|
#define CONFIG_FILE_EXPIRE_RESERVE_NOW \
|
|
|
|
"test_exchange_api_expire_reserve_now.conf"
|
2018-05-18 16:54:36 +02:00
|
|
|
|
2020-01-12 19:55:56 +01:00
|
|
|
|
|
|
|
/**
|
2020-01-13 00:27:48 +01:00
|
|
|
* Exchange configuration data.
|
2020-01-12 19:55:56 +01:00
|
|
|
*/
|
2020-01-13 00:27:48 +01:00
|
|
|
static struct TALER_TESTING_ExchangeConfiguration ec;
|
2020-01-12 19:55:56 +01:00
|
|
|
|
2018-01-21 15:39:48 +01:00
|
|
|
/**
|
2020-01-13 00:27:48 +01:00
|
|
|
* Bank configuration data.
|
2018-01-21 15:39:48 +01:00
|
|
|
*/
|
2020-01-13 00:27:48 +01:00
|
|
|
static struct TALER_TESTING_BankConfiguration bc;
|
2020-01-12 19:45:45 +01:00
|
|
|
|
2018-01-21 15:39:48 +01:00
|
|
|
|
2018-01-21 19:57:09 +01:00
|
|
|
/**
|
2018-01-21 20:10:05 +01:00
|
|
|
* Execute the taler-exchange-wirewatch command with
|
|
|
|
* our configuration file.
|
2018-01-21 19:57:09 +01:00
|
|
|
*
|
2018-01-21 20:10:05 +01:00
|
|
|
* @param label label to use for the command.
|
2018-01-21 15:39:48 +01:00
|
|
|
*/
|
2018-01-21 19:57:09 +01:00
|
|
|
#define CMD_EXEC_WIREWATCH(label) \
|
2019-08-25 16:18:24 +02:00
|
|
|
TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE)
|
2018-01-21 15:39:48 +01:00
|
|
|
|
2018-01-23 10:28:24 +01:00
|
|
|
/**
|
|
|
|
* Execute the taler-exchange-aggregator command with
|
|
|
|
* our configuration file.
|
|
|
|
*
|
|
|
|
* @param label label to use for the command.
|
|
|
|
*/
|
|
|
|
#define CMD_EXEC_AGGREGATOR(label) \
|
2019-08-25 16:18:24 +02:00
|
|
|
TALER_TESTING_cmd_exec_aggregator (label, CONFIG_FILE)
|
2018-01-23 10:28:24 +01:00
|
|
|
|
2018-01-21 19:57:09 +01:00
|
|
|
/**
|
2018-01-21 20:10:05 +01:00
|
|
|
* Run wire transfer of funds from some user's account to the
|
|
|
|
* exchange.
|
2018-01-21 19:57:09 +01:00
|
|
|
*
|
2018-01-21 20:10:05 +01:00
|
|
|
* @param label label to use for the command.
|
|
|
|
* @param amount amount to transfer, i.e. "EUR:1"
|
2018-01-21 19:57:09 +01:00
|
|
|
*/
|
|
|
|
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
2020-01-11 23:06:10 +01:00
|
|
|
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.exchange_account_url, \
|
|
|
|
&bc.exchange_auth, \
|
|
|
|
bc.user42_payto)
|
2018-01-21 19:25:12 +01:00
|
|
|
|
2018-01-21 15:39:48 +01:00
|
|
|
/**
|
2018-01-23 10:28:24 +01:00
|
|
|
* Main function that will tell the interpreter what commands to
|
|
|
|
* run.
|
2018-01-21 15:39:48 +01:00
|
|
|
*
|
|
|
|
* @param cls closure
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
run (void *cls,
|
|
|
|
struct TALER_TESTING_Interpreter *is)
|
|
|
|
{
|
2018-06-25 14:22:52 +02:00
|
|
|
/**
|
|
|
|
* Checks made against /wire response.
|
|
|
|
*/
|
|
|
|
struct TALER_TESTING_Command wire[] = {
|
2018-01-23 10:28:24 +01:00
|
|
|
/**
|
2018-06-25 14:22:52 +02:00
|
|
|
* Check if 'x-taler-bank' wire method is offered
|
|
|
|
* by the exchange.
|
2018-01-23 10:28:24 +01:00
|
|
|
*/
|
2018-04-02 14:24:45 +02:00
|
|
|
TALER_TESTING_cmd_wire ("wire-taler-bank-1",
|
|
|
|
"x-taler-bank",
|
2018-01-23 10:28:24 +01:00
|
|
|
NULL,
|
|
|
|
MHD_HTTP_OK),
|
2018-06-25 14:22:52 +02:00
|
|
|
TALER_TESTING_cmd_end ()
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test withdrawal plus spending.
|
|
|
|
*/
|
|
|
|
struct TALER_TESTING_Command withdraw[] = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Move money to the exchange's bank account.
|
|
|
|
*/
|
|
|
|
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1",
|
|
|
|
"EUR:5.01"),
|
|
|
|
/**
|
|
|
|
* Make a reserve exist, according to the previous
|
|
|
|
* transfer.
|
|
|
|
*/
|
|
|
|
CMD_EXEC_WIREWATCH ("wirewatch-1"),
|
2018-01-23 10:28:24 +01:00
|
|
|
/**
|
|
|
|
* Withdraw EUR:5.
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
|
|
|
|
"create-reserve-1",
|
|
|
|
"EUR:5",
|
|
|
|
MHD_HTTP_OK),
|
|
|
|
/**
|
|
|
|
* Check the reserve is depleted.
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_status ("status-1",
|
|
|
|
"create-reserve-1",
|
|
|
|
"EUR:0",
|
|
|
|
MHD_HTTP_OK),
|
2018-06-25 14:22:52 +02:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_end ()
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TALER_TESTING_Command spend[] = {
|
2018-01-23 10:28:24 +01:00
|
|
|
/**
|
|
|
|
* Spend the coin.
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_deposit
|
2018-12-18 16:09:17 +01:00
|
|
|
("deposit-simple", "withdraw-coin-1", 0,
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user42_payto,
|
2019-08-25 16:18:24 +02:00
|
|
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
|
|
|
GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_OK),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to overdraw.
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2",
|
|
|
|
"create-reserve-1",
|
|
|
|
"EUR:5",
|
2019-11-23 22:30:32 +01:00
|
|
|
MHD_HTTP_CONFLICT),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to double spend using different wire details.
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_deposit
|
2018-12-18 16:09:17 +01:00
|
|
|
("deposit-double-1", "withdraw-coin-1", 0,
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user43_payto,
|
2019-08-25 16:18:24 +02:00
|
|
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
2019-11-23 22:30:32 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_CONFLICT),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to double spend using a different transaction id.
|
|
|
|
* (copied verbatim from old exchange-lib tests.)
|
|
|
|
* FIXME: how can it get a different transaction id? There
|
|
|
|
* isn't such a thing actually, the exchange only knows about
|
|
|
|
* contract terms' hashes. So since the contract terms are
|
2018-06-25 14:22:52 +02:00
|
|
|
* exactly the same as the previous command,
|
|
|
|
* how can a different id be generated?
|
2019-10-31 12:59:50 +01:00
|
|
|
*/TALER_TESTING_cmd_deposit
|
2018-12-18 16:09:17 +01:00
|
|
|
("deposit-double-1", "withdraw-coin-1", 0,
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user43_payto,
|
2019-08-25 16:18:24 +02:00
|
|
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
2019-11-23 22:30:32 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_CONFLICT),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to double spend with different proposal.
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_deposit
|
2018-12-18 16:09:17 +01:00
|
|
|
("deposit-double-2", "withdraw-coin-1", 0,
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user43_payto,
|
2019-08-25 16:18:24 +02:00
|
|
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}",
|
2019-11-23 22:30:32 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_CONFLICT),
|
2018-04-02 14:24:45 +02:00
|
|
|
|
2018-06-25 14:22:52 +02:00
|
|
|
TALER_TESTING_cmd_end ()
|
|
|
|
};
|
|
|
|
|
2018-01-23 10:28:24 +01:00
|
|
|
|
2018-06-25 14:22:52 +02:00
|
|
|
struct TALER_TESTING_Command refresh[] = {
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill reserve with EUR:5, 1ct is for fees. NOTE: the old
|
|
|
|
* test-suite gave a account number of _424_ to the user at
|
|
|
|
* this step; to type less, here the _42_ number is reused.
|
|
|
|
* Does this change the tests semantics?
|
2019-10-31 12:59:50 +01:00
|
|
|
*/CMD_TRANSFER_TO_EXCHANGE ("refresh-create-reserve-1",
|
2018-01-23 10:28:24 +01:00
|
|
|
"EUR:5.01"),
|
2018-04-02 14:24:45 +02:00
|
|
|
|
2018-01-23 10:28:24 +01:00
|
|
|
/**
|
|
|
|
* Make previous command effective.
|
|
|
|
*/
|
|
|
|
CMD_EXEC_WIREWATCH ("wirewatch-2"),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Withdraw EUR:5.
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_withdraw_amount
|
|
|
|
("refresh-withdraw-coin-1",
|
2019-08-25 16:18:24 +02:00
|
|
|
"refresh-create-reserve-1",
|
|
|
|
"EUR:5",
|
|
|
|
MHD_HTTP_OK),
|
2018-01-23 10:28:24 +01:00
|
|
|
/**
|
|
|
|
* Try to partially spend (deposit) 1 EUR of the 5 EUR coin
|
|
|
|
* (in full) (merchant would receive EUR:0.99 due to 1 ct
|
|
|
|
* deposit fee)
|
2019-10-31 12:59:50 +01:00
|
|
|
*/TALER_TESTING_cmd_deposit
|
2018-12-18 16:09:17 +01:00
|
|
|
("refresh-deposit-partial",
|
2019-08-25 16:18:24 +02:00
|
|
|
"refresh-withdraw-coin-1", 0,
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user42_payto,
|
2019-08-25 16:18:24 +02:00
|
|
|
"{\"items\":[{\"name\":\"ice cream\",\
|
2018-01-23 10:28:24 +01:00
|
|
|
\"value\":\"EUR:1\"}]}",
|
2019-08-25 16:18:24 +02:00
|
|
|
GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Melt the rest of the coin's value
|
|
|
|
* (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */
|
2018-05-14 14:50:27 +02:00
|
|
|
TALER_TESTING_cmd_refresh_melt_double
|
2019-07-24 11:57:03 +02:00
|
|
|
("refresh-melt-1",
|
2019-08-25 16:18:24 +02:00
|
|
|
"refresh-withdraw-coin-1",
|
|
|
|
MHD_HTTP_OK,
|
|
|
|
NULL),
|
2018-01-23 10:28:24 +01:00
|
|
|
/**
|
|
|
|
* Complete (successful) melt operation, and
|
|
|
|
* withdraw the coins
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_refresh_reveal
|
2018-12-18 16:27:50 +01:00
|
|
|
("refresh-reveal-1",
|
2019-08-25 16:18:24 +02:00
|
|
|
"refresh-melt-1", MHD_HTTP_OK),
|
2018-04-02 14:24:45 +02:00
|
|
|
|
2018-01-23 10:28:24 +01:00
|
|
|
/**
|
|
|
|
* Do it again to check idempotency
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_refresh_reveal
|
|
|
|
("refresh-reveal-1-idempotency",
|
2019-08-25 16:18:24 +02:00
|
|
|
"refresh-melt-1", MHD_HTTP_OK),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that /refresh/link works
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_refresh_link
|
2018-12-18 16:27:50 +01:00
|
|
|
("refresh-link-1",
|
2019-08-25 16:18:24 +02:00
|
|
|
"refresh-reveal-1", MHD_HTTP_OK),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to spend a refreshed EUR:1 coin
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_deposit
|
2018-12-18 16:09:17 +01:00
|
|
|
("refresh-deposit-refreshed-1a",
|
2019-08-25 16:18:24 +02:00
|
|
|
"refresh-reveal-1-idempotency", 0,
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user42_payto,
|
2019-08-25 16:18:24 +02:00
|
|
|
"{\"items\":[{\"name\":\"ice cream\",\
|
2018-01-23 10:28:24 +01:00
|
|
|
\"value\":3}]}",
|
2019-08-25 16:18:24 +02:00
|
|
|
GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to spend a refreshed EUR:0.1 coin
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_deposit
|
2018-12-18 16:09:17 +01:00
|
|
|
("refresh-deposit-refreshed-1b",
|
2019-08-25 16:18:24 +02:00
|
|
|
"refresh-reveal-1", 3,
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user43_payto,
|
2019-08-25 16:18:24 +02:00
|
|
|
"{\"items\":[{\"name\":\"ice cream\",\
|
2018-01-23 10:28:24 +01:00
|
|
|
\"value\":3}]}",
|
2019-08-25 16:18:24 +02:00
|
|
|
GNUNET_TIME_UNIT_ZERO, "EUR:0.1", MHD_HTTP_OK),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/* Test running a failing melt operation (same operation
|
|
|
|
* again must fail) */
|
|
|
|
TALER_TESTING_cmd_refresh_melt
|
2019-07-24 11:57:03 +02:00
|
|
|
("refresh-melt-failing",
|
2019-08-25 16:18:24 +02:00
|
|
|
"refresh-withdraw-coin-1",
|
2019-11-23 22:30:32 +01:00
|
|
|
MHD_HTTP_CONFLICT,
|
2019-08-25 16:18:24 +02:00
|
|
|
NULL),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/* FIXME: also test with coin that was already melted
|
|
|
|
* (signature differs from coin that was deposited...) */
|
|
|
|
|
2018-06-25 14:22:52 +02:00
|
|
|
TALER_TESTING_cmd_end ()
|
|
|
|
};
|
2018-01-23 10:28:24 +01:00
|
|
|
|
2018-06-25 14:22:52 +02:00
|
|
|
struct TALER_TESTING_Command track[] = {
|
2018-01-23 10:28:24 +01:00
|
|
|
/**
|
|
|
|
* Try resolving a deposit's WTID, as we never triggered
|
|
|
|
* execution of transactions, the answer should be that
|
|
|
|
* the exchange knows about the deposit, but has no WTID yet.
|
2019-10-31 12:59:50 +01:00
|
|
|
*/TALER_TESTING_cmd_track_transaction
|
2019-08-25 16:18:24 +02:00
|
|
|
("deposit-wtid-found",
|
|
|
|
"deposit-simple", 0, MHD_HTTP_ACCEPTED, NULL),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Try resolving a deposit's WTID for a failed deposit.
|
|
|
|
* As the deposit failed, the answer should be that the
|
|
|
|
* exchange does NOT know about the deposit.
|
2019-10-31 12:59:50 +01:00
|
|
|
*/TALER_TESTING_cmd_track_transaction
|
2019-08-25 16:18:24 +02:00
|
|
|
("deposit-wtid-failing",
|
|
|
|
"deposit-double-2", 0, MHD_HTTP_NOT_FOUND, NULL),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Try resolving an undefined (all zeros) WTID; this
|
|
|
|
* should fail as obviously the exchange didn't use that
|
|
|
|
* WTID value for any transaction.
|
2019-10-31 12:59:50 +01:00
|
|
|
*/TALER_TESTING_cmd_track_transfer_empty
|
2018-12-18 16:46:16 +01:00
|
|
|
("wire-deposit-failing",
|
2019-08-25 16:18:24 +02:00
|
|
|
NULL, 0, MHD_HTTP_NOT_FOUND),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Run transfers. Note that _actual_ aggregation will NOT
|
|
|
|
* happen here, as each deposit operation is run with a
|
|
|
|
* fresh merchant public key! NOTE: this comment comes
|
|
|
|
* "verbatim" from the old test-suite, and IMO does not explain
|
|
|
|
* a lot!
|
2019-10-31 12:59:50 +01:00
|
|
|
*/CMD_EXEC_AGGREGATOR ("run-aggregator"),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check all the transfers took place.
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_check_bank_transfer
|
2020-01-13 00:27:48 +01:00
|
|
|
("check_bank_transfer-499c", ec.exchange_url,
|
|
|
|
"EUR:4.98", bc.exchange_payto, bc.user42_payto),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_check_bank_transfer
|
2020-01-13 00:27:48 +01:00
|
|
|
("check_bank_transfer-99c1", ec.exchange_url,
|
|
|
|
"EUR:0.98", bc.exchange_payto, bc.user42_payto),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_check_bank_transfer
|
2020-01-13 00:27:48 +01:00
|
|
|
("check_bank_transfer-99c2", ec.exchange_url,
|
|
|
|
"EUR:0.98", bc.exchange_payto, bc.user42_payto),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_check_bank_transfer
|
2020-01-13 00:27:48 +01:00
|
|
|
("check_bank_transfer-99c", ec.exchange_url,
|
|
|
|
"EUR:0.08", bc.exchange_payto, bc.user43_payto),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_check_bank_transfer
|
2020-01-13 00:27:48 +01:00
|
|
|
("check_bank_transfer-aai-1", ec.exchange_url,
|
|
|
|
"EUR:5.01", bc.user42_payto, bc.exchange_payto),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* NOTE: the old test-suite had this "check bank transfer"
|
|
|
|
* command with debit account == 424.
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_check_bank_transfer
|
2020-01-13 00:27:48 +01:00
|
|
|
("check_bank_transfer-aai-2", ec.exchange_url,
|
|
|
|
"EUR:5.01", bc.user42_payto, bc.exchange_payto),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
|
|
|
|
|
|
|
|
TALER_TESTING_cmd_track_transaction
|
2019-08-25 16:18:24 +02:00
|
|
|
("deposit-wtid-ok",
|
|
|
|
"deposit-simple", 0, MHD_HTTP_OK, "check_bank_transfer-499c"),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_track_transfer
|
2018-12-18 16:46:16 +01:00
|
|
|
("wire-deposit-success-bank",
|
2019-08-25 16:18:24 +02:00
|
|
|
"check_bank_transfer-99c1", 0, MHD_HTTP_OK, "EUR:0.98",
|
|
|
|
"EUR:0.01"),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_track_transfer
|
2018-12-18 16:46:16 +01:00
|
|
|
("wire-deposits-success-wtid",
|
2019-08-25 16:18:24 +02:00
|
|
|
"deposit-wtid-ok", 0, MHD_HTTP_OK, "EUR:4.98",
|
|
|
|
"EUR:0.01"),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
2018-06-25 14:22:52 +02:00
|
|
|
TALER_TESTING_cmd_end ()
|
|
|
|
};
|
2018-01-23 10:28:24 +01:00
|
|
|
|
2018-06-25 14:22:52 +02:00
|
|
|
|
2018-06-28 10:38:42 +02:00
|
|
|
/**
|
|
|
|
* This block checks whether a wire deadline
|
|
|
|
* very far in the future does NOT get aggregated now.
|
|
|
|
*/
|
|
|
|
struct TALER_TESTING_Command unaggregation[] = {
|
|
|
|
|
|
|
|
TALER_TESTING_cmd_check_bank_empty
|
|
|
|
("far-future-aggregation-a"),
|
|
|
|
|
|
|
|
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-unaggregated",
|
|
|
|
"EUR:5.01"),
|
|
|
|
|
|
|
|
CMD_EXEC_WIREWATCH ("wirewatch-unaggregated"),
|
|
|
|
|
|
|
|
/* "consume" reserve creation transfer. */
|
|
|
|
TALER_TESTING_cmd_check_bank_transfer
|
|
|
|
("check_bank_transfer-unaggregated",
|
2020-01-13 00:27:48 +01:00
|
|
|
ec.exchange_url,
|
2019-08-25 16:18:24 +02:00
|
|
|
"EUR:5.01",
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user42_payto, bc.exchange_payto),
|
2018-06-28 10:38:42 +02:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_withdraw_amount
|
|
|
|
("withdraw-coin-unaggregated",
|
2019-08-25 16:18:24 +02:00
|
|
|
"create-reserve-unaggregated",
|
|
|
|
"EUR:5",
|
|
|
|
MHD_HTTP_OK),
|
2018-06-28 10:38:42 +02:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_deposit
|
|
|
|
("deposit-unaggregated",
|
2019-08-25 16:18:24 +02:00
|
|
|
"withdraw-coin-unaggregated",
|
|
|
|
0,
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user43_payto,
|
2019-08-25 16:18:24 +02:00
|
|
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
|
|
|
GNUNET_TIME_relative_multiply
|
|
|
|
(GNUNET_TIME_UNIT_YEARS,
|
|
|
|
3000),
|
|
|
|
"EUR:5",
|
|
|
|
MHD_HTTP_OK),
|
2018-06-28 10:38:42 +02:00
|
|
|
|
|
|
|
CMD_EXEC_AGGREGATOR ("aggregation-attempt"),
|
|
|
|
|
|
|
|
TALER_TESTING_cmd_check_bank_empty
|
|
|
|
("far-future-aggregation-b"),
|
|
|
|
|
|
|
|
TALER_TESTING_cmd_end ()
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-06-25 14:22:52 +02:00
|
|
|
struct TALER_TESTING_Command refund[] = {
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill reserve with EUR:5.01, as withdraw fee is 1 ct per
|
|
|
|
* config.
|
|
|
|
*/
|
|
|
|
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-r1",
|
|
|
|
"EUR:5.01"),
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run wire-watch to trigger the reserve creation.
|
|
|
|
*/
|
|
|
|
CMD_EXEC_WIREWATCH ("wirewatch-3"),
|
|
|
|
|
|
|
|
/* Withdraw a 5 EUR coin, at fee of 1 ct */
|
|
|
|
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-r1",
|
|
|
|
"create-reserve-r1",
|
|
|
|
"EUR:5",
|
|
|
|
MHD_HTTP_OK),
|
|
|
|
/**
|
|
|
|
* Spend 5 EUR of the 5 EUR coin (in full) (merchant would
|
|
|
|
* receive EUR:4.99 due to 1 ct deposit fee)
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_deposit
|
2018-12-18 16:09:17 +01:00
|
|
|
("deposit-refund-1", "withdraw-coin-r1", 0,
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user42_payto,
|
2019-08-25 16:18:24 +02:00
|
|
|
"{\"items\":[{\"name\":\"ice cream\","
|
|
|
|
"\"value\":\"EUR:5\"}]}",
|
|
|
|
GNUNET_TIME_UNIT_MINUTES, "EUR:5", MHD_HTTP_OK),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run transfers. Should do nothing as refund deadline blocks
|
|
|
|
* it
|
|
|
|
*/
|
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-refund"),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check that aggregator didn't do anything, as expected.
|
|
|
|
* Note, this operation takes two commands: one to "flush"
|
|
|
|
* the preliminary transfer (used to withdraw) from the
|
|
|
|
* fakebank and the second to actually check there are not
|
|
|
|
* other transfers around.
|
2019-10-31 12:59:50 +01:00
|
|
|
*/TALER_TESTING_cmd_check_bank_transfer
|
2020-01-13 00:27:48 +01:00
|
|
|
("check_bank_transfer-pre-refund", ec.exchange_url,
|
|
|
|
"EUR:5.01", bc.user42_payto, bc.exchange_payto),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_check_bank_empty
|
|
|
|
("check_bank_transfer-pre-refund"),
|
|
|
|
|
|
|
|
TALER_TESTING_cmd_refund
|
|
|
|
("refund-ok", MHD_HTTP_OK,
|
2019-08-25 16:18:24 +02:00
|
|
|
"EUR:5", "EUR:0.01", "deposit-refund-1"),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
2018-05-17 15:35:45 +02:00
|
|
|
TALER_TESTING_cmd_refund
|
|
|
|
("refund-ok-double", MHD_HTTP_OK,
|
2019-08-25 16:18:24 +02:00
|
|
|
"EUR:5", "EUR:0.01", "deposit-refund-1"),
|
2018-05-17 15:35:45 +02:00
|
|
|
|
2018-05-17 15:50:50 +02:00
|
|
|
/* Previous /refund(s) had id == 0. */
|
|
|
|
TALER_TESTING_cmd_refund_with_id
|
|
|
|
("refund-conflicting", MHD_HTTP_CONFLICT,
|
2019-08-25 16:18:24 +02:00
|
|
|
"EUR:5", "EUR:0.01", "deposit-refund-1", 1),
|
2018-05-17 15:50:50 +02:00
|
|
|
|
2018-01-23 10:28:24 +01:00
|
|
|
/**
|
|
|
|
* Spend 4.99 EUR of the refunded 4.99 EUR coin (1ct gone
|
|
|
|
* due to refund) (merchant would receive EUR:4.98 due to
|
|
|
|
* 1 ct deposit fee) */
|
|
|
|
TALER_TESTING_cmd_deposit
|
2018-12-18 16:09:17 +01:00
|
|
|
("deposit-refund-2", "withdraw-coin-r1", 0,
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user42_payto,
|
2019-08-25 16:18:24 +02:00
|
|
|
"{\"items\":[{\"name\":\"more ice cream\","
|
|
|
|
"\"value\":\"EUR:5\"}]}",
|
|
|
|
GNUNET_TIME_UNIT_ZERO, "EUR:4.99", MHD_HTTP_OK),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run transfers. This will do the transfer as refund deadline
|
|
|
|
* was 0
|
|
|
|
*/
|
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-3"),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check that deposit did run.
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_check_bank_transfer
|
2020-01-13 00:27:48 +01:00
|
|
|
("check_bank_transfer-pre-refund", ec.exchange_url,
|
|
|
|
"EUR:4.97", bc.exchange_payto, bc.user42_payto),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Run failing refund, as past deadline & aggregation.
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_refund
|
|
|
|
("refund-fail", MHD_HTTP_GONE,
|
2019-08-25 16:18:24 +02:00
|
|
|
"EUR:4.99", "EUR:0.01", "deposit-refund-2"),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_check_bank_empty
|
|
|
|
("check-empty-after-refund"),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test refunded coins are never executed, even past
|
|
|
|
* refund deadline
|
|
|
|
*/
|
|
|
|
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-rb",
|
|
|
|
"EUR:5.01"),
|
|
|
|
|
|
|
|
CMD_EXEC_WIREWATCH ("wirewatch-rb"),
|
|
|
|
|
|
|
|
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-rb",
|
|
|
|
"create-reserve-rb",
|
|
|
|
"EUR:5",
|
|
|
|
MHD_HTTP_OK),
|
|
|
|
|
|
|
|
TALER_TESTING_cmd_check_bank_transfer
|
2020-01-13 00:27:48 +01:00
|
|
|
("check_bank_transfer-aai-3b", ec.exchange_url,
|
|
|
|
"EUR:5.01", bc.user42_payto, bc.exchange_payto),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
TALER_TESTING_cmd_deposit
|
2018-12-18 16:09:17 +01:00
|
|
|
("deposit-refund-1b", "withdraw-coin-rb", 0,
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user42_payto,
|
2019-08-25 16:18:24 +02:00
|
|
|
"{\"items\":[{\"name\":\"ice cream\","
|
|
|
|
"\"value\":\"EUR:5\"}]}",
|
|
|
|
GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_OK),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Trigger refund (before aggregator had a chance to execute
|
|
|
|
* deposit, even though refund deadline was zero).
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_refund
|
|
|
|
("refund-ok-fast", MHD_HTTP_OK,
|
2019-08-25 16:18:24 +02:00
|
|
|
"EUR:5", "EUR:0.01", "deposit-refund-1b"),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Run transfers. This will do the transfer as refund deadline
|
|
|
|
* was 0, except of course because the refund succeeded, the
|
|
|
|
* transfer should no longer be done.
|
2019-10-31 12:59:50 +01:00
|
|
|
*/CMD_EXEC_AGGREGATOR ("run-aggregator-3b"),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/* check that aggregator didn't do anything, as expected */
|
|
|
|
TALER_TESTING_cmd_check_bank_empty
|
|
|
|
("check-refund-fast-not-run"),
|
|
|
|
|
2018-06-25 14:22:52 +02:00
|
|
|
TALER_TESTING_cmd_end ()
|
|
|
|
};
|
2018-01-23 10:28:24 +01:00
|
|
|
|
2018-06-25 14:22:52 +02:00
|
|
|
struct TALER_TESTING_Command payback[] = {
|
2018-01-23 10:28:24 +01:00
|
|
|
/**
|
|
|
|
* Fill reserve with EUR:5.01, as withdraw fee is 1 ct per
|
|
|
|
* config.
|
|
|
|
*/
|
|
|
|
CMD_TRANSFER_TO_EXCHANGE ("payback-create-reserve-1",
|
|
|
|
"EUR:5.01"),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run wire-watch to trigger the reserve creation.
|
|
|
|
*/
|
|
|
|
CMD_EXEC_WIREWATCH ("wirewatch-4"),
|
|
|
|
|
|
|
|
/* Withdraw a 5 EUR coin, at fee of 1 ct */
|
|
|
|
TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-1",
|
|
|
|
"payback-create-reserve-1",
|
|
|
|
"EUR:5",
|
2018-04-02 14:24:45 +02:00
|
|
|
MHD_HTTP_OK),
|
2018-12-12 13:42:00 +01:00
|
|
|
/* Make coin invalid */
|
|
|
|
TALER_TESTING_cmd_revoke ("revoke-1",
|
|
|
|
MHD_HTTP_OK,
|
2018-01-23 10:28:24 +01:00
|
|
|
"payback-withdraw-coin-1",
|
|
|
|
CONFIG_FILE),
|
|
|
|
|
2018-12-12 13:42:00 +01:00
|
|
|
/* Refund coin to bank account */
|
|
|
|
TALER_TESTING_cmd_payback ("payback-1",
|
|
|
|
MHD_HTTP_OK,
|
|
|
|
"payback-withdraw-coin-1",
|
2019-07-23 21:56:21 +02:00
|
|
|
"EUR:5",
|
|
|
|
NULL),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/* Check the money is back with the reserve */
|
|
|
|
TALER_TESTING_cmd_status ("payback-reserve-status-1",
|
|
|
|
"payback-create-reserve-1",
|
|
|
|
"EUR:5.0",
|
|
|
|
MHD_HTTP_OK),
|
|
|
|
|
2018-05-18 10:50:27 +02:00
|
|
|
/* Re-withdraw from this reserve */
|
|
|
|
TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2",
|
|
|
|
"payback-create-reserve-1",
|
|
|
|
"EUR:1",
|
|
|
|
MHD_HTTP_OK),
|
|
|
|
|
2018-12-12 13:42:00 +01:00
|
|
|
/**
|
|
|
|
* This withdrawal will test the logic to create a "payback"
|
|
|
|
* element to insert into the reserve's history.
|
2018-06-25 14:22:52 +02:00
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_withdraw_amount
|
|
|
|
("payback-withdraw-coin-2-over",
|
2019-08-25 16:18:24 +02:00
|
|
|
"payback-create-reserve-1",
|
|
|
|
"EUR:10",
|
2019-11-23 22:30:32 +01:00
|
|
|
MHD_HTTP_CONFLICT),
|
2018-05-18 17:04:36 +02:00
|
|
|
|
2018-05-18 10:57:41 +02:00
|
|
|
TALER_TESTING_cmd_status ("payback-reserve-status-2",
|
|
|
|
"payback-create-reserve-1",
|
|
|
|
"EUR:3.99",
|
|
|
|
MHD_HTTP_OK),
|
|
|
|
|
2018-05-18 16:54:36 +02:00
|
|
|
/**
|
|
|
|
* These commands should close the reserve because
|
|
|
|
* the aggregator is given a config file that ovverrides
|
|
|
|
* the reserve expiration time (making it now-ish)
|
2019-10-31 12:59:50 +01:00
|
|
|
*/CMD_TRANSFER_TO_EXCHANGE
|
2018-05-18 16:54:36 +02:00
|
|
|
("short-lived-reserve",
|
2019-08-25 16:18:24 +02:00
|
|
|
"EUR:5.01"),
|
2018-05-18 16:54:36 +02:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_exec_wirewatch
|
|
|
|
("short-lived-aggregation",
|
2019-08-25 16:18:24 +02:00
|
|
|
CONFIG_FILE_EXPIRE_RESERVE_NOW),
|
2018-05-18 16:54:36 +02:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_exec_aggregator
|
|
|
|
("close-reserves",
|
2019-08-25 16:18:24 +02:00
|
|
|
CONFIG_FILE_EXPIRE_RESERVE_NOW),
|
2018-05-18 16:54:36 +02:00
|
|
|
|
2018-10-22 11:31:33 +02:00
|
|
|
TALER_TESTING_cmd_status ("short-lived-status",
|
|
|
|
"short-lived-reserve",
|
|
|
|
"EUR:0",
|
|
|
|
MHD_HTTP_OK),
|
|
|
|
|
2018-05-18 16:54:36 +02:00
|
|
|
TALER_TESTING_cmd_withdraw_amount
|
|
|
|
("expired-withdraw",
|
2019-08-25 16:18:24 +02:00
|
|
|
"short-lived-reserve",
|
|
|
|
"EUR:1",
|
2019-11-23 22:30:32 +01:00
|
|
|
MHD_HTTP_CONFLICT),
|
2018-05-18 16:54:36 +02:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_check_bank_transfer
|
|
|
|
("check_bank_short-lived_transfer",
|
2020-01-13 00:27:48 +01:00
|
|
|
ec.exchange_url,
|
2019-08-25 16:18:24 +02:00
|
|
|
"EUR:5.01",
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user42_payto,
|
|
|
|
bc.exchange_payto),
|
2018-05-18 16:54:36 +02:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_check_bank_transfer
|
|
|
|
("check_bank_short-lived_reimburse",
|
2020-01-13 00:27:48 +01:00
|
|
|
ec.exchange_url,
|
2019-08-25 16:18:24 +02:00
|
|
|
"EUR:5",
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.exchange_payto,
|
|
|
|
bc.user42_payto),
|
2018-05-18 16:54:36 +02:00
|
|
|
|
2018-01-23 10:28:24 +01:00
|
|
|
/**
|
|
|
|
* Fill reserve with EUR:2.02, as withdraw fee is 1 ct per
|
|
|
|
* config, then withdraw two coin, partially spend one, and
|
|
|
|
* then have the rest paid back. Check deposit of other coin
|
|
|
|
* fails. (Do not use EUR:5 here as the EUR:5 coin was
|
|
|
|
* revoked and we did not bother to create a new one...)
|
2019-10-31 12:59:50 +01:00
|
|
|
*/CMD_TRANSFER_TO_EXCHANGE ("payback-create-reserve-2",
|
2018-01-23 10:28:24 +01:00
|
|
|
"EUR:2.02"),
|
|
|
|
|
|
|
|
/* Make previous command effective. */
|
|
|
|
CMD_EXEC_WIREWATCH ("wirewatch-5"),
|
|
|
|
|
|
|
|
/* Withdraw a 1 EUR coin, at fee of 1 ct */
|
|
|
|
TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2a",
|
|
|
|
"payback-create-reserve-2",
|
|
|
|
"EUR:1",
|
|
|
|
MHD_HTTP_OK),
|
|
|
|
|
|
|
|
/* Withdraw a 1 EUR coin, at fee of 1 ct */
|
|
|
|
TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2b",
|
|
|
|
"payback-create-reserve-2",
|
|
|
|
"EUR:1",
|
|
|
|
MHD_HTTP_OK),
|
|
|
|
|
|
|
|
TALER_TESTING_cmd_deposit
|
2018-12-18 16:09:17 +01:00
|
|
|
("payback-deposit-partial",
|
2019-08-25 16:18:24 +02:00
|
|
|
"payback-withdraw-coin-2a", 0,
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user42_payto,
|
2019-08-25 16:18:24 +02:00
|
|
|
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
|
|
|
|
GNUNET_TIME_UNIT_ZERO, "EUR:0.5", MHD_HTTP_OK),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
TALER_TESTING_cmd_revoke ("revoke-2", MHD_HTTP_OK,
|
|
|
|
"payback-withdraw-coin-2a",
|
|
|
|
CONFIG_FILE),
|
|
|
|
|
|
|
|
TALER_TESTING_cmd_payback ("payback-2", MHD_HTTP_OK,
|
|
|
|
"payback-withdraw-coin-2a",
|
2019-07-23 21:56:21 +02:00
|
|
|
"EUR:0.5",
|
|
|
|
NULL),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
2019-11-23 22:30:32 +01:00
|
|
|
TALER_TESTING_cmd_payback ("payback-2b", MHD_HTTP_CONFLICT,
|
2018-01-23 10:28:24 +01:00
|
|
|
"payback-withdraw-coin-2a",
|
2019-07-23 21:56:21 +02:00
|
|
|
"EUR:0.5",
|
|
|
|
NULL),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_deposit
|
2018-12-18 16:09:17 +01:00
|
|
|
("payback-deposit-revoked",
|
2019-08-25 16:18:24 +02:00
|
|
|
"payback-withdraw-coin-2b", 0,
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user42_payto,
|
2019-08-25 16:18:24 +02:00
|
|
|
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
|
|
|
|
GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_NOT_FOUND),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* Test deposit fails after payback, with proof in payback */
|
|
|
|
|
|
|
|
/* FIXME: #3887: right now, the exchange will never return the
|
|
|
|
* coin's transaction history with payback data, as we get a
|
|
|
|
* 404 on the DK! */
|
|
|
|
TALER_TESTING_cmd_deposit
|
2018-06-25 14:22:52 +02:00
|
|
|
("payback-deposit-partial-after-payback",
|
2019-08-25 16:18:24 +02:00
|
|
|
"payback-withdraw-coin-2a",
|
|
|
|
0,
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user42_payto,
|
2019-08-25 16:18:24 +02:00
|
|
|
"{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}",
|
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:0.5",
|
|
|
|
MHD_HTTP_NOT_FOUND),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/* Test that revoked coins cannot be withdrawn */
|
|
|
|
CMD_TRANSFER_TO_EXCHANGE ("payback-create-reserve-3",
|
|
|
|
"EUR:1.01"),
|
|
|
|
|
|
|
|
CMD_EXEC_WIREWATCH ("wirewatch-6"),
|
|
|
|
|
|
|
|
TALER_TESTING_cmd_withdraw_amount
|
|
|
|
("payback-withdraw-coin-3-revoked",
|
2019-08-25 16:18:24 +02:00
|
|
|
"payback-create-reserve-3",
|
|
|
|
"EUR:1",
|
|
|
|
MHD_HTTP_NOT_FOUND),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
|
|
|
/* check that we are empty before the rejection test */
|
|
|
|
TALER_TESTING_cmd_check_bank_transfer
|
2020-01-13 00:27:48 +01:00
|
|
|
("check_bank_transfer-pr1", ec.exchange_url,
|
|
|
|
"EUR:5.01", bc.user42_payto, bc.exchange_payto),
|
2018-01-23 10:28:24 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_transfer
|
2020-01-13 00:27:48 +01:00
|
|
|
("check_bank_transfer-pr2", ec.exchange_url,
|
|
|
|
"EUR:2.02", bc.user42_payto, bc.exchange_payto),
|
2018-01-23 10:28:24 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_transfer
|
2020-01-13 00:27:48 +01:00
|
|
|
("check_bank_transfer-pr3", ec.exchange_url,
|
|
|
|
"EUR:1.01", bc.user42_payto, bc.exchange_payto),
|
2018-06-25 14:22:52 +02:00
|
|
|
TALER_TESTING_cmd_check_bank_empty
|
|
|
|
("check-empty-again"),
|
2018-01-23 10:28:24 +01:00
|
|
|
|
2018-06-25 14:22:52 +02:00
|
|
|
TALER_TESTING_cmd_end ()
|
|
|
|
};
|
|
|
|
|
2020-01-12 20:22:18 +01:00
|
|
|
struct TALER_TESTING_Command revocation[] = {
|
|
|
|
/**
|
|
|
|
* Fill reserve with EUR:5.01, as withdraw fee is 1 ct per
|
|
|
|
* config.
|
|
|
|
*/
|
|
|
|
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1",
|
|
|
|
"EUR:5.01"),
|
|
|
|
/**
|
|
|
|
* Run wire-watch to trigger the reserve creation.
|
|
|
|
*/
|
|
|
|
CMD_EXEC_WIREWATCH ("wirewatch-4"),
|
|
|
|
/* Withdraw a 5 EUR coin, at fee of 1 ct */
|
|
|
|
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
|
|
|
|
"create-reserve-1",
|
|
|
|
"EUR:5",
|
|
|
|
MHD_HTTP_OK),
|
|
|
|
/**
|
|
|
|
* Try to partially spend (deposit) 1 EUR of the 5 EUR coin
|
|
|
|
* (in full) (merchant would receive EUR:0.99 due to 1 ct
|
|
|
|
* deposit fee)
|
|
|
|
*/TALER_TESTING_cmd_deposit
|
|
|
|
("deposit-partial",
|
|
|
|
"withdraw-coin-1", 0,
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.user42_payto,
|
2020-01-12 20:22:18 +01:00
|
|
|
"{\"items\":[{\"name\":\"ice cream\",\
|
|
|
|
\"value\":\"EUR:1\"}]}",
|
|
|
|
GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK),
|
|
|
|
/**
|
|
|
|
* Melt SOME of the rest of the coin's value
|
|
|
|
* (EUR:3.17 = 3x EUR:1.03 + 7x EUR:0.13) */
|
|
|
|
TALER_TESTING_cmd_refresh_melt
|
|
|
|
("refresh-melt-1",
|
|
|
|
"withdraw-coin-1",
|
|
|
|
MHD_HTTP_OK,
|
|
|
|
NULL),
|
|
|
|
/**
|
|
|
|
* Complete (successful) melt operation, and withdraw the coins
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_refresh_reveal
|
|
|
|
("refresh-reveal-1",
|
|
|
|
"refresh-melt-1", MHD_HTTP_OK),
|
|
|
|
/* Make refreshed coin invalid */
|
|
|
|
TALER_TESTING_cmd_revoke ("revoke-1",
|
|
|
|
MHD_HTTP_OK,
|
|
|
|
"refresh-melt-1",
|
|
|
|
CONFIG_FILE),
|
|
|
|
/* Refund coin to original coin */
|
|
|
|
TALER_TESTING_cmd_payback ("payback-1a",
|
|
|
|
MHD_HTTP_OK,
|
|
|
|
"refresh-reveal-1#0",
|
|
|
|
"EUR:1",
|
|
|
|
"refresh-melt-1"),
|
|
|
|
TALER_TESTING_cmd_payback ("payback-1b",
|
|
|
|
MHD_HTTP_OK,
|
|
|
|
"refresh-reveal-1#1",
|
|
|
|
"EUR:1",
|
|
|
|
"refresh-melt-1"),
|
|
|
|
TALER_TESTING_cmd_payback ("payback-1c",
|
|
|
|
MHD_HTTP_OK,
|
|
|
|
"refresh-reveal-1#2",
|
|
|
|
"EUR:1",
|
|
|
|
"refresh-melt-1"),
|
|
|
|
/* Now we have EUR:3.83 EUR back after 3x EUR:1 in paybacks */
|
|
|
|
/* Melt original coin AGAIN, but only create one 0.1 EUR coin;
|
|
|
|
This costs EUR:0.03 in refresh and EUR:01 in withdraw fees,
|
|
|
|
leaving EUR:3.69. */
|
|
|
|
TALER_TESTING_cmd_refresh_melt
|
|
|
|
("refresh-melt-2",
|
|
|
|
"withdraw-coin-1",
|
|
|
|
MHD_HTTP_OK,
|
|
|
|
"EUR:0.1",
|
|
|
|
NULL),
|
|
|
|
/**
|
|
|
|
* Complete (successful) melt operation, and withdraw the coins
|
|
|
|
*/
|
|
|
|
TALER_TESTING_cmd_refresh_reveal
|
|
|
|
("refresh-reveal-2",
|
|
|
|
"refresh-melt-2", MHD_HTTP_OK),
|
|
|
|
/* Revokes refreshed EUR:0.1 coin */
|
|
|
|
TALER_TESTING_cmd_revoke ("revoke-2",
|
|
|
|
MHD_HTTP_OK,
|
|
|
|
"refresh-reveal-2",
|
|
|
|
CONFIG_FILE),
|
|
|
|
/* Revoke also original coin denomination */
|
|
|
|
TALER_TESTING_cmd_revoke ("revoke-3",
|
|
|
|
MHD_HTTP_OK,
|
|
|
|
"withdraw-coin-1",
|
|
|
|
CONFIG_FILE),
|
|
|
|
/* Refund coin EUR:0.1 to original coin, creating zombie! */
|
|
|
|
TALER_TESTING_cmd_payback ("payback-2",
|
|
|
|
MHD_HTTP_OK,
|
|
|
|
"refresh-reveal-2",
|
|
|
|
"EUR:0.1",
|
|
|
|
"refresh-melt-2"),
|
|
|
|
/* Due to payback, original coin is now at EUR:3.79 */
|
|
|
|
/* Refund original (now zombie) coin to reserve */
|
|
|
|
TALER_TESTING_cmd_payback ("payback-3",
|
|
|
|
MHD_HTTP_OK,
|
|
|
|
"withdraw-coin-1",
|
|
|
|
"EUR:3.79",
|
|
|
|
NULL),
|
|
|
|
/* Check the money is back with the reserve */
|
|
|
|
TALER_TESTING_cmd_status ("payback-reserve-status-1",
|
|
|
|
"create-reserve-1",
|
|
|
|
"EUR:3.79",
|
|
|
|
MHD_HTTP_OK),
|
|
|
|
TALER_TESTING_cmd_end ()
|
|
|
|
};
|
|
|
|
|
2020-01-12 19:55:56 +01:00
|
|
|
#define RESERVE_OPEN_CLOSE_CHUNK 4
|
|
|
|
#define RESERVE_OPEN_CLOSE_ITERATIONS 3
|
2019-06-08 21:41:12 +02:00
|
|
|
|
2020-01-12 19:55:56 +01:00
|
|
|
struct TALER_TESTING_Command reserve_open_close[(RESERVE_OPEN_CLOSE_ITERATIONS
|
|
|
|
* RESERVE_OPEN_CLOSE_CHUNK)
|
|
|
|
+ 1];
|
2018-12-12 19:08:24 +01:00
|
|
|
for (unsigned int i = 0;
|
|
|
|
i < RESERVE_OPEN_CLOSE_ITERATIONS;
|
|
|
|
i++)
|
|
|
|
{
|
2020-01-12 19:55:56 +01:00
|
|
|
reserve_open_close[(i * RESERVE_OPEN_CLOSE_CHUNK) + 0]
|
|
|
|
= CMD_TRANSFER_TO_EXCHANGE
|
2018-12-12 19:08:24 +01:00
|
|
|
("reserve-open-close-key",
|
2020-01-12 19:55:56 +01:00
|
|
|
"EUR:20");
|
2018-12-12 19:08:24 +01:00
|
|
|
reserve_open_close[(i * RESERVE_OPEN_CLOSE_CHUNK) + 1]
|
|
|
|
= TALER_TESTING_cmd_exec_wirewatch
|
|
|
|
("reserve-open-close-wirewatch",
|
2019-08-25 16:18:24 +02:00
|
|
|
CONFIG_FILE_EXPIRE_RESERVE_NOW);
|
2018-12-12 19:08:24 +01:00
|
|
|
reserve_open_close[(i * RESERVE_OPEN_CLOSE_CHUNK) + 2]
|
|
|
|
= TALER_TESTING_cmd_exec_aggregator
|
|
|
|
("reserve-open-close-aggregation",
|
2019-08-25 16:18:24 +02:00
|
|
|
CONFIG_FILE_EXPIRE_RESERVE_NOW);
|
2018-12-12 19:08:24 +01:00
|
|
|
reserve_open_close[(i * RESERVE_OPEN_CLOSE_CHUNK) + 3]
|
|
|
|
= TALER_TESTING_cmd_status ("reserve-open-close-status",
|
|
|
|
"reserve-open-close-key",
|
|
|
|
"EUR:0",
|
|
|
|
MHD_HTTP_OK);
|
|
|
|
}
|
2020-01-12 19:55:56 +01:00
|
|
|
reserve_open_close[RESERVE_OPEN_CLOSE_ITERATIONS * RESERVE_OPEN_CLOSE_CHUNK]
|
2019-08-25 16:18:24 +02:00
|
|
|
= TALER_TESTING_cmd_end ();
|
2018-12-12 13:42:00 +01:00
|
|
|
|
2020-01-12 20:22:18 +01:00
|
|
|
|
2018-06-25 14:22:52 +02:00
|
|
|
struct TALER_TESTING_Command commands[] = {
|
|
|
|
TALER_TESTING_cmd_batch ("wire",
|
|
|
|
wire),
|
|
|
|
TALER_TESTING_cmd_batch ("withdraw",
|
|
|
|
withdraw),
|
|
|
|
TALER_TESTING_cmd_batch ("spend",
|
|
|
|
spend),
|
|
|
|
TALER_TESTING_cmd_batch ("refresh",
|
|
|
|
refresh),
|
|
|
|
TALER_TESTING_cmd_batch ("track",
|
|
|
|
track),
|
2018-06-28 10:38:42 +02:00
|
|
|
TALER_TESTING_cmd_batch ("unaggregation",
|
|
|
|
unaggregation),
|
2018-06-25 14:22:52 +02:00
|
|
|
TALER_TESTING_cmd_batch ("refund",
|
|
|
|
refund),
|
|
|
|
TALER_TESTING_cmd_batch ("payback",
|
|
|
|
payback),
|
2018-12-12 13:42:00 +01:00
|
|
|
TALER_TESTING_cmd_batch ("reserve-open-close",
|
|
|
|
reserve_open_close),
|
2020-01-12 20:22:18 +01:00
|
|
|
TALER_TESTING_cmd_batch ("revocation",
|
|
|
|
revocation),
|
2018-01-23 10:28:24 +01:00
|
|
|
/**
|
|
|
|
* End the suite. Fixme: better to have a label for this
|
2018-12-12 19:08:24 +01:00
|
|
|
* too, as it shows as "(null)" on logs.
|
2018-01-23 10:28:24 +01:00
|
|
|
*/
|
2018-01-21 15:39:48 +01:00
|
|
|
TALER_TESTING_cmd_end ()
|
|
|
|
};
|
|
|
|
|
2018-01-21 19:57:09 +01:00
|
|
|
TALER_TESTING_run_with_fakebank (is,
|
|
|
|
commands,
|
2020-01-13 00:27:48 +01:00
|
|
|
bc.bank_url);
|
2018-01-21 15:39:48 +01:00
|
|
|
}
|
|
|
|
|
2018-04-02 14:24:45 +02:00
|
|
|
|
2018-01-21 15:39:48 +01:00
|
|
|
int
|
|
|
|
main (int argc,
|
2019-08-25 16:18:24 +02:00
|
|
|
char *const *argv)
|
2018-01-21 15:39:48 +01:00
|
|
|
{
|
2018-01-21 19:57:09 +01:00
|
|
|
/* These environment variables get in the way... */
|
2018-01-21 15:39:48 +01:00
|
|
|
unsetenv ("XDG_DATA_HOME");
|
|
|
|
unsetenv ("XDG_CONFIG_HOME");
|
2019-07-15 20:55:11 +02:00
|
|
|
GNUNET_log_setup ("test-exchange-api",
|
2018-01-21 15:39:48 +01:00
|
|
|
"INFO",
|
|
|
|
NULL);
|
2020-01-13 00:27:48 +01:00
|
|
|
/* Check fakebank port is available and get config */
|
|
|
|
if (GNUNET_OK !=
|
|
|
|
TALER_TESTING_prepare_fakebank (CONFIG_FILE,
|
|
|
|
"account-2",
|
|
|
|
&bc))
|
2018-01-21 19:57:09 +01:00
|
|
|
return 77;
|
|
|
|
TALER_TESTING_cleanup_files (CONFIG_FILE);
|
2018-01-23 10:28:24 +01:00
|
|
|
/* @helpers. Run keyup, create tables, ... Note: it
|
|
|
|
* fetches the port number from config in order to see
|
|
|
|
* if it's available. */
|
2018-02-28 16:15:18 +01:00
|
|
|
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
|
2020-01-13 00:27:48 +01:00
|
|
|
&ec))
|
2018-01-21 15:39:48 +01:00
|
|
|
{
|
2018-01-21 19:57:09 +01:00
|
|
|
case GNUNET_SYSERR:
|
|
|
|
GNUNET_break (0);
|
|
|
|
return 1;
|
|
|
|
case GNUNET_NO:
|
2018-01-21 15:39:48 +01:00
|
|
|
return 77;
|
2018-01-21 19:57:09 +01:00
|
|
|
case GNUNET_OK:
|
|
|
|
if (GNUNET_OK !=
|
2018-01-23 10:28:24 +01:00
|
|
|
/* Set up event loop and reschedule context, plus
|
|
|
|
* start/stop the exchange. It calls TALER_TESTING_setup
|
|
|
|
* which creates the 'is' object.
|
|
|
|
*/
|
2018-01-21 19:57:09 +01:00
|
|
|
TALER_TESTING_setup_with_exchange (&run,
|
|
|
|
NULL,
|
|
|
|
CONFIG_FILE))
|
|
|
|
return 1;
|
2018-01-23 10:28:24 +01:00
|
|
|
break;
|
2018-01-21 19:57:09 +01:00
|
|
|
default:
|
|
|
|
GNUNET_break (0);
|
|
|
|
return 1;
|
2018-01-21 15:39:48 +01:00
|
|
|
}
|
2018-01-21 19:57:09 +01:00
|
|
|
return 0;
|
2018-01-21 15:39:48 +01:00
|
|
|
}
|
2018-01-21 19:57:09 +01:00
|
|
|
|
2019-10-31 12:59:50 +01:00
|
|
|
|
2019-07-15 20:55:11 +02:00
|
|
|
/* end of test_exchange_api.c */
|