From 357c68d7ef6467259411b0ce67d5b21d55090885 Mon Sep 17 00:00:00 2001 From: Logan Nguyen Date: Fri, 31 Jan 2025 20:48:16 -0600 Subject: [PATCH] fix: fixed HbarLimitService unit test Signed-off-by: Logan Nguyen Revert "fixed shouldLimit v1" This reverts commit 2f745e6f6188d7c4d84da931793544200420d073. Reapply "fixed shouldLimit v1" This reverts commit f280bbf311a4e407ed2c158d372581e2b8b36e25. s Signed-off-by: Logan Nguyen Revert "fix: fixed HbarLimitService unit test" This reverts commit ec28eee0f22911714095f9a9c3e69d42e286eb17. Reapply "fix: fixed HbarLimitService unit test" This reverts commit e27bae25cb51f5a49db525c5e66e08b3da2c3c15. Signed-off-by: Logan Nguyen --- .../hbarLimitService/hbarLimitService.spec.ts | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/relay/tests/lib/services/hbarLimitService/hbarLimitService.spec.ts b/packages/relay/tests/lib/services/hbarLimitService/hbarLimitService.spec.ts index c39ffe7f6..cc60341a5 100644 --- a/packages/relay/tests/lib/services/hbarLimitService/hbarLimitService.spec.ts +++ b/packages/relay/tests/lib/services/hbarLimitService/hbarLimitService.spec.ts @@ -24,7 +24,6 @@ import { AccountId, Hbar } from '@hashgraph/sdk'; import chai, { expect } from 'chai'; import chaiAsPromised from 'chai-as-promised'; import { randomBytes, uuidV4 } from 'ethers'; -import { Long } from 'long'; import pino, { Logger } from 'pino'; import { Counter, Gauge, Registry } from 'prom-client'; import sinon from 'sinon'; @@ -189,12 +188,13 @@ describe('HBAR Rate Limit Service', function () { }); describe('shouldLimit', function () { - const operatorEnvs = [{ OPERATOR_ID_MAIN: ConfigService.get('OPERATOR_ID_MAIN') }, { OPERATOR_ID_MAIN: null }]; + const operatorEnvs = [ + { OPERATOR_ID_MAIN: ConfigService.get('OPERATOR_ID_MAIN') }, + { OPERATOR_ID_MAIN: zeroAddress() }, + ]; operatorEnvs.forEach((operatorEnv) => { - const operatorAddress = operatorEnv.OPERATOR_ID_MAIN - ? prepend0x(AccountId.fromString(operatorEnv.OPERATOR_ID_MAIN).toSolidityAddress()) - : zeroAddress(); + const operatorAddress = prepend0x(AccountId.fromString(operatorEnv.OPERATOR_ID_MAIN).toSolidityAddress()); withOverriddenEnvsInMochaTest(operatorEnv, () => { describe('based on evmAddress', async function () { @@ -877,7 +877,10 @@ describe('HBAR Rate Limit Service', function () { expect(operatorPlan.amountSpent).to.eq(expense); }; - const operatorEnvs = [{ OPERATOR_ID_MAIN: ConfigService.get('OPERATOR_ID_MAIN') }, { OPERATOR_ID_MAIN: null }]; + const operatorEnvs = [ + { OPERATOR_ID_MAIN: ConfigService.get('OPERATOR_ID_MAIN') }, + { OPERATOR_ID_MAIN: zeroAddress() }, + ]; operatorEnvs.forEach((operatorEnv) => { const operatorAddress = operatorEnv.OPERATOR_ID_MAIN @@ -950,7 +953,10 @@ describe('HBAR Rate Limit Service', function () { ).to.eventually.equal(expected); }; - const operatorEnvs = [{ OPERATOR_ID_MAIN: ConfigService.get('OPERATOR_ID_MAIN') }, { OPERATOR_ID_MAIN: null }]; + const operatorEnvs = [ + { OPERATOR_ID_MAIN: ConfigService.get('OPERATOR_ID_MAIN') }, + { OPERATOR_ID_MAIN: zeroAddress() }, + ]; operatorEnvs.forEach((operatorEnv) => { withOverriddenEnvsInMochaTest(operatorEnv, () => {