From 0cef479e00a89a6649c747f91aba5208affd30e0 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 31 May 2016 10:39:11 +0200 Subject: [PATCH] extend test to cover GC --- src/benchmark/taler-exchange-benchmark | Bin 24848 -> 25920 bytes src/exchangedb/plugin_exchangedb_postgres.c | 6 ++ src/exchangedb/test_exchangedb.c | 67 ++++++++++++++++++-- 3 files changed, 69 insertions(+), 4 deletions(-) diff --git a/src/benchmark/taler-exchange-benchmark b/src/benchmark/taler-exchange-benchmark index ae793dc928edf868454e8568abb3ab639222a5ed..ea5f1ce45dc1ca33bf91d35a3b7270a395ac181f 100755 GIT binary patch delta 7041 zcmaJ`4_H*!mA~)JJQ(>q{2vhT!2^{4Ab%vrxS$Y6qsE{_w~9U^s1S>qpf$URLnB)0 zG+FdUnEf>WKFTWa5T{QHi!$`faMba}U& zbWGEQq1m068MCuQ)~Rt>DUd;?f;<)9^MJC|;@X{VSW{qDa|q~RKOPL80ykTC01n5) z?N|VA8AciF4ZxKE{G5Ti7)?NbW;-7+z-EG=7Xt8v0DK?-4++3M0eENtekA};Vy+R* zP=F$Q1ZGUrg+xI{2+rtinl2c^BL!!4c1;%y;da3pokP_Q(osS+H?>q+Sy@S$ZsLox<2?|C8bC7G)4?G^HONv5iMyM_EX$+Vli z2Zj7^kX`Gk{N7FhJVXYx<-Bb|ZYG)H_HGjL10+-Ry}FRULGlEW7YVtRWU98eQpod2 zrYd`jgglGnFp^avPft)?Y&})gYZt&&GN5XDnUHfxrYd@`+yIc7PBK-`J0RpFlBsIm z^Fod$nTqA@6>qXw|Ha6wYa=IBGj{Czn$GH+`JEun9YYb$jt{m@JVw5#f>HISNZ}iRaXW#m zzK;sGw!oB6lD^LQ?SBdfZ``mrJNWOyl1q(Yk&`gMn5gZp4n)efMAcymPYY77KdWp7 zBz-Dep0cZ43m?dWovcg^*xj^0;Q+(yR_Blwdv{VA%oNBP?4>riszcwt29 zeW4hDP-9Q_!AR&u_@3{;sJ~{Y1_R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z4z@Yam`)ELROVLYuwMoiN{8G`4K(G^;|!JJdv6z{`Tv6roN7AZW{s7FH6xlzwk`o( zR0k`mY9F^aomACAE-AvqON&0l0!THDx%<9f`LQUCoBE!vdP@=?WZ$e=EN*AEt3B*u z%^q=E-%D5jLUwpo`2AB(7xw4nC4FDGZoTQiid#&6{TSoXX_X1z!vHQMnwna>r1SLE{q{VU&O`+R|ak83cpXq$urVJPvz zY?8)=)A=DiZ3c}=aMI_#jh}r>!u$JDWxbPL{Hf4QfXYqyi9Bp}K=DdGSKk@sPU(6* zjeNtyWC%x=2xlj>?nn?XM>Ss0tvARk5>~rzPHtejK_FoesN!~&K7!23B|^tt8}8e( z?f#Ct9=sD&UQS?|>m`+>5UFFHcop@_t*V}8RmC+@rFI#T3i`q~=Ub%@tZd%~Z<>Cj zVy;IwRNM8Fv^h613oUGJdqtYQCh&JfYkPH?ew_B_vmS_grt#OuC`A46#51Jxw(2zf z%*66)g{U8u_(P-zqW+IXe-RsnsGo~?@N{mhPSaEVkejta)H8~C@7Y+(lL7dlZ< zmGV5S6>zG8_1s>YdfcCg{~Y^4n|n`3fizIXoE^1NSCF*=?pw!t0R2HW3K+kEIXBJ! EFYr--aR2}S diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 72f85e7bb..5fbaa26b3 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -4298,6 +4298,12 @@ postgres_gc (void *cls) conn = connect_to_postgres (pc); if (NULL == conn) return GNUNET_SYSERR; + if (GNUNET_OK != + postgres_prepare (conn)) + { + PQfinish (conn); + return GNUNET_SYSERR; + } result = GNUNET_PQ_exec_prepared (conn, "gc_prewire", params_none); diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 2dee9a7ee..b42fb30f3 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -202,11 +202,17 @@ destroy_denom_key_pair (struct DenomKeyPair *dkp) * * @param size the size of the denomination key * @param session the DB session + * @param now time to use for key generation, legal expiration will be 3h later. + * @param fee_withdraw withdraw fee to use + * @param fee_deposit deposit fee to use + * @param fee_refresh refresh fee to use + * @param fee_refund refund fee to use * @return the denominaiton key pair; NULL upon error */ static struct DenomKeyPair * create_denom_key_pair (unsigned int size, struct TALER_EXCHANGEDB_Session *session, + struct GNUNET_TIME_Absolute now, const struct TALER_Amount *value, const struct TALER_Amount *fee_withdraw, const struct TALER_Amount *fee_deposit, @@ -216,7 +222,6 @@ create_denom_key_pair (unsigned int size, struct DenomKeyPair *dkp; struct TALER_EXCHANGEDB_DenominationKeyIssueInformation dki; struct TALER_EXCHANGEDB_DenominationKeyInformationP issue2; - struct GNUNET_TIME_Absolute now; dkp = GNUNET_new (struct DenomKeyPair); dkp->priv.rsa_private_key = GNUNET_CRYPTO_rsa_private_key_create (size); @@ -230,7 +235,6 @@ create_denom_key_pair (unsigned int size, 0, sizeof (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation)); dki.denom_pub = dkp->pub; - now = GNUNET_TIME_absolute_get (); GNUNET_TIME_round_abs (&now); dki.issue.properties.start = GNUNET_TIME_absolute_hton (now); dki.issue.properties.expire_withdraw = GNUNET_TIME_absolute_hton @@ -558,7 +562,7 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) struct TALER_EXCHANGEDB_LinkDataList *ldl; struct TALER_EXCHANGEDB_LinkDataList *ldlp; struct TALER_DenominationSignature ev_sigs[MELT_NEW_COINS]; - unsigned int cnt; + unsigned int cnt; unsigned int i; int ret; @@ -575,6 +579,7 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) /* create a denomination (value: 1; fraction: 100) */ dkp = create_denom_key_pair (512, session, + GNUNET_TIME_absolute_get (), &value, &fee_withdraw, &fee_deposit, @@ -645,6 +650,7 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) { new_dkp[cnt] = create_denom_key_pair (1024, session, + GNUNET_TIME_absolute_get (), &value, &fee_withdraw, &fee_deposit, @@ -974,6 +980,54 @@ deposit_cb (void *cls, } +/** + * Test garbage collection. + * + * @param session DB session to use + * @return #GNUNET_OK on success + */ +static int +test_gc (struct TALER_EXCHANGEDB_Session *session) +{ + struct DenomKeyPair *dkp; + struct GNUNET_TIME_Absolute now; + struct GNUNET_TIME_Absolute past; + struct TALER_EXCHANGEDB_DenominationKeyInformationP issue2; + + now = GNUNET_TIME_absolute_get (); + past = GNUNET_TIME_absolute_subtract (now, + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, + 4)); + dkp = create_denom_key_pair (1024, + session, + past, + &value, + &fee_withdraw, + &fee_deposit, + &fee_refresh, + &fee_refund); + if (GNUNET_OK != + plugin->gc (plugin->cls)) + { + GNUNET_break(0); + destroy_denom_key_pair (dkp); + return GNUNET_SYSERR; + } + if (GNUNET_OK == + plugin->get_denomination_info (plugin->cls, + session, + &dkp->pub, + &issue2)) + { + GNUNET_break(0); + destroy_denom_key_pair (dkp); + return GNUNET_SYSERR; + } + destroy_denom_key_pair (dkp); + return GNUNET_OK; +} + + /** * Main function that will be run by the scheduler. * @@ -1093,7 +1147,9 @@ run (void *cls) value.fraction * 2, value.currency)); result = 5; - dkp = create_denom_key_pair (1024, session, + dkp = create_denom_key_pair (1024, + session, + GNUNET_TIME_absolute_get (), &value, &fee_withdraw, &fee_deposit, @@ -1427,6 +1483,9 @@ run (void *cls) transaction_id_wt, &cb_wtid_check, &cb_wtid_never)); + FAILIF (GNUNET_OK != + test_gc (session)); + result = 0; drop: