Skip to content

Commit

Permalink
fix error logging (#1526) (#1535)
Browse files Browse the repository at this point in the history
(cherry picked from commit 5177509)

Co-authored-by: dydxwill <[email protected]>
  • Loading branch information
mergify[bot] and dydxwill authored May 17, 2024
1 parent 7a30529 commit 818bf9f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { getIpAddr } from '../../../../src/lib/utils';
import { sendRequest } from '../../../helpers/helpers';
import { RequestMethod } from '../../../../src/types';
import { logger, stats } from '@dydxprotocol-indexer/base';
import { stats } from '@dydxprotocol-indexer/base';
import { redis } from '@dydxprotocol-indexer/redis';
import { ratelimitRedis } from '../../../../src/caches/rate-limiters';
import { ComplianceControllerHelper } from '../../../../src/controllers/api/v4/compliance-controller';
Expand Down Expand Up @@ -447,7 +447,6 @@ describe('ComplianceV2Controller', () => {
});

it('should be a no-op for ONBOARD action with existing COMPLIANT status', async () => {
const loggerError = jest.spyOn(logger, 'error');
await ComplianceStatusTable.create({
address: testConstants.defaultAddress,
status: ComplianceStatus.COMPLIANT,
Expand All @@ -468,16 +467,10 @@ describe('ComplianceV2Controller', () => {
address: testConstants.defaultAddress,
status: ComplianceStatus.COMPLIANT,
}));

expect(loggerError).toHaveBeenCalledWith(expect.objectContaining({
at: 'ComplianceV2Controller POST /geoblock',
message: 'Invalid action for current compliance status',
}));
expect(response.body.status).toEqual(ComplianceStatus.COMPLIANT);
});

it('should be a no-op for ONBOARD action with existing FIRST_STRIKE_CLOSE_ONLY status', async () => {
const loggerError = jest.spyOn(logger, 'error');
await ComplianceStatusTable.create({
address: testConstants.defaultAddress,
status: ComplianceStatus.FIRST_STRIKE_CLOSE_ONLY,
Expand All @@ -501,10 +494,6 @@ describe('ComplianceV2Controller', () => {
reason: ComplianceReason.US_GEO,
}));

expect(loggerError).toHaveBeenCalledWith(expect.objectContaining({
at: 'ComplianceV2Controller POST /geoblock',
message: 'Invalid action for current compliance status',
}));
expect(response.body.status).toEqual(ComplianceStatus.FIRST_STRIKE_CLOSE_ONLY);
expect(response.body.reason).toEqual(ComplianceReason.US_GEO);
expect(response.body.updatedAt).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,7 @@ router.post(
complianceStatus[0].status === ComplianceStatus.FIRST_STRIKE ||
complianceStatus[0].status === ComplianceStatus.COMPLIANT
) {
if (action === ComplianceAction.ONBOARD) {
logger.error({
at: 'ComplianceV2Controller POST /geoblock',
message: 'Invalid action for current compliance status',
address,
action,
complianceStatus: complianceStatus[0],
});
} else if (
if (
isRestrictedCountryHeaders(req.headers as CountryHeaders) &&
action === ComplianceAction.CONNECT
) {
Expand All @@ -320,15 +312,7 @@ router.post(
} else if (
complianceStatus[0].status === ComplianceStatus.FIRST_STRIKE_CLOSE_ONLY
) {
if (action === ComplianceAction.ONBOARD) {
logger.error({
at: 'ComplianceV2Controller POST /geoblock',
message: 'Invalid action for current compliance status',
address,
action,
complianceStatus: complianceStatus[0],
});
} else if (action === ComplianceAction.VALID_SURVEY) {
if (action === ComplianceAction.VALID_SURVEY) {
complianceStatusFromDatabase = await ComplianceStatusTable.update({
address,
status: ComplianceStatus.FIRST_STRIKE,
Expand Down

0 comments on commit 818bf9f

Please sign in to comment.