Skip to content

Commit

Permalink
Merge pull request #1488 from Giveth/fix-givbacks-round-in-Ortto
Browse files Browse the repository at this point in the history
fix givbacks round in Ortto
  • Loading branch information
RamRamez authored Apr 16, 2024
2 parents e651c0b + fd9c253 commit 22935b6
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 75 deletions.
19 changes: 0 additions & 19 deletions src/services/chains/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,25 +470,6 @@ function getTransactionDetailTestCases() {
// assert.notEqual(transactionInfo.hash, txHash);
// });

it('should return transaction detail for normal transfer on goerli', async () => {
// https://goerli.etherscan.io/tx/0x43cb1c61a81f007abd3de766a6029ffe62d0324268d7781469a3d7879d487cb1

const amount = 0.117;
const transactionInfo = await getTransactionInfoFromNetwork({
txHash:
'0x43cb1c61a81f007abd3de766a6029ffe62d0324268d7781469a3d7879d487cb1',
symbol: 'ETH',
networkId: NETWORK_IDS.GOERLI,
fromAddress: '0xc18c3cc1cf44e72dedfcbae981ef1ab32256ee60',
toAddress: '0x2d2b642c7407ebce201ed80711124fffd1777331',
amount,
timestamp: 1661114988,
});
assert.isOk(transactionInfo);
assert.equal(transactionInfo.currency, 'ETH');
assert.equal(transactionInfo.amount, amount);
});

// TODO: Rewrite this test for goerli or delete
// it('should return transaction detail for UNI token transfer on ropsten', async () => {
// // https://ropsten.etherscan.io/tx/0xba3c2627c9d3dd963455648b4f9d7239e8b5c80d0aa85ac354d2b762d99e4441
Expand Down
55 changes: 0 additions & 55 deletions src/services/donationService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,61 +86,6 @@ function sendSegmentEventForDonationTestCases() {
}

function syncDonationStatusWithBlockchainNetworkTestCases() {
it('should verify a goerli donation and update donor.totalDonated and projectOwner.totalReceived', async () => {
// https://goerli.etherscan.io/tx/0x43cb1c61a81f007abd3de766a6029ffe62d0324268d7781469a3d7879d487cb1

const transactionInfo = {
txHash:
'0x43cb1c61a81f007abd3de766a6029ffe62d0324268d7781469a3d7879d487cb1',
networkId: NETWORK_IDS.GOERLI,
amount: 0.117,
fromAddress: '0xc18c3cc1cf44e72dedfcbae981ef1ab32256ee60',
toAddress: '0x2d2b642c7407ebce201ed80711124fffd1777331',
currency: 'ETH',
timestamp: 1661114988,
};
const user = await saveUserDirectlyToDb(transactionInfo.fromAddress);
const projectOwner = await saveUserDirectlyToDb(
generateRandomEtheriumAddress(),
);
const project = await saveProjectDirectlyToDb(
{
...createProjectData(),
walletAddress: transactionInfo.toAddress,
},
projectOwner,
);
const donation = await saveDonationDirectlyToDb(
{
amount: transactionInfo.amount,
transactionNetworkId: transactionInfo.networkId,
transactionId: transactionInfo.txHash,
currency: transactionInfo.currency,
fromWalletAddress: transactionInfo.fromAddress,
toWalletAddress: transactionInfo.toAddress,
valueUsd: 100,
anonymous: false,
createdAt: new Date(transactionInfo.timestamp),
status: DONATION_STATUS.PENDING,
},
user.id,
project.id,
);
const updateDonation = await syncDonationStatusWithBlockchainNetwork({
donationId: donation.id,
});
assert.isOk(updateDonation);
assert.equal(updateDonation.id, donation.id);
assert.isTrue(updateDonation.segmentNotified);
assert.equal(updateDonation.status, DONATION_STATUS.VERIFIED);

const donor = await findUserById(user.id);
assert.equal(donor?.totalDonated, 100);

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

it('should verify a Polygon donation', async () => {
// https://polygonscan.com/tx/0x16f122ad45705dfa41bb323c3164b6d840cbb0e9fa8b8e58bd7435370f8bbfc8

Expand Down
2 changes: 1 addition & 1 deletion src/services/donationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ export const syncDonationStatusWithBlockchainNetwork = async (params: {
totalDonated: donationStats?.totalDonated,
donationsCount: donationStats?.donationsCount,
lastDonationDate: donationStats?.lastDonationDate,
GIVbacksRound: donation.powerRound,
GIVbacksRound: donation.powerRound + 1, // powerRound is 1 behind givbacks round
QFRound: donation.qfRound?.name,
donationChain: NETWORKS_IDS_TO_NAME[donation.transactionNetworkId],
});
Expand Down

0 comments on commit 22935b6

Please sign in to comment.