the big macrofication of the traits

This commit is contained in:
Christian Grothoff 2021-10-27 15:21:48 +02:00
parent 4bfa68efee
commit 3f630eafc4
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
24 changed files with 156 additions and 3171 deletions

File diff suppressed because it is too large Load Diff

View File

@ -86,28 +86,7 @@ libtalertesting_la_SOURCES = \
testing_api_helpers_bank.c \
testing_api_helpers_exchange.c \
testing_api_loop.c \
testing_api_traits.c \
testing_api_trait_amount.c \
testing_api_trait_blinding_key.c \
testing_api_trait_cmd.c \
testing_api_trait_coin_priv.c \
testing_api_trait_contract.c \
testing_api_trait_denom_pub.c \
testing_api_trait_denom_sig.c \
testing_api_trait_exchange_pub.c \
testing_api_trait_exchange_sig.c \
testing_api_trait_fresh_coin.c \
testing_api_trait_json.c \
testing_api_trait_merchant_key.c \
testing_api_trait_number.c \
testing_api_trait_process.c \
testing_api_trait_reserve_history.c \
testing_api_trait_reserve_pub.c \
testing_api_trait_reserve_priv.c \
testing_api_trait_string.c \
testing_api_trait_time.c \
testing_api_trait_uuid.c \
testing_api_trait_wtid.c
testing_api_traits.c
libtalertesting_la_LIBADD = \
$(top_builddir)/src/lib/libtalerauditor.la \
$(top_builddir)/src/lib/libtalerexchange.la \

View File

@ -1,76 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_amount.c
* @brief offer amounts as traits.
* @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_AMOUNT "amount"
/**
* Obtain an amount from a @a cmd.
*
* @param cmd command to extract the amount from.
* @param index which amount to pick if @a cmd has multiple
* on offer
* @param[out] amount set to the amount.
* @return #GNUNET_OK on success
*/
int
TALER_TESTING_get_trait_amount_obj (const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct TALER_Amount **amount)
{
return cmd->traits (cmd->cls,
(const void **) amount,
TALER_TESTING_TRAIT_AMOUNT,
index);
}
/**
* Offer amount.
*
* @param index which amount to offer, in case there are
* multiple available.
* @param amount the amount to offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_amount_obj (unsigned int index,
const struct TALER_Amount *amount)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_AMOUNT,
.ptr = (const void *) amount
};
return ret;
}
/* end of testing_api_trait_amount.c */

View File

@ -1,77 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_blinding_key.c
* @brief offer blinding keys as traits.
* @author Christian Grothoff
* @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_BLINDING_KEY "blinding-key"
/**
* Obtain a blinding key from a @a cmd.
*
* @param cmd command to extract trait from
* @param index which coin to pick if @a cmd has multiple on offer.
* @param[out] blinding_key set to the offered blinding key.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_blinding_key
(const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct TALER_DenominationBlindingKeyP **blinding_key)
{
return cmd->traits (cmd->cls,
(const void **) blinding_key,
TALER_TESTING_TRAIT_BLINDING_KEY,
index);
}
/**
* Offer blinding key.
*
* @param index index number to associate to the offered key.
* @param blinding_key blinding key to offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_blinding_key
(unsigned int index,
const struct TALER_DenominationBlindingKeyP *blinding_key)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_BLINDING_KEY,
.ptr = (const void *) blinding_key
};
return ret;
}
/* end of testing_api_trait_blinding_key.c */

View File

@ -1,80 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_cmd.c
* @brief offers CMDs as traits.
* @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_CMD "cmd"
/**
* Obtain a command from @a cmd.
*
* @param cmd command to extract the command from.
* @param index always zero. Commands offering this
* kind of traits do not need this index. For
* example, a "batch" CMD returns always the
* CMD currently being executed.
* @param[out] _cmd where to write the wire details.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_cmd (const struct TALER_TESTING_Command *cmd,
unsigned int index,
struct TALER_TESTING_Command **_cmd)
{
return cmd->traits (cmd->cls,
(const void **) _cmd,
TALER_TESTING_TRAIT_CMD,
index);
}
/**
* Offer a command in a trait.
*
* @param index always zero. Commands offering this
* kind of traits do not need this index. For
* example, a "meta" CMD returns always the
* CMD currently being executed.
* @param cmd wire details to offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_cmd (unsigned int index,
const struct TALER_TESTING_Command *cmd)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_CMD,
.ptr = (const struct TALER_TESTING_Command *) cmd
};
return ret;
}
/* end of testing_api_trait_cmd.c */

