-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ruleset Unit Tests and tweaks #445
Conversation
🦋 Changeset detectedLatest commit: fb0810f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
c8dd157
to
2b2b783
Compare
| (typeof REJECT_ADDRESSES)[keyof typeof REJECT_ADDRESSES] | ||
| (typeof APPROVE_ADDRESSES)[keyof typeof APPROVE_ADDRESSES]; | ||
|
||
const MOCK_API_CALLS = apiCallsSnapshot as Record< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you guys hate these types, but it allows RuleSet.check() to allow for looser types being imported from json (ex: we recognize riskType with strict types, riskType: "COUNTERPARTY" | "OWNERSHIP" | "INDIRECT"
, but from json, riskType
is typed as string
, and thus it gives a TypeError, without these types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments for now + Slack comments
return partial.threshold(data); | ||
}) | ||
); | ||
const shouldApplyRule = results[this.predicateFn]((_) => _); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need ((_) => _)
? Can we not just say results[this.predicateFn]()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do; the predicate fns require a fn to predicate off of, and unfortunately in TypeScript there isn't cleaner syntactic sugar
async check(deposit: ScreeningDepositRequest): Promise<Rejection | Delay> { | ||
async check( | ||
deposit: ScreeningDepositRequest, | ||
cache: Partial<Record<ApiCallKeys, CallReturnData>> = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we alias the cache type? The really long types are unweildy, aliases would at least help a little bit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely, changed
): Promise<MisttrackAddressOverviewData> => { | ||
const token = "ETH"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a heads up (no action item rn), we may have to screen on more than one chain because sometimes if hack happens on optimism and is bridged back to ETH, the ETH screening call doesn't always show the hack. Made ticket
TC_7: "0xadd7885af8f37df5c965e5d16caf16f807dc79a0", | ||
} as const; | ||
|
||
export const APPROVE_ADDRESSES = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ishaan is a good example to keep in here, he's a normal defi user but somehow gets flagged by TRM for stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, what is his address? I'll add him in a later PR addressing the tickets you made
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, lgtm. Bit easier to read now 👍
Motivation
RuleSet work needs tests, what currently exists are only scripts
Solution
Adds tests, also tweaks a couple things about how RuleSets are defined
Proof
PR Checklist