Skip to content

Commit

Permalink
test: more test when price is decimal
Browse files Browse the repository at this point in the history
  • Loading branch information
graykode committed Apr 5, 2024
1 parent 98c9289 commit d6adb9b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions test/get-expected-input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ test('get expected input ask', async () => {
'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
'0x0000000000000000000000000000000000000000',
'0.1',
'100',
'100.01',
)
expect(takenAmount).toBe('0')
expect(spendAmount).toBe('0')
Expand All @@ -151,14 +151,14 @@ test('get expected input ask', async () => {
'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
'0x0000000000000000000000000000000000000000',
'0.2',
'4005',
'4005.01',
)

await isSpendResultEqual(
'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
'0x0000000000000000000000000000000000000000',
'0.23',
'10000',
'10000.01',
)

await isSpendResultEqual(
Expand All @@ -174,7 +174,7 @@ test('get expected input bid', async () => {
'0x0000000000000000000000000000000000000000',
'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
'100000',
'4010',
'4010.01',
)
expect(takenAmount).toBe('0')
expect(spendAmount).toBe('0')
Expand All @@ -183,14 +183,14 @@ test('get expected input bid', async () => {
'0x0000000000000000000000000000000000000000',
'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
'100000',
'4005',
'4005.16',
)

await isSpendResultEqual(
'0x0000000000000000000000000000000000000000',
'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
'100000',
'200',
'200.12',
)

await isSpendResultEqual(
Expand Down
12 changes: 6 additions & 6 deletions test/get-expected-output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ test('get expected output ask', async () => {
'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
'0x0000000000000000000000000000000000000000',
'1000.123',
'100',
'100.01',
)
expect(takenAmount).toBe('0')
expect(spendAmount).toBe('0')
Expand All @@ -151,14 +151,14 @@ test('get expected output ask', async () => {
'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
'0x0000000000000000000000000000000000000000',
'1000000',
'4005',
'4005.01',
)

await isSpendResultEqual(
'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
'0x0000000000000000000000000000000000000000',
'1000.123',
'10000',
'10000.01',
)

await isSpendResultEqual(
Expand All @@ -174,7 +174,7 @@ test('get expected output bid', async () => {
'0x0000000000000000000000000000000000000000',
'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
'0.01',
'4010',
'4010.01',
)
expect(takenAmount).toBe('0')
expect(spendAmount).toBe('0')
Expand All @@ -183,14 +183,14 @@ test('get expected output bid', async () => {
'0x0000000000000000000000000000000000000000',
'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
'0.1',
'4005',
'4005.01',
)

await isSpendResultEqual(
'0x0000000000000000000000000000000000000000',
'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
'1.1234',
'200',
'200.01',
)

await isSpendResultEqual(
Expand Down
12 changes: 6 additions & 6 deletions test/limit-order.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test('make bid order', async () => {
'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
'0x0000000000000000000000000000000000000000',
'100',
'1000',
'1000.01',
{ signature, rpcUrl: publicClient.transport.url! },
)

Expand All @@ -86,7 +86,7 @@ test('make bid order', async () => {
bookId,
publicClient.transport.url!,
)
).find(({ price }) => 999 <= price && price <= 1000) ?? { amount: 0n }
).find(({ price }) => 1000 <= price && price <= 1001) ?? { amount: 0n }
).amount
expect(Number(beforeSize)).toEqual(0)

Expand All @@ -106,7 +106,7 @@ test('make bid order', async () => {
bookId,
publicClient.transport.url!,
)
).find(({ price }) => 999 <= price && price <= 1000)!.amount
).find(({ price }) => 1000 <= price && price <= 1001)!.amount

expect(beforeBalance - afterBalance).toEqual(100000000n)
expect(Number(afterSize)).greaterThan(0)
Expand All @@ -127,7 +127,7 @@ test('make bid order with post only', async () => {
'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
'0x0000000000000000000000000000000000000000',
'100',
'8000',
'8000.01',
{ signature, postOnly: true, rpcUrl: publicClient.transport.url! },
)

Expand Down Expand Up @@ -188,7 +188,7 @@ test('make ask order', async () => {
'0x0000000000000000000000000000000000000000',
'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
'0.01',
'8000',
'8000.01',
{ rpcUrl: publicClient.transport.url! },
)

Expand Down Expand Up @@ -243,7 +243,7 @@ test('make ask order with post only', async () => {
'0x0000000000000000000000000000000000000000',
'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
'0.01',
'1000',
'1000.01',
{ postOnly: true, rpcUrl: publicClient.transport.url! },
)

Expand Down

0 comments on commit d6adb9b

Please sign in to comment.