View File

@ -1,78 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_coin_priv.c
* @brief coin priv traits.
* @author Christian Grothoff
* @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_COIN_PRIVATE_KEY "coin-private-key"
/**
* Obtain a coin private key from a @a cmd.
*
* @param cmd command to extract trait from.
* @param index index of the coin priv to obtain.
* @param[out] coin_priv set to the private key of the coin.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_coin_priv
(const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct TALER_CoinSpendPrivateKeyP **coin_priv)
{
return cmd->traits (cmd->cls,
(const void **) coin_priv,
TALER_TESTING_TRAIT_COIN_PRIVATE_KEY,
index);
}
/**
* Offer coin private key.
*
* @param index index number to associate with offered coin priv.
* @param coin_priv coin private key to offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_coin_priv
(unsigned int index,
const struct TALER_CoinSpendPrivateKeyP *coin_priv)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_COIN_PRIVATE_KEY,
.ptr = (const void *) coin_priv
};
return ret;
}
/* end of testing_api_trait_coin_priv.c */

View File

@ -1,74 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018-2020 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_contract.c
* @brief offers contract term trait.
* @author Marcello Stanisci
* @author Christian Grothoff
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_testing_lib.h"
/**
* Contains a contract terms object as a json_t.
*/
#define TALER_TESTING_TRAIT_CONTRACT_TERMS "contract-terms"
/**
* Obtain contract terms from @a cmd.
*
* @param cmd command to extract the contract terms from.
* @param index contract terms index number.
* @param[out] contract_terms where to write the contract terms.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_contract_terms (const struct TALER_TESTING_Command *cmd,
unsigned int index,
const json_t **contract_terms)
{
return cmd->traits (cmd->cls,
(const void **) contract_terms,
TALER_TESTING_TRAIT_CONTRACT_TERMS,
index);
}
/**
* Offer contract terms.
*
* @param index contract terms index number.
* @param contract_terms contract terms to offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_contract_terms (unsigned int index,
const json_t *contract_terms)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_CONTRACT_TERMS,
.ptr = (const void *) contract_terms
};
return ret;
}

View File

@ -1,77 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_denom_pub.c
* @brief denom pub traits.
* @author Christian Grothoff
* @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_DENOM_PUB "denomination-public-key"
/**
* Obtain a denomination public key from a @a cmd.
*
* @param cmd command to extract trait from
* @param index index number of the denom to obtain.
* @param[out] denom_pub set to the offered denom pub.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_denom_pub (const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct
TALER_EXCHANGE_DenomPublicKey **denom_pub)
{
return cmd->traits (cmd->cls,
(const void **) denom_pub,
TALER_TESTING_TRAIT_DENOM_PUB,
index);
}
/**
* Make a trait for a denomination public key.
*
* @param index index number to associate to the offered denom pub.
* @param denom_pub denom pub to offer with this trait.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_denom_pub (unsigned int index,
const struct
TALER_EXCHANGE_DenomPublicKey *denom_pub)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_DENOM_PUB,
.ptr = (const void *) denom_pub
};
return ret;
}
/* end of testing_api_trait_denom_pub.c */

View File

@ -1,79 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_denom_sig.c
* @brief offer denomination signatures as traits
* @author Christian Grothoff
* @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_DENOM_SIG "denomination-signature"
/**
* Obtain a denomination signature from a @a cmd.
*
* @param cmd command to extract the denom sig from.
* @param index index number associated with the denom sig.
* @param[out] denom_sig set to the offered signature.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_denom_sig
(const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct TALER_DenominationSignature **denom_sig)
{
return cmd->traits (cmd->cls,
(const void **) denom_sig,
TALER_TESTING_TRAIT_DENOM_SIG,
index);
}
/**
* Offer denom sig.
*
* @param index index number to associate to the signature on
* offer.
* @param denom_sig the denom sig on offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_denom_sig
(unsigned int index,
const struct TALER_DenominationSignature *denom_sig)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_DENOM_SIG,
.ptr = (const void *) denom_sig
};
return ret;
}
/* end of testing_api_trait_denom_sig.c */

View File

@ -1,77 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_exchange_pub.c
* @brief exchange pub traits.
* @author Christian Grothoff
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_EXCHANGE_PUB "exchange-public-key"
/**
* Obtain a exchange public key from a @a cmd.
*
* @param cmd command to extract trait from
* @param index index number of the exchange to obtain.
* @param[out] exchange_pub set to the offered exchange pub.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_exchange_pub
(const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct TALER_ExchangePublicKeyP **exchange_pub)
{
return cmd->traits (cmd->cls,
(const void **) exchange_pub,
TALER_TESTING_TRAIT_EXCHANGE_PUB,
index);
}
/**
* Make a trait for a exchange public key.
*
* @param index index number to associate to the offered exchange pub.
* @param exchange_pub exchange pub to offer with this trait.
*
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_exchange_pub
(unsigned int index,
const struct TALER_ExchangePublicKeyP *exchange_pub)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_EXCHANGE_PUB,
.ptr = (const void *) exchange_pub
};
return ret;
}
/* end of testing_api_trait_exchange_pub.c */

View File

@ -1,77 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_exchange_sig.c
* @brief exchange pub traits.
* @author Christian Grothoff
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_EXCHANGE_SIG "exchange-online-signature"
/**
* Obtain a exchange signature (online sig) from a @a cmd.
*
* @param cmd command to extract trait from
* @param index index number of the exchange to obtain.
* @param[out] exchange_sig set to the offered exchange signature.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_exchange_sig
(const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct TALER_ExchangeSignatureP **exchange_sig)
{
return cmd->traits (cmd->cls,
(const void **) exchange_sig,
TALER_TESTING_TRAIT_EXCHANGE_SIG,
index);
}
/**
* Make a trait for a exchange signature.
*
* @param index index number to associate to the offered exchange pub.
* @param exchange_sig exchange signature to offer with this trait.
*
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_exchange_sig
(unsigned int index,
const struct TALER_ExchangeSignatureP *exchange_sig)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_EXCHANGE_SIG,
.ptr = (const void *) exchange_sig
};
return ret;
}
/* end of testing_api_trait_exchange_sig.c */

View File

@ -1,77 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_fresh_coin.c
* @brief traits to offer fresh conins (after "melt" operations)
* @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_FRESH_COINS "fresh-coins"
/**
* Get a array of fresh coins.
*
* @param cmd command to extract the fresh coin from.
* @param index which array to pick if @a cmd has multiple
* on offer.
* @param[out] fresh_coins will point to the offered array.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_fresh_coins
(const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct TALER_TESTING_FreshCoinData **fresh_coins)
{
return cmd->traits (cmd->cls,
(const void **) fresh_coins,
TALER_TESTING_TRAIT_FRESH_COINS,
index);
}
/**
* Offer a _array_ of fresh coins.
*
* @param index which array of fresh coins to offer,
* if there are multiple on offer. Typically passed as
* zero.
* @param fresh_coins the array of fresh coins to offer
* @return the trait,
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_fresh_coins
(unsigned int index,
const struct TALER_TESTING_FreshCoinData *fresh_coins)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_FRESH_COINS,
.ptr = (const void *) fresh_coins
};
return ret;
}
/* end of testing_api_trait_fresh_coin.c */

View File

@ -1,165 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_json.c
* @brief offers JSON traits.
* @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_WIRE_DETAILS "wire-details"
#define TALER_TESTING_TRAIT_EXCHANGE_KEYS "exchange-keys"
#define TALER_TESTING_TRAIT_JSON "json"
/**
* Obtain serialized exchange keys from @a cmd.
*
* @param cmd command to extract the keys from.
* @param index index number associate with the keys on offer.
* @param[out] keys where to write the serialized keys.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_exchange_keys
(const struct TALER_TESTING_Command *cmd,
unsigned int index,
const json_t **keys)
{
return cmd->traits (cmd->cls,
(const void **) keys,
TALER_TESTING_TRAIT_EXCHANGE_KEYS,
index);
}
/**
* Offer serialized keys in a trait.
*
* @param index index number associate with the serial keys
* on offer.
* @param keys serialized keys to offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_exchange_keys
(unsigned int index,
const json_t *keys)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_EXCHANGE_KEYS,
.ptr = (const json_t *) keys
};
return ret;
}
/**
* Obtain wire details from @a cmd.
*
* @param cmd command to extract the wire details from.
* @param index index number associate with the wire details
* on offer; usually zero, as one command sticks to
* one bank account.
* @param[out] wire_details where to write the wire details.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_wire_details
(const struct TALER_TESTING_Command *cmd,
unsigned int index,
const json_t **wire_details)
{
return cmd->traits (cmd->cls,
(const void **) wire_details,
TALER_TESTING_TRAIT_WIRE_DETAILS,
index);
}
/**
* Offer wire details in a trait.
*
* @param index index number associate with the wire details
* on offer; usually zero, as one command sticks to
* one bank account.
* @param wire_details wire details to offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_wire_details
(unsigned int index,
const json_t *wire_details)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_WIRE_DETAILS,
.ptr = (const json_t *) wire_details
};
return ret;
}
/**
* Obtain json from @a cmd.
*
* @param cmd command to extract the json from.
* @param index index number associate with the json on offer.
* @param[out] json where to write the json.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_json (const struct TALER_TESTING_Command *cmd,
unsigned int index,
const json_t **json)
{
return cmd->traits (cmd->cls,
(const void **) json,
TALER_TESTING_TRAIT_JSON,
index);
}
/**
* Offer json in a trait.
*
* @param index index number associate with the json
* on offer.
* @param json json to offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_json (unsigned int index,
const json_t *json)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_JSON,
.ptr = (const json_t *) json
};
return ret;
}
/* end of testing_api_trait_json.c */

View File

@ -1,127 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_merchant_key.c
* @brief traits to offer peer's (private) keys
* @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_MERCHANT_PRIV "merchant-priv"
#define TALER_TESTING_TRAIT_MERCHANT_PUB "merchant-pub-pub"
/**
* Obtain a private key from a "peer". Used e.g. to obtain
* a merchant's priv to sign a /track request.
*
* @param cmd command that is offering the key.
* @param index (typically zero) which key to return if there
* are multiple on offer.
* @param[out] priv set to the key coming from @a cmd.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_merchant_priv
(const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct TALER_MerchantPrivateKeyP **priv)
{
return cmd->traits (cmd->cls,
(const void **) priv,
TALER_TESTING_TRAIT_MERCHANT_PRIV,
index);
}
/**
* Offer private key, typically done when CMD_1 needs it to
* sign a request.
*
* @param index (typically zero) which key to return if there are
* multiple on offer.
* @param priv which object should be offered.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_merchant_priv (unsigned int index,
const struct
TALER_MerchantPrivateKeyP *priv)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_MERCHANT_PRIV,
.ptr = (const void *) priv
};
return ret;
}
/**
* Obtain a public key from a "peer". Used e.g. to obtain
* a merchant's public key to use backend's API.
*
* @param cmd command offering the key.
* @param index (typically zero) which key to return if there
* are multiple on offer.
* @param[out] pub set to the key coming from @a cmd.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_merchant_pub
(const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct TALER_MerchantPublicKeyP **pub)
{
return cmd->traits (cmd->cls,
(const void **) pub,
TALER_TESTING_TRAIT_MERCHANT_PUB,
index);
}
/**
* Offer public key.
*
* @param index (typically zero) which key to return if there
* are multiple on offer. NOTE: if one key is offered, it
* is mandatory to set this as zero.
* @param pub which object should be returned.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_merchant_pub (unsigned int index,
const struct
TALER_MerchantPublicKeyP *pub)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_MERCHANT_PUB,
.ptr = (const void *) pub
};
return ret;
}
/* end of testing_api_trait_merchant_key.c */

View File

@ -1,229 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018-2020 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_number.c
* @brief traits to offer numbers
* @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_UINT "uint"
#define TALER_TESTING_TRAIT_UINT32 "uint-32"
#define TALER_TESTING_TRAIT_UINT64 "uint-64"
#define TALER_TESTING_TRAIT_INT64 "int-64"
#define TALER_TESTING_TRAIT_BANK_ROW "bank-transaction-row"
/**
* Obtain a number from @a cmd.
*
* @param cmd command to extract the number from.
* @param index the number's index number.
* @param[out] n set to the number coming from @a cmd.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_uint (const struct TALER_TESTING_Command *cmd,
unsigned int index,
const unsigned int **n)
{
return cmd->traits (cmd->cls,
(const void **) n,
TALER_TESTING_TRAIT_UINT,
index);
}
/**
* Offer a number.
*
* @param index the number's index number.
* @param n the number to offer.
* @return #GNUNET_OK on success.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_uint (unsigned int index,
const unsigned int *n)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_UINT,
.ptr = (const void *) n
};
return ret;
}
/**
* Obtain a "number" value from @a cmd, 32-bit version.
*
* @param cmd command to extract the number from.
* @param index the number's index number.
* @param[out] n set to the number coming from @a cmd.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_uint32 (const struct TALER_TESTING_Command *cmd,
unsigned int index,
const uint32_t **n)
{
return cmd->traits (cmd->cls,
(const void **) n,
TALER_TESTING_TRAIT_UINT32,
index);
}
/**
* Offer number trait, 32-bit version.
*
* @param index the number's index number.
* @param n number to offer.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_uint32 (unsigned int index,
const uint32_t *n)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_UINT32,
.ptr = (const void *) n
};
return ret;
}
/**
* Obtain a "number" value from @a cmd, 64-bit version.
*
* @param cmd command to extract the number from.
* @param index the number's index number.
* @param[out] n set to the number coming from @a cmd.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_uint64 (const struct TALER_TESTING_Command *cmd,
unsigned int index,
const uint64_t **n)
{
return cmd->traits (cmd->cls,
(const void **) n,
TALER_TESTING_TRAIT_UINT64,
index);
}
/**
* Offer number trait, 64-bit version.
*
* @param index the number's index number.
* @param n number to offer.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_uint64 (unsigned int index,
const uint64_t *n)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_UINT64,
.ptr = (const void *) n
};
return ret;
}
/**
* Obtain a "number" value from @a cmd, 64-bit signed version.
*
* @param cmd command to extract the number from.
* @param index the number's index number.
* @param[out] n set to the number coming from @a cmd.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_int64 (const struct TALER_TESTING_Command *cmd,
unsigned int index,
const int64_t **n)
{
return cmd->traits (cmd->cls,
(const void **) n,
TALER_TESTING_TRAIT_INT64,
index);
}
/**
* Offer number trait, 64-bit signed version.
*
* @param index the number's index number.
* @param n number to offer.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_int64 (unsigned int index,
const int64_t *n)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_INT64,
.ptr = (const void *) n
};
return ret;
}
/**
* Obtain a bank transaction row value from @a cmd.
*
* @param cmd command to extract the number from.
* @param[out] row set to the number coming from @a cmd.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_bank_row (const struct TALER_TESTING_Command *cmd,
const uint64_t **row)
{
return cmd->traits (cmd->cls,
(const void **) row,
TALER_TESTING_TRAIT_BANK_ROW,
0);
}
/**
* Offer bank transaction row trait.
*
* @param row number to offer.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_bank_row (const uint64_t *row)
{
struct TALER_TESTING_Trait ret = {
.index = 0,
.trait_name = TALER_TESTING_TRAIT_BANK_ROW,
.ptr = (const void *) row
};
return ret;
}
/* end of testing_api_trait_number.c */

View File

@ -1,82 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_process.c
* @brief trait offering process handles.
* @author Christian Grothoff
* @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_PROCESS "process"
/**
* Obtain location where a command stores a pointer to a process.
*
* @param cmd command to extract trait from.
* @param index which process to pick if @a cmd
* has multiple on offer.
* @param[out] processp set to the address of the pointer to the
* process.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_process
(const struct TALER_TESTING_Command *cmd,
unsigned int index,
struct GNUNET_OS_Process ***processp)
{
return cmd->traits (cmd->cls,
(const void **) processp,
TALER_TESTING_TRAIT_PROCESS,
index);
}
/**
* Offer location where a command stores a pointer to a process.
*
* @param index offered location index number, in case there are
* multiple on offer.
* @param processp process location to offer.
*
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_process
(unsigned int index,
struct GNUNET_OS_Process **processp)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_PROCESS,
.ptr = (const void *) processp
};
return ret;
}
/* end of testing_api_trait_process.c */

View File

@ -1,76 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018-2020 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_reserve_history.c
* @brief implements reserve hostry trait
* @author Christian Grothoff
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_RESERVE_HISTORY \
"reserve-history-entry"
/**
* Obtain a reserve history entry from a @a cmd.
*
* @param cmd command to extract the reserve history from.
* @param index reserve history's index number.
* @param[out] rhp set to the reserve history.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_reserve_history (
const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct TALER_EXCHANGE_ReserveHistory **rhp)
{
return cmd->traits (cmd->cls,
(const void **) rhp,
TALER_TESTING_TRAIT_RESERVE_HISTORY,
index);
}
/**
* Offer a reserve history entry.
*
* @param index reserve pubs's index number.
* @param rh reserve history entry to offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_reserve_history (
unsigned int index,
const struct TALER_EXCHANGE_ReserveHistory *rh)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_RESERVE_HISTORY,
.ptr = (const void *) rh
};
return ret;
}
/* end of testing_api_trait_reserve_history.c */

View File

@ -1,76 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_reserve_priv.c
* @brief implements reserve private key trait
* @author Christian Grothoff
* @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_RESERVE_PRIVATE_KEY \
"reserve-private-key"
/**
* Obtain a reserve private key from a @a cmd.
*
* @param cmd command to extract the reserve priv from.
* @param index reserve priv's index number.
* @param[out] reserve_priv set to the reserve priv.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_reserve_priv
(const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct TALER_ReservePrivateKeyP **reserve_priv)
{
return cmd->traits (cmd->cls,
(const void **) reserve_priv,
TALER_TESTING_TRAIT_RESERVE_PRIVATE_KEY,
index);
}
/**
* Offer a reserve private key.
*
* @param index reserve priv's index number.
* @param reserve_priv reserve private key to offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_reserve_priv
(unsigned int index,
const struct TALER_ReservePrivateKeyP *reserve_priv)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_RESERVE_PRIVATE_KEY,
.ptr = (const void *) reserve_priv
};
return ret;
}
/* end of testing_api_trait_reserve_priv.c */

View File

@ -1,78 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018-2020 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_reserve_pub.c
* @brief implements reserve public key trait
* @author Christian Grothoff
* @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_RESERVE_PUBLIC_KEY \
"reserve-public-key"
/**
* Obtain a reserve public key from a @a cmd.
*
* @param cmd command to extract the reserve pub from.
* @param index reserve pub's index number.
* @param[out] reserve_pub set to the reserve pub.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_reserve_pub
(const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct TALER_ReservePublicKeyP **reserve_pub)
{
if (NULL == cmd->traits)
return GNUNET_SYSERR;
return cmd->traits (cmd->cls,
(const void **) reserve_pub,
TALER_TESTING_TRAIT_RESERVE_PUBLIC_KEY,
index);
}
/**
* Offer a reserve public key.
*
* @param index reserve pub's index number.
* @param reserve_pub reserve public key to offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_reserve_pub
(unsigned int index,
const struct TALER_ReservePublicKeyP *reserve_pub)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_RESERVE_PUBLIC_KEY,
.ptr = (const void *) reserve_pub
};
return ret;
}
/* end of testing_api_trait_reserve_pub.c */

View File

@ -1,231 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018-2020 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_string.c
* @brief offers strings traits.
* @author Marcello Stanisci
* @author Christian Grothoff
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
/**
* Some string. Avoid, use something more precise!
*/
#define TALER_TESTING_TRAIT_STRING "string"
/**
* An HTTP-URL.
*/
#define TALER_TESTING_TRAIT_URL "url"
/**
* A PAYTO-URL.
*/
#define TALER_TESTING_TRAIT_PAYTO "payto"
/**
* String identifying an order.
*/
#define TALER_TESTING_TRAIT_ORDER_ID "order-id"
/**
* Obtain a string from @a cmd.
*
* @param cmd command to extract the subject from.
* @param index index number associated with the transfer
* subject to offer.
* @param[out] s where to write the offered
* string
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_string (const struct TALER_TESTING_Command *cmd,
unsigned int index,
const char **s)
{
return cmd->traits (cmd->cls,
(const void **) s,
TALER_TESTING_TRAIT_STRING,
index);
}
/**
* Offer string.
*
* @param index index number associated with the transfer
* subject being offered.
* @param s transfer subject to offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_string (unsigned int index,
const char *s)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_STRING,
.ptr = (const void *) s
};
return ret;
}
/**
* Obtain a HTTP url from @a cmd.
*
* @param cmd command to extract the url from.
* @param index which url is to be picked, in case
* multiple are offered.
* @param[out] url where to write the url.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_url (const struct TALER_TESTING_Command *cmd,
unsigned int index,
const char **url)
{
return cmd->traits (cmd->cls,
(const void **) url,
TALER_TESTING_TRAIT_URL,
index);
}
/**
* Offer HTTP url in a trait.
*
* @param index which url is to be picked,
* in case multiple are offered.
* @param url the url to offer.
*
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_url (unsigned int index,
const char *url)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_URL,
.ptr = (const void *) url
};
GNUNET_assert ( (NULL == url) ||
(0 != strncasecmp (url,
"payto://",
strlen ("payto://"))) );
return ret;
}
/**
* Obtain a order id from @a cmd.
*
* @param cmd command to extract the order id from.
* @param index which order id is to be picked, in case
* multiple are offered.
* @param[out] order_id where to write the order id.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_order_id (const struct TALER_TESTING_Command *cmd,
unsigned int index,
const char **order_id)
{
return cmd->traits (cmd->cls,
(const void **) order_id,
TALER_TESTING_TRAIT_ORDER_ID,
index);
}
/**
* Offer order id in a trait.
*
* @param index which order id is to be offered,
* in case multiple are offered.
* @param order_id the order id to offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_order_id (unsigned int index,
const char *order_id)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_ORDER_ID,
.ptr = (const void *) order_id
};
return ret;
}
/**
* Obtain a PAYTO-url from @a cmd.
*
* @param cmd command to extract the url from.
* @param pt which url is to be picked, in case
* multiple are offered.
* @param[out] url where to write the url.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_payto (const struct TALER_TESTING_Command *cmd,
enum TALER_TESTING_PaytoType pt,
const char **url)
{
return cmd->traits (cmd->cls,
(const void **) url,
TALER_TESTING_TRAIT_PAYTO,
(unsigned int) pt);
}
/**
* Offer a "payto" URL reference.
*
* @param pt which reference is to be offered,
* in case multiple are offered.
* @param payto_uri the payto URI
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_payto (enum TALER_TESTING_PaytoType pt,
const char *payto_uri)
{
struct TALER_TESTING_Trait ret = {
.index = (unsigned int) pt,
.trait_name = TALER_TESTING_TRAIT_PAYTO,
.ptr = (const void *) payto_uri,
};
GNUNET_assert (0 == strncasecmp (payto_uri,
"payto://",
strlen ("payto://")));
return ret;
}
/* end of testing_api_trait_string.c */

View File

@ -1,120 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_time.c
* @brief traits to offer time stamps.
* @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_TIME_ABS "time-abs"
#define TALER_TESTING_TRAIT_TIME_REL "time-rel"
/**
* Obtain a absolute time from @a cmd.
*
* @param cmd command to extract trait from
* @param index which time stamp to pick if
* @a cmd has multiple on offer.
* @param[out] time set to the wanted WTID.
* @return #GNUNET_OK on success
*/
int
TALER_TESTING_get_trait_absolute_time
(const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct GNUNET_TIME_Absolute **time)
{
return cmd->traits (cmd->cls,
(const void **) time,
TALER_TESTING_TRAIT_TIME_ABS,
index);
}
/**
* Offer a absolute time.
*
* @param index associate the object with this index
* @param time which object should be returned
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_absolute_time
(unsigned int index,
const struct GNUNET_TIME_Absolute *time)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_TIME_ABS,
.ptr = (const void *) time
};
return ret;
}
/**
* Obtain a relative time from @a cmd.
*
* @param cmd command to extract trait from
* @param index which time to pick if
* @a cmd has multiple on offer.
* @param[out] time set to the wanted WTID.
* @return #GNUNET_OK on success
*/
int
TALER_TESTING_get_trait_relative_time (
const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct GNUNET_TIME_Relative **time)
{
return cmd->traits (cmd->cls,
(const void **) time,
TALER_TESTING_TRAIT_TIME_REL,
index);
}
/**
* Offer a relative time.
*
* @param index associate the object with this index
* @param time which object should be returned
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_relative_time (
unsigned int index,
const struct GNUNET_TIME_Relative *time)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_TIME_REL,
.ptr = (const void *) time
};
return ret;
}
/* end of testing_api_trait_time.c */

View File

@ -1,117 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2020 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_uuid.c
* @brief offer any trait that is passed over as a uuid.
* @author Jonathan Buchanan
*/
#include "platform.h"
#include "taler_signatures.h"
#include "taler_exchange_service.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_UUID "uuid"
#define TALER_TESTING_TRAIT_CLAIM_TOKEN "claim_token"
/**
* Obtain a uuid from @a cmd.
*
* @param cmd command to extract the uuid from.
* @param index which amount to pick if @a cmd has multiple
* on offer
* @param[out] uuid where to write the uuid.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_uuid (const struct TALER_TESTING_Command *cmd,
unsigned int index,
struct GNUNET_Uuid **uuid)
{
return cmd->traits (cmd->cls,
(const void **) uuid,
TALER_TESTING_TRAIT_UUID,
index);
}
/**
* Offer a uuid in a trait.
*
* @param index which uuid to offer, in case there are
* multiple available.
* @param uuid the uuid to offer.
*
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_uuid (unsigned int index,
const struct GNUNET_Uuid *uuid)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_UUID,
.ptr = (const void *) uuid
};
return ret;
}
/**
* Obtain a claim token from @a cmd.
*
* @param cmd command to extract the token from.
* @param index which amount to pick if @a cmd has multiple
* on offer
* @param[out] ct where to write the token.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_claim_token (const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct TALER_ClaimTokenP **ct)
{
return cmd->traits (cmd->cls,
(const void **) ct,
TALER_TESTING_TRAIT_CLAIM_TOKEN,
index);
}
/**
* Offer a claim token in a trait.
*
* @param index which token to offer, in case there are
* multiple available.
* @param ct the token to offer.
*
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_claim_token (unsigned int index,
const struct TALER_ClaimTokenP *ct)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_CLAIM_TOKEN,
.ptr = (const void *) ct
};
return ret;
}

View File

@ -1,76 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2018 Taler Systems SA
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.
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.
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/>
*/
/**
* @file testing/testing_api_trait_number.c
* @brief traits to offer numbers
* @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_testing_lib.h"
#define TALER_TESTING_TRAIT_WTID "wtid"
/**
* Obtain a WTID value from @a cmd.
*
* @param cmd command to extract trait from
* @param index which WTID to pick if @a cmd has multiple on
* offer
* @param[out] wtid set to the wanted WTID.
* @return #GNUNET_OK on success
*/
int
TALER_TESTING_get_trait_wtid
(const struct TALER_TESTING_Command *cmd,
unsigned int index,
const struct TALER_WireTransferIdentifierRawP **wtid)
{
return cmd->traits (cmd->cls,
(const void **) wtid,
TALER_TESTING_TRAIT_WTID,
index);
}
/**
* Offer a WTID.
*
* @param index associate the object with this index
* @param wtid which object should be returned
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_wtid
(unsigned int index,
const struct TALER_WireTransferIdentifierRawP *wtid)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_WTID,
.ptr = (const void *) wtid
};
return ret;
}
/* end of testing_api_trait_number.c */

View File

@ -1,6 +1,6 @@
/*
This file is part of TALER
Copyright (C) 2018 Taler Systems SA
Copyright (C) 2018, 2021 Taler Systems SA
TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@ -29,6 +29,11 @@
#include "taler_testing_lib.h"
TALER_TESTING_SIMPLE_TRAITS (TALER_TESTING_MAKE_IMPL_SIMPLE_TRAIT)
TALER_TESTING_INDEXED_TRAITS (TALER_TESTING_MAKE_IMPL_INDEXED_TRAIT)
/**
* End a trait array. Usually, commands offer several traits,
* and put them in arrays.
@ -46,16 +51,7 @@ TALER_TESTING_trait_end ()
}
/**
* Pick the chosen trait from the traits array.
*
* @param traits the traits array.
* @param ret where to store the result.
* @param trait type of the trait to extract.
* @param index index number of the object to extract.
* @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
*/
int
enum GNUNET_GenericReturnValue
TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits,
const void **ret,
const char *trait,
@ -63,7 +59,8 @@ TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits,
{
for (unsigned int i = 0; NULL != traits[i].trait_name; i++)
{
if ( (0 == strcmp (trait, traits[i].trait_name)) &&
if ( (0 == strcmp (trait,
traits[i].trait_name)) &&
(index == traits[i].index) )
{
*ret = (void *) traits[i].ptr;
@ -72,8 +69,8 @@ TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits,
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Trait %s/%u not found.\n",
trait, index);
trait,
index);
return GNUNET_SYSERR;
}