From 5bf6fd61ec869c46f8d06ec34c42b34a264081f9 Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Fri, 22 Sep 2023 13:22:15 -0400 Subject: [PATCH] ODIS E2E test fix (#10574) * prevent usedQuota from being increased when bypassing quota * make result warning optional * add warning to E2E test --- .../combiner/test/end-to-end/pnp.test.ts | 16 +++++++++++----- .../signer/src/pnp/endpoints/sign/action.ts | 4 +++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/phone-number-privacy/combiner/test/end-to-end/pnp.test.ts b/packages/phone-number-privacy/combiner/test/end-to-end/pnp.test.ts index 17c5f0fdb61..63f01d1729f 100644 --- a/packages/phone-number-privacy/combiner/test/end-to-end/pnp.test.ts +++ b/packages/phone-number-privacy/combiner/test/end-to-end/pnp.test.ts @@ -71,7 +71,7 @@ describe(`Running against service deployed at ${combinerUrl} w/ blockchain provi performedQueryCount: res.performedQueryCount, totalQuota: res.totalQuota, remainingQuota: res.totalQuota - res.performedQueryCount, - warnings: [], + warnings: res.warnings ?? [], }) }) @@ -86,7 +86,7 @@ describe(`Running against service deployed at ${combinerUrl} w/ blockchain provi performedQueryCount: res.performedQueryCount, totalQuota: res.totalQuota, remainingQuota: res.totalQuota - res.performedQueryCount, - warnings: [], + warnings: res.warnings ?? [], }) }) @@ -101,7 +101,7 @@ describe(`Running against service deployed at ${combinerUrl} w/ blockchain provi performedQueryCount: res1.performedQueryCount, totalQuota: res1.totalQuota, remainingQuota: res1.totalQuota - res1.performedQueryCount, - warnings: [], + warnings: res1.warnings ?? [], } expect(res1).toStrictEqual(expectedRes) const res2 = await OdisUtils.Quota.getPnpQuotaStatus( @@ -210,7 +210,10 @@ describe(`Running against service deployed at ${combinerUrl} w/ blockchain provi performedQueryCount: startingPerformedQueryCount + 1, totalQuota: startingTotalQuota, remainingQuota: startingTotalQuota - (startingPerformedQueryCount + 1), - warnings: [], + warnings: [ + 'CELO_ODIS_WARN_17 SIGNER Discrepancies detected in signer responses', + 'CELO_ODIS_WARN_18 SIGNER Discrepancy found in signers performed query count measurements', + ], }) }) @@ -233,7 +236,10 @@ describe(`Running against service deployed at ${combinerUrl} w/ blockchain provi performedQueryCount: startingPerformedQueryCount + 1, totalQuota: startingTotalQuota, remainingQuota: startingTotalQuota - (startingPerformedQueryCount + 1), - warnings: [], + warnings: [ + 'CELO_ODIS_WARN_17 SIGNER Discrepancies detected in signer responses', + 'CELO_ODIS_WARN_18 SIGNER Discrepancy found in signers performed query count measurements', + ], }) }) }) diff --git a/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/action.ts b/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/action.ts index 63911081042..f5dd8b4ce4d 100644 --- a/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/action.ts +++ b/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/action.ts @@ -113,7 +113,9 @@ export function pnpSign( signature, ctx ) - usedQuota++ + if (!bypassQuotaForE2ETesting(config.test_quota_bypass_percentage, request.body)) { + usedQuota++ + } } else { Counters.duplicateRequests.inc() logger.info('Request already exists in db. Will service request without charging quota.')