import { uint256ToBytesLittleEndian } from "../subgraph"; import { getSnatchList } from "../helpers"; import { Position, PositionStatus } from '../__generated__/graphql'; const mockPos1: Position[] = [ { __typename: 'Position', id: uint256ToBytesLittleEndian(3n), owner: '0x8db6b632d743aef641146dc943acb64957155388', share: 0.000001, creationTime: 1610000000, taxRate: 0.05, status: PositionStatus.Active, // Enum usage }, { __typename: 'Position', id: uint256ToBytesLittleEndian(4n), owner: '0x8db6b632d743aef641146dc943acb64957155388', share: 0.000001, creationTime: 1610000000, taxRate: 0.01, status: PositionStatus.Active, // Enum usage }, { __typename: 'Position', id: uint256ToBytesLittleEndian(5n), owner: '0x8db6b632d743aef641146dc943acb64957155388', share: 0.000001, creationTime: 1610000000, taxRate: 0.02, status: PositionStatus.Active, // Enum usage } ]; describe('BigInt Conversion Functions', () => { test('get a list of positions to snatch', async () => { // snatch 20 of 10000000 stake expect(getSnatchList(mockPos1, 20000000000000000000n, 0.03)).toEqual([4n, 5n]); // snatch 10 of 10000000 stake expect(getSnatchList(mockPos1, 10000000000000000000n, 0.02)).toEqual([4n]); // snatch 10 of 10000000 stake expect(getSnatchList(mockPos1, 30000000000000000000n, 0.06)).toEqual([4n, 5n, 3n]); }); test('test error', async () => { expect(() => {getSnatchList(mockPos1, 20000000000000000000n, 0.02)}).toThrow("Not enough capacity"); }); });