Skip to content

Commit

Permalink
Update totalReceived of project owners correctly after verifying dona…
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadranjbarz committed Sep 6, 2023
1 parent f0c648e commit 89c5c9e
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/services/donationService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
createDonationData,
createProjectData,
DONATION_SEED_DATA,
generateRandomEtheriumAddress,
saveDonationDirectlyToDb,
saveProjectDirectlyToDb,
saveUserDirectlyToDb,
Expand Down Expand Up @@ -79,10 +80,16 @@ function syncDonationStatusWithBlockchainNetworkTestCases() {
timestamp: 1661114988,
};
const user = await saveUserDirectlyToDb(transactionInfo.fromAddress);
const project = await saveProjectDirectlyToDb({
...createProjectData(),
walletAddress: transactionInfo.toAddress,
});
const projectOwner = await saveUserDirectlyToDb(
generateRandomEtheriumAddress(),
);
const project = await saveProjectDirectlyToDb(
{
...createProjectData(),
walletAddress: transactionInfo.toAddress,
},
projectOwner,
);
const donation = await saveDonationDirectlyToDb(
{
amount: transactionInfo.amount,
Expand Down Expand Up @@ -110,8 +117,8 @@ function syncDonationStatusWithBlockchainNetworkTestCases() {
const donor = await findUserById(user.id);
assert.equal(donor?.totalDonated, 100);

const projectOwnerUser = await findUserById(project.adminUser.id);
assert.equal(projectOwnerUser?.totalReceived, 100);
const updatedProjectOwner = await findUserById(projectOwner.id);
assert.equal(updatedProjectOwner?.totalReceived, 100);
});

it('should verify a Polygon donation', async () => {
Expand Down

0 comments on commit 89c5c9e

Please sign in to comment.