Skip to content

Update cvat payout calculator for the new manifest#3981

Open
portuu3 wants to merge 2 commits into
developfrom
cvat-new-manifest
Open

Update cvat payout calculator for the new manifest#3981
portuu3 wants to merge 2 commits into
developfrom
cvat-new-manifest

Conversation

@portuu3

@portuu3 portuu3 commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Issue tracking

NA

Context behind the change

Update cvat payout calculator for the new manifest

How has this been tested?

Tested using unit tests
Pending to test with CVAT oracles on testnet when ready

Release plan

NA

Potential risks; What to monitor; Rollback plan

NA

@portuu3
portuu3 requested a review from Dzeranov July 23, 2026 07:59
@portuu3 portuu3 self-assigned this Jul 23, 2026
@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

5 Skipped Deployments
Project Deployment Actions Updated (UTC)
faucet-frontend Ignored Ignored Preview Jul 23, 2026 2:57pm
faucet-server Ignored Ignored Preview Jul 23, 2026 2:57pm
human-app Skipped Skipped Jul 23, 2026 2:57pm
human-dashboard-frontend Skipped Skipped Jul 23, 2026 2:57pm
staking-dashboard Skipped Skipped Jul 23, 2026 2:57pm

Request Review

@dnechay dnechay moved this to In Review in Core tech - 2026 (H1) Jul 23, 2026

@dnechay dnechay left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm overall, some cleanup comments

const mockedGetReservedFunds = jest
.fn()
.mockImplementation(async () =>
BigInt(faker.number.int({ min: 1000, max: 100000 })),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not mock default with some random number, because it can confuse in case of incorrect/failing test suite, it's better to mimic real behavior (i.e. funds not reserved) which returns 0n

Suggested change
BigInt(faker.number.int({ min: 1000, max: 100000 })),
0n,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont understand why you want to return 0 here. We use reserved funds to calculate the job bounty

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@portuu3
Here you just declare a mock to be used later, so there can define actual mocked values.

By default it should return something, that will make test:

  • pass, where reserved funds aren't necessary
  • fail, where you have to override

Setting random value by default satisfies both, but in case something goes wrong - e.g. you forget to set mockResolvedValueOnce in the the test where it actually matters - you will get failed assertions with weird calculations of job bounty something like expected 1234.34, got 45834.3, but in case we set 0 as default, then it would be expected 1234.34, got 0 because of the math, which makes it clear that we just forgot to mock reserved funds call return value

@vercel
vercel Bot temporarily deployed to Preview – human-app July 23, 2026 14:57 Inactive
@vercel
vercel Bot temporarily deployed to Preview – human-dashboard-frontend July 23, 2026 14:57 Inactive
@vercel
vercel Bot temporarily deployed to Preview – staking-dashboard July 23, 2026 14:57 Inactive
@portuu3
portuu3 requested a review from dnechay July 23, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

3 participants