-enable signup bonus with fakebank
This commit is contained in:
parent
8322527536
commit
ecae3c26dd
@ -489,6 +489,12 @@ struct TALER_FAKEBANK_Handle
|
|||||||
*/
|
*/
|
||||||
pthread_mutex_t big_lock;
|
pthread_mutex_t big_lock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How much money should be put into new accounts
|
||||||
|
* on /register.
|
||||||
|
*/
|
||||||
|
struct TALER_Amount signup_bonus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current transaction counter.
|
* Current transaction counter.
|
||||||
*/
|
*/
|
||||||
@ -3432,6 +3438,7 @@ post_testing_register (struct TALER_FAKEBANK_Handle *h,
|
|||||||
username,
|
username,
|
||||||
username);
|
username);
|
||||||
acc->password = GNUNET_strdup (password);
|
acc->password = GNUNET_strdup (password);
|
||||||
|
acc->balance = h->signup_bonus; /* magic money creation! */
|
||||||
}
|
}
|
||||||
return TALER_MHD_reply_static (connection,
|
return TALER_MHD_reply_static (connection,
|
||||||
MHD_HTTP_NO_CONTENT,
|
MHD_HTTP_NO_CONTENT,
|
||||||
@ -4080,12 +4087,17 @@ TALER_FAKEBANK_start2 (uint16_t port,
|
|||||||
uint64_t ram_limit,
|
uint64_t ram_limit,
|
||||||
unsigned int num_threads)
|
unsigned int num_threads)
|
||||||
{
|
{
|
||||||
|
struct TALER_Amount zero;
|
||||||
|
|
||||||
|
TALER_amount_set_zero (currency,
|
||||||
|
&zero);
|
||||||
return TALER_FAKEBANK_start3 ("localhost",
|
return TALER_FAKEBANK_start3 ("localhost",
|
||||||
port,
|
port,
|
||||||
NULL,
|
NULL,
|
||||||
currency,
|
currency,
|
||||||
ram_limit,
|
ram_limit,
|
||||||
num_threads);
|
num_threads,
|
||||||
|
&zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4095,7 +4107,8 @@ TALER_FAKEBANK_start3 (const char *hostname,
|
|||||||
const char *exchange_url,
|
const char *exchange_url,
|
||||||
const char *currency,
|
const char *currency,
|
||||||
uint64_t ram_limit,
|
uint64_t ram_limit,
|
||||||
unsigned int num_threads)
|
unsigned int num_threads,
|
||||||
|
const struct TALER_Amount *signup_bonus)
|
||||||
{
|
{
|
||||||
struct TALER_FAKEBANK_Handle *h;
|
struct TALER_FAKEBANK_Handle *h;
|
||||||
|
|
||||||
@ -4107,7 +4120,14 @@ TALER_FAKEBANK_start3 (const char *hostname,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
GNUNET_assert (strlen (currency) < TALER_CURRENCY_LEN);
|
GNUNET_assert (strlen (currency) < TALER_CURRENCY_LEN);
|
||||||
|
if (0 != strcmp (signup_bonus->currency,
|
||||||
|
currency))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
h = GNUNET_new (struct TALER_FAKEBANK_Handle);
|
h = GNUNET_new (struct TALER_FAKEBANK_Handle);
|
||||||
|
h->signup_bonus = *signup_bonus;
|
||||||
if (NULL != exchange_url)
|
if (NULL != exchange_url)
|
||||||
h->exchange_url = GNUNET_strdup (exchange_url);
|
h->exchange_url = GNUNET_strdup (exchange_url);
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of TALER
|
This file is part of TALER
|
||||||
Copyright (C) 2016, 2017 Taler Systems SA
|
Copyright (C) 2016-2022 Taler Systems SA
|
||||||
|
|
||||||
TALER is free software; you can redistribute it and/or modify it
|
TALER is free software; you can redistribute it and/or modify it
|
||||||
under the terms of the GNU General Public License as published
|
under the terms of the GNU General Public License as published
|
||||||
@ -52,6 +52,10 @@ static struct TALER_FAKEBANK_Handle *fb;
|
|||||||
*/
|
*/
|
||||||
static struct GNUNET_SCHEDULER_Task *keepalive;
|
static struct GNUNET_SCHEDULER_Task *keepalive;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Amount to credit an account with on /register.
|
||||||
|
*/
|
||||||
|
static struct TALER_Amount signup_bonus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop the process.
|
* Stop the process.
|
||||||
@ -161,12 +165,28 @@ run (void *cls,
|
|||||||
go |= TALER_MHD_GO_FORCE_CONNECTION_CLOSE;
|
go |= TALER_MHD_GO_FORCE_CONNECTION_CLOSE;
|
||||||
TALER_MHD_setup (go);
|
TALER_MHD_setup (go);
|
||||||
}
|
}
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
TALER_amount_is_valid (&signup_bonus))
|
||||||
|
{
|
||||||
|
GNUNET_assert (GNUNET_OK ==
|
||||||
|
TALER_amount_set_zero (currency_string,
|
||||||
|
&signup_bonus));
|
||||||
|
}
|
||||||
|
if (0 != strcmp (currency_string,
|
||||||
|
signup_bonus.currency))
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"Signup bonus and main currency do not match\n");
|
||||||
|
ret = EXIT_INVALIDARGUMENT;
|
||||||
|
return;
|
||||||
|
}
|
||||||
fb = TALER_FAKEBANK_start3 (hostname,
|
fb = TALER_FAKEBANK_start3 (hostname,
|
||||||
(uint16_t) port,
|
(uint16_t) port,
|
||||||
exchange_url,
|
exchange_url,
|
||||||
currency_string,
|
currency_string,
|
||||||
ram,
|
ram,
|
||||||
num_threads);
|
num_threads,
|
||||||
|
&signup_bonus);
|
||||||
GNUNET_free (hostname);
|
GNUNET_free (hostname);
|
||||||
GNUNET_free (exchange_url);
|
GNUNET_free (exchange_url);
|
||||||
GNUNET_free (currency_string);
|
GNUNET_free (currency_string);
|
||||||
@ -206,6 +226,11 @@ main (int argc,
|
|||||||
"NUM_THREADS",
|
"NUM_THREADS",
|
||||||
"size of the thread pool",
|
"size of the thread pool",
|
||||||
&num_threads),
|
&num_threads),
|
||||||
|
TALER_getopt_get_amount ('s',
|
||||||
|
"signup-bonus",
|
||||||
|
"AMOUNT",
|
||||||
|
"amount to credit newly registered account (created out of thin air)",
|
||||||
|
&signup_bonus),
|
||||||
GNUNET_GETOPT_OPTION_END
|
GNUNET_GETOPT_OPTION_END
|
||||||
};
|
};
|
||||||
enum GNUNET_GenericReturnValue iret;
|
enum GNUNET_GenericReturnValue iret;
|
||||||
|
@ -91,6 +91,7 @@ TALER_FAKEBANK_start2 (uint16_t port,
|
|||||||
* @param currency which currency should the bank offer
|
* @param currency which currency should the bank offer
|
||||||
* @param ram_limit how much memory do we use at most
|
* @param ram_limit how much memory do we use at most
|
||||||
* @param num_threads size of the thread pool, 0 to use the GNUnet scheduler
|
* @param num_threads size of the thread pool, 0 to use the GNUnet scheduler
|
||||||
|
* @param signup_bonus how much to credit new users
|
||||||
* @return NULL on error
|
* @return NULL on error
|
||||||
*/
|
*/
|
||||||
struct TALER_FAKEBANK_Handle *
|
struct TALER_FAKEBANK_Handle *
|
||||||
@ -99,7 +100,8 @@ TALER_FAKEBANK_start3 (const char *hostname,
|
|||||||
const char *exchange_url,
|
const char *exchange_url,
|
||||||
const char *currency,
|
const char *currency,
|
||||||
uint64_t ram_limit,
|
uint64_t ram_limit,
|
||||||
unsigned int num_threads);
|
unsigned int num_threads,
|
||||||
|
const struct TALER_Amount *signup_bonus);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user