Skip to content

Commit

Permalink
feat: ⚡ added allocation date unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
sadiabbasi committed Jan 2, 2025
1 parent db26038 commit b311a45
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,37 @@ describe('VestingContract class', () => {
debug("vestingProgress:", vestingProgress);

});
test('should calculate the correct allocation date', async () => {
expect.assertions(2);

const trx = await vestingContract.assignTokens(
'coinsale.tmy',
accountName,
'1.000000 LEOS',
999,
signer
);

expect(trx.processed.receipt.status).toBe('executed');

const balances = await vestingContract.getVestingAllocations(accountName);

const allocationDetails = balances.allocationsDetails[0];
const allocationDate = allocationDetails.vestingStart;

const settings = await vestingContract.getSettings();
const saleStart = new Date(settings.sales_start_date);
const timeSinceSaleStart = allocationDetails.vestingStart.getTime() - saleStart.getTime();

// Calculate expected allocation date
const expectedAllocationDate = new Date(saleStart.getTime() + timeSinceSaleStart);

// Validate allocation date matches expected allocation date
const tolerance = 1000; // 1 second in milliseconds

expect(Math.abs(allocationDate.getTime() - expectedAllocationDate.getTime())).toBeLessThanOrEqual(tolerance);
});

});

describe('migratealloc()', () => {
Expand Down

0 comments on commit b311a45

Please sign in to comment.