Skip to content

Commit

Permalink
fixed shouldLimit v1
Browse files Browse the repository at this point in the history
Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>

Revert "fixed shouldLimit v1"

This reverts commit 2f745e6f6188d7c4d84da931793544200420d073.

Reapply "fixed shouldLimit v1"

This reverts commit f280bbf311a4e407ed2c158d372581e2b8b36e25.
  • Loading branch information
quiet-node committed Feb 1, 2025
1 parent a5b4271 commit e5cf24b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 = AccountId.fromString(operatorEnv.OPERATOR_ID_MAIN).toSolidityAddress();

withOverriddenEnvsInMochaTest(operatorEnv, () => {
describe('based on evmAddress', async function () {
Expand Down
13 changes: 4 additions & 9 deletions packages/relay/tests/lib/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,10 @@ describe('Utils', () => {
OPERATOR_KEY_MAIN: privateKeys[0].keyValue,
},
() => {
it('should return null and log a warning if operatorId is missing', () => {
const warnSpy = sinon.spy(logger, 'warn');

const operator = Utils.getOperator(logger);

expect(operator).to.be.null;
expect(warnSpy.calledOnce).to.be.true;
expect(warnSpy.firstCall.args[0]).to.equal('Invalid operatorId or operatorKey for main client.');
warnSpy.restore();
it('should throw error if operatorId is missing', () => {
expect(() => Utils.getOperator(logger)).to.throw(
'Configuration error: OPERATOR_ID_MAIN is a mandatory configuration for relay operation.',
);
});
},
);
Expand Down

0 comments on commit e5cf24b

Please sign in to comment.