diff options
Diffstat (limited to 'src/exchangedb/test_exchangedb.c')
-rw-r--r-- | src/exchangedb/test_exchangedb.c | 71 |
1 files changed, 49 insertions, 22 deletions
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index eea484e94..fe3ed7854 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c | |||
@@ -833,6 +833,8 @@ static uint64_t deposit_rowid; | |||
833 | * @param cls closure a `struct TALER_EXCHANGEDB_Deposit *` | 833 | * @param cls closure a `struct TALER_EXCHANGEDB_Deposit *` |
834 | * @param rowid unique ID for the deposit in our DB, used for marking | 834 | * @param rowid unique ID for the deposit in our DB, used for marking |
835 | * it as 'tiny' or 'done' | 835 | * it as 'tiny' or 'done' |
836 | * @param exchange_timestamp when did the deposit happen | ||
837 | * @param wallet_timestamp when did the wallet sign the contract | ||
836 | * @param merchant_pub public key of the merchant | 838 | * @param merchant_pub public key of the merchant |
837 | * @param coin_pub public key of the coin | 839 | * @param coin_pub public key of the coin |
838 | * @param amount_with_fee amount that was deposited including fee | 840 | * @param amount_with_fee amount that was deposited including fee |
@@ -846,6 +848,8 @@ static uint64_t deposit_rowid; | |||
846 | static enum GNUNET_DB_QueryStatus | 848 | static enum GNUNET_DB_QueryStatus |
847 | deposit_cb (void *cls, | 849 | deposit_cb (void *cls, |
848 | uint64_t rowid, | 850 | uint64_t rowid, |
851 | struct GNUNET_TIME_Absolute exchange_timestamp, | ||
852 | struct GNUNET_TIME_Absolute wallet_timestamp, | ||
849 | const struct TALER_MerchantPublicKeyP *merchant_pub, | 853 | const struct TALER_MerchantPublicKeyP *merchant_pub, |
850 | const struct TALER_CoinSpendPublicKeyP *coin_pub, | 854 | const struct TALER_CoinSpendPublicKeyP *coin_pub, |
851 | const struct TALER_Amount *amount_with_fee, | 855 | const struct TALER_Amount *amount_with_fee, |
@@ -890,7 +894,8 @@ deposit_cb (void *cls, | |||
890 | * | 894 | * |
891 | * @param cls closure | 895 | * @param cls closure |
892 | * @param rowid unique serial ID for the deposit in our DB | 896 | * @param rowid unique serial ID for the deposit in our DB |
893 | * @param timestamp when did the deposit happen | 897 | * @param exchange_timestamp when did the deposit happen |
898 | * @param wallet_timestamp when did the wallet sign the contract | ||
894 | * @param merchant_pub public key of the merchant | 899 | * @param merchant_pub public key of the merchant |
895 | * @param denom_pub denomination of the @a coin_pub | 900 | * @param denom_pub denomination of the @a coin_pub |
896 | * @param coin_pub public key of the coin | 901 | * @param coin_pub public key of the coin |
@@ -908,7 +913,8 @@ deposit_cb (void *cls, | |||
908 | static int | 913 | static int |
909 | audit_deposit_cb (void *cls, | 914 | audit_deposit_cb (void *cls, |
910 | uint64_t rowid, | 915 | uint64_t rowid, |
911 | struct GNUNET_TIME_Absolute timestamp, | 916 | struct GNUNET_TIME_Absolute exchange_timestamp, |
917 | struct GNUNET_TIME_Absolute wallet_timestamp, | ||
912 | const struct TALER_MerchantPublicKeyP *merchant_pub, | 918 | const struct TALER_MerchantPublicKeyP *merchant_pub, |
913 | const struct TALER_DenominationPublicKey *denom_pub, | 919 | const struct TALER_DenominationPublicKey *denom_pub, |
914 | const struct TALER_CoinSpendPublicKeyP *coin_pub, | 920 | const struct TALER_CoinSpendPublicKeyP *coin_pub, |
@@ -1878,15 +1884,27 @@ run (void *cls) | |||
1878 | plugin->ensure_coin_known (plugin->cls, | 1884 | plugin->ensure_coin_known (plugin->cls, |
1879 | session, | 1885 | session, |
1880 | &deposit.coin)); | 1886 | &deposit.coin)); |
1881 | FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != | 1887 | { |
1882 | plugin->insert_deposit (plugin->cls, | 1888 | struct GNUNET_TIME_Absolute now; |
1889 | struct GNUNET_TIME_Absolute r; | ||
1890 | struct TALER_Amount deposit_fee; | ||
1891 | |||
1892 | now = GNUNET_TIME_absolute_get (); | ||
1893 | GNUNET_TIME_round_abs (&now); | ||
1894 | FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != | ||
1895 | plugin->insert_deposit (plugin->cls, | ||
1896 | session, | ||
1897 | now, | ||
1898 | &deposit)); | ||
1899 | FAILIF (1 != | ||
1900 | plugin->have_deposit (plugin->cls, | ||
1883 | session, | 1901 | session, |
1884 | &deposit)); | 1902 | &deposit, |
1885 | FAILIF (1 != | 1903 | GNUNET_YES, |
1886 | plugin->have_deposit (plugin->cls, | 1904 | &deposit_fee, |
1887 | session, | 1905 | &r)); |
1888 | &deposit, | 1906 | FAILIF (now.abs_value_us != r.abs_value_us); |
1889 | GNUNET_YES)); | 1907 | } |
1890 | { | 1908 | { |
1891 | struct GNUNET_TIME_Absolute start_range; | 1909 | struct GNUNET_TIME_Absolute start_range; |
1892 | struct GNUNET_TIME_Absolute end_range; | 1910 | struct GNUNET_TIME_Absolute end_range; |
@@ -1983,18 +2001,27 @@ run (void *cls) | |||
1983 | session, | 2001 | session, |
1984 | "test-2")); | 2002 | "test-2")); |
1985 | RND_BLK (&deposit2.merchant_pub); /* should fail if merchant is different */ | 2003 | RND_BLK (&deposit2.merchant_pub); /* should fail if merchant is different */ |
1986 | FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != | 2004 | { |
1987 | plugin->have_deposit (plugin->cls, | 2005 | struct GNUNET_TIME_Absolute r; |
1988 | session, | 2006 | struct TALER_Amount deposit_fee; |
1989 | &deposit2, | 2007 | |
1990 | GNUNET_YES)); | 2008 | FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != |
1991 | deposit2.merchant_pub = deposit.merchant_pub; | 2009 | plugin->have_deposit (plugin->cls, |
1992 | RND_BLK (&deposit2.coin.coin_pub); /* should fail if coin is different */ | 2010 | session, |
1993 | FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != | 2011 | &deposit2, |
1994 | plugin->have_deposit (plugin->cls, | 2012 | GNUNET_YES, |
1995 | session, | 2013 | &deposit_fee, |
1996 | &deposit2, | 2014 | &r)); |
1997 | GNUNET_YES)); | 2015 | deposit2.merchant_pub = deposit.merchant_pub; |
2016 | RND_BLK (&deposit2.coin.coin_pub); /* should fail if coin is different */ | ||
2017 | FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != | ||
2018 | plugin->have_deposit (plugin->cls, | ||
2019 | session, | ||
2020 | &deposit2, | ||
2021 | GNUNET_YES, | ||
2022 | &deposit_fee, | ||
2023 | &r)); | ||
2024 | } | ||
1998 | FAILIF (GNUNET_OK != | 2025 | FAILIF (GNUNET_OK != |
1999 | test_melting (session)); | 2026 | test_melting (session)); |
2000 | FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != | 2027 | FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != |