Update cvat payout calculator for the new manifest#3981
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 5 Skipped Deployments
|
dnechay
left a comment
There was a problem hiding this comment.
Lgtm overall, some cleanup comments
|
|
||
| for (const jobFinalResult of matchedJobResults) { | ||
| // TODO: enable annotation quality validation when ready | ||
| if ( |
There was a problem hiding this comment.
Already filtered above, so probably we can remove this check on jobFilanResult
| afterEach(() => { | ||
| jest.resetAllMocks(); | ||
| mockedEscrowClient.build.mockResolvedValue({ | ||
| getIntermediateResultsUrl: mockedGetIntermediateResultsUrl, | ||
| getReservedFunds: mockedGetReservedFunds, | ||
| } as unknown as EscrowClient); | ||
| }); |
There was a problem hiding this comment.
No need in this block
| afterEach(() => { | |
| jest.resetAllMocks(); | |
| mockedEscrowClient.build.mockResolvedValue({ | |
| getIntermediateResultsUrl: mockedGetIntermediateResultsUrl, | |
| getReservedFunds: mockedGetReservedFunds, | |
| } as unknown as EscrowClient); | |
| }); |
| const tokenDecimals = BigInt(6); | ||
| const jobCount = jobsPerAnnotator * annotators.length; | ||
| const payoutPerJob = BigInt(faker.number.int({ min: 1000, max: 100000 })); | ||
| const reservedFunds = payoutPerJob * BigInt(jobCount); |
There was a problem hiding this comment.
| const reservedFunds = payoutPerJob * BigInt(jobCount); | |
| mockedGetReservedFunds.mockResolvedValueOnce(payoutPerJob * BigInt(jobCount)); |
| const mockedGetReservedFunds = jest | ||
| .fn() | ||
| .mockImplementation(async () => | ||
| BigInt(faker.number.int({ min: 1000, max: 100000 })), |
There was a problem hiding this comment.
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
| BigInt(faker.number.int({ min: 1000, max: 100000 })), | |
| 0n, |
| mockedGetReservedFunds.mockResolvedValueOnce(reservedFunds); | ||
| const manifest = generateCvatManifest(); | ||
| const payouts = await calculator.calculate({ | ||
| chainId, | ||
| escrowAddress, | ||
| manifest, | ||
| manifest: manifest, | ||
| finalResultsUrl: faker.internet.url(), | ||
| }); |
There was a problem hiding this comment.
| mockedGetReservedFunds.mockResolvedValueOnce(reservedFunds); | |
| const manifest = generateCvatManifest(); | |
| const payouts = await calculator.calculate({ | |
| chainId, | |
| escrowAddress, | |
| manifest, | |
| manifest: manifest, | |
| finalResultsUrl: faker.internet.url(), | |
| }); | |
| const payouts = await calculator.calculate({ | |
| chainId, | |
| escrowAddress, | |
| manifest: generateCvatManifest(), | |
| finalResultsUrl: faker.internet.url(), | |
| }); |
| results: [ | ||
| { | ||
| id: faker.number.int(), | ||
| job_id: faker.number.int(), |
There was a problem hiding this comment.
Even though we use faker there, there is a very little chance that faker.number.int() will generate final_result_id = result.id, so for the purpose of this test let's make sure somehow that those ids are 100% different
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