Splitting "lib" test case into smaller CMDs arrays.

This commit is contained in:
Marcello Stanisci 2018-06-25 14:22:52 +02:00
parent 402a8b42d1
commit 886382236c
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F

View File

@ -128,6 +128,7 @@ static char *exchange_url;
EXCHANGE_ACCOUNT_NO, USER_LOGIN_NAME, USER_LOGIN_PASS, \ EXCHANGE_ACCOUNT_NO, USER_LOGIN_NAME, USER_LOGIN_PASS, \
subject, exchange_url) subject, exchange_url)
/** /**
* Main function that will tell the interpreter what commands to * Main function that will tell the interpreter what commands to
* run. * run.
@ -138,24 +139,14 @@ static void
run (void *cls, run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct TALER_TESTING_Command commands[] = {
/****** Start of "wire" testing ******/
/** /**
* Move money to the exchange's bank account. * Checks made against /wire response.
*/ */
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1", struct TALER_TESTING_Command wire[] = {
"EUR:5.01"),
/** /**
* Make a reserve exist, according to the previous * Check if 'x-taler-bank' wire method is offered
* transfer. * by the exchange.
*/
CMD_EXEC_WIREWATCH ("wirewatch-1"),
/**
* Check if 'x-taler-bank' wire method is offered by the exchange.
*/ */
TALER_TESTING_cmd_wire ("wire-taler-bank-1", TALER_TESTING_cmd_wire ("wire-taler-bank-1",
is->exchange, is->exchange,
@ -172,9 +163,27 @@ run (void *cls,
NULL, NULL,
MHD_HTTP_OK), MHD_HTTP_OK),
#endif #endif
/****** End of "wire" testing ******/
/****** Start of withdraw and spend testing ******/ 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"),
/** /**
* Withdraw EUR:5. * Withdraw EUR:5.
@ -193,6 +202,11 @@ run (void *cls,
"create-reserve-1", "create-reserve-1",
"EUR:0", "EUR:0",
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_end ()
};
struct TALER_TESTING_Command spend[] = {
/** /**
* Spend the coin. * Spend the coin.
*/ */
@ -228,8 +242,8 @@ run (void *cls,
* FIXME: how can it get a different transaction id? There * FIXME: how can it get a different transaction id? There
* isn't such a thing actually, the exchange only knows about * isn't such a thing actually, the exchange only knows about
* contract terms' hashes. So since the contract terms are * contract terms' hashes. So since the contract terms are
* exactly the same as the previous command, how can a different * exactly the same as the previous command,
* id be generated? * how can a different id be generated?
*/ */
TALER_TESTING_cmd_deposit TALER_TESTING_cmd_deposit
("deposit-double-1", is->exchange, "withdraw-coin-1", 0, ("deposit-double-1", is->exchange, "withdraw-coin-1", 0,
@ -248,9 +262,11 @@ run (void *cls,
"{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}",
GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_FORBIDDEN), GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_FORBIDDEN),
/****** End of withdraw and spend testing ******/ TALER_TESTING_cmd_end ()
};
/****** Start of refresh testing ******/
struct TALER_TESTING_Command refresh[] = {
/** /**
* Fill reserve with EUR:5, 1ct is for fees. NOTE: the old * Fill reserve with EUR:5, 1ct is for fees. NOTE: the old
@ -350,10 +366,10 @@ run (void *cls,
/* FIXME: also test with coin that was already melted /* FIXME: also test with coin that was already melted
* (signature differs from coin that was deposited...) */ * (signature differs from coin that was deposited...) */
/****** End of refresh testing ******/ TALER_TESTING_cmd_end ()
};
/* **** Test tracking API ***** */
struct TALER_TESTING_Command track[] = {
/** /**
* Try resolving a deposit's WTID, as we never triggered * Try resolving a deposit's WTID, as we never triggered
* execution of transactions, the answer should be that * execution of transactions, the answer should be that
@ -437,9 +453,11 @@ run (void *cls,
"deposit-wtid-ok", 0, MHD_HTTP_OK, "EUR:4.98", "deposit-wtid-ok", 0, MHD_HTTP_OK, "EUR:4.98",
"EUR:0.01"), "EUR:0.01"),
/* **** End of test tracking API ***** */ TALER_TESTING_cmd_end ()
};
/* **** test /refund API ***** */
struct TALER_TESTING_Command refund[] = {
/** /**
* Fill reserve with EUR:5.01, as withdraw fee is 1 ct per * Fill reserve with EUR:5.01, as withdraw fee is 1 ct per
@ -590,10 +608,10 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_empty TALER_TESTING_cmd_check_bank_empty
("check-refund-fast-not-run"), ("check-refund-fast-not-run"),
/* ************** End of refund API testing ************* */ TALER_TESTING_cmd_end ()
};
/* ************** Test /payback API ************* */
struct TALER_TESTING_Command payback[] = {
/** /**
* Fill reserve with EUR:5.01, as withdraw fee is 1 ct per * Fill reserve with EUR:5.01, as withdraw fee is 1 ct per
* config. * config.
@ -635,8 +653,10 @@ run (void *cls,
MHD_HTTP_OK), MHD_HTTP_OK),
/* This withdrawal will test the logic to create /* This withdrawal will test the logic to create
* a "payback" element to insert into the reserve's history. */ * a "payback" element to insert into the reserve's history.
TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2-over", */
TALER_TESTING_cmd_withdraw_amount
("payback-withdraw-coin-2-over",
is->exchange, is->exchange,
"payback-create-reserve-1", "payback-create-reserve-1",
"EUR:10", "EUR:10",
@ -749,12 +769,17 @@ run (void *cls,
* coin's transaction history with payback data, as we get a * coin's transaction history with payback data, as we get a
* 404 on the DK! */ * 404 on the DK! */
TALER_TESTING_cmd_deposit TALER_TESTING_cmd_deposit
("payback-deposit-partial-after-payback", is->exchange, ("payback-deposit-partial-after-payback",
"payback-withdraw-coin-2a", 0, is->exchange,
TALER_TESTING_make_wire_details (42, "payback-withdraw-coin-2a",
0,
TALER_TESTING_make_wire_details
(42,
fakebank_url), fakebank_url),
"{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, "EUR:0.5", MHD_HTTP_NOT_FOUND), GNUNET_TIME_UNIT_ZERO,
"EUR:0.5",
MHD_HTTP_NOT_FOUND),
/* Test that revoked coins cannot be withdrawn */ /* Test that revoked coins cannot be withdrawn */
CMD_TRANSFER_TO_EXCHANGE ("payback-create-reserve-3", CMD_TRANSFER_TO_EXCHANGE ("payback-create-reserve-3",
@ -780,18 +805,45 @@ run (void *cls,
("check_bank_transfer-pr3", exchange_url, ("check_bank_transfer-pr3", exchange_url,
"EUR:1.01", 42, 2), "EUR:1.01", 42, 2),
TALER_TESTING_cmd_check_bank_empty ("check-empty-again"), TALER_TESTING_cmd_check_bank_empty
("check-empty-again"),
/* Test rejection of bogus wire transfers */ /* Test rejection of bogus wire transfers */
CMD_TRANSFER_TO_EXCHANGE_SUBJECT ("bogus-subject", CMD_TRANSFER_TO_EXCHANGE_SUBJECT
("bogus-subject",
"EUR:1.01", "EUR:1.01",
"not a reserve public key"), "not a reserve public key"),
CMD_EXEC_WIREWATCH ("wirewatch-7"), CMD_EXEC_WIREWATCH ("wirewatch-7"),
TALER_TESTING_cmd_check_bank_empty ("check-empty-from-reject"), TALER_TESTING_cmd_check_bank_empty
("check-empty-from-reject"),
/* ************** End of /payback API ************* */ TALER_TESTING_cmd_end ()
};
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),
TALER_TESTING_cmd_batch ("refund",
refund),
TALER_TESTING_cmd_batch ("payback",
payback),
/** /**
* End the suite. Fixme: better to have a label for this * End the suite. Fixme: better to have a label for this