diff --git a/test/services/blockchain/contracts/VestingContract.integration.test.ts b/test/services/blockchain/contracts/VestingContract.integration.test.ts index 08a3f6f5..7ce1b92f 100644 --- a/test/services/blockchain/contracts/VestingContract.integration.test.ts +++ b/test/services/blockchain/contracts/VestingContract.integration.test.ts @@ -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()', () => {