This commit is contained in:
JulesCrown 2024-04-04 07:40:12 +02:00
parent 5a8c80e838
commit 59533a64d2
6 changed files with 85 additions and 3 deletions

View file

@ -1,4 +1,4 @@
import { bytesToUint256LittleEndian, uint256ToBytesLittleEndian } from "../subgraph"; // Adjust the import path to where your functions are defined
import { bytesToUint256LittleEndian, uint256ToBytesLittleEndian } from "../subgraph";
import { Position, PositionStatus } from '../__generated__/graphql';

View file

@ -0,0 +1,42 @@
import { uint256ToBytesLittleEndian } from "../subgraph";
import { getSnatchList } from "../helpers";
import { Position, PositionStatus } from '../__generated__/graphql';
describe('BigInt Conversion Functions', () => {
test('get a list of positions to snatch', async () => {
const mockPos: 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
}
];
expect(getSnatchList(mockPos, 20000000000000000000n, 0.03)).toEqual([4n, 5n]);
});
});