Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More tests for providerRequestsCount
Browse files Browse the repository at this point in the history
segun committed Oct 13, 2023

Verified

This commit was signed with the committer’s verified signature.
pradyunsg Pradyun Gedam
1 parent 8578eb0 commit ef3efb7
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/components/UI/BlockaidBanner/BlockaidBanner.types.ts
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ export interface SecurityAlertResponse {
reason: Reason;
features: string[];
resultType: ResultType;
providerRequestsCount: Record<string, number>;
providerRequestsCount?: Record<string, number>;
}

type BlockaidBannerAllProps = BannerAlertProps & {
32 changes: 32 additions & 0 deletions app/util/blockaid/index.test.ts
Original file line number Diff line number Diff line change
@@ -31,4 +31,36 @@ describe('getBlockaidMetricsParams', () => {
ppom_eth_getCode_count: 3,
});
});

it('should not return eth call counts if providerRequestsCount is empty', () => {
const securityAlertResponse: SecurityAlertResponse = {
resultType: ResultType.Malicious,
reason: Reason.notApplicable,
features: [],
providerRequestsCount: {},
};

const result = getBlockaidMetricsParams(securityAlertResponse);
expect(result).toEqual({
ui_customizations: ['flagged_as_malicious'],
security_alert_response: ResultType.Malicious,
security_alert_reason: Reason.notApplicable,
});
});

it('should not return eth call counts if providerRequestsCount is undefined', () => {
const securityAlertResponse: SecurityAlertResponse = {
resultType: ResultType.Malicious,
reason: Reason.notApplicable,
features: [],
providerRequestsCount: undefined,
};

const result = getBlockaidMetricsParams(securityAlertResponse);
expect(result).toEqual({
ui_customizations: ['flagged_as_malicious'],
security_alert_response: ResultType.Malicious,
security_alert_reason: Reason.notApplicable,
});
});
});

0 comments on commit ef3efb7

Please sign in to comment.