-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improves support for other native tokens
- Loading branch information
Showing
7 changed files
with
672 additions
and
51 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
packages/retryable-monitor/__tests__/reportRetryables.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { describe, it, expect } from 'vitest' | ||
import { ethers } from 'ethers' | ||
import { formatL2Callvalue } from '../reportRetryables' | ||
import { ChildChainTicketReport } from '../types' | ||
|
||
describe('reportRetryables', () => { | ||
describe('formatL2Callvalue', () => { | ||
it('should format ETH amounts correctly', async () => { | ||
const ticket = { | ||
deposit: { | ||
amount: ethers.utils.parseEther('12.0').toString(), | ||
symbol: 'ETH', | ||
decimals: 18, | ||
}, | ||
} as ChildChainTicketReport | ||
|
||
const result = await formatL2Callvalue(ticket) | ||
expect(result).toBe('\n\t *Child chain callvalue:* 12.0 ETH') | ||
}) | ||
|
||
it('should format USDC amounts with 6 decimals', async () => { | ||
const ticket = { | ||
deposit: { | ||
amount: '12000000', // 12 USDC with 6 decimals | ||
symbol: 'USDC', | ||
decimals: 6, | ||
}, | ||
} as ChildChainTicketReport | ||
|
||
const result = await formatL2Callvalue(ticket) | ||
expect(result).toBe('\n\t *Child chain callvalue:* 12.0 USDC') | ||
}) | ||
|
||
it('should handle amounts with default 18 decimals when decimals not specified', async () => { | ||
const ticket = { | ||
deposit: { | ||
amount: ethers.utils.parseEther('12.0').toString(), // 12 with 18 decimals | ||
symbol: 'XAI', | ||
// no decimals field | ||
}, | ||
} as ChildChainTicketReport | ||
|
||
const result = await formatL2Callvalue(ticket) | ||
expect(result).toBe('\n\t *Child chain callvalue:* 12.0 XAI') | ||
}) | ||
|
||
it('should handle real transaction data from Arbitrum chain', async () => { | ||
const ticket = { | ||
deposit: { | ||
amount: '12000000000000000000', // 12 ETH in wei | ||
symbol: 'ETH', | ||
decimals: 18, | ||
}, | ||
} as ChildChainTicketReport | ||
|
||
const result = await formatL2Callvalue(ticket) | ||
expect(result).toBe('\n\t *Child chain callvalue:* 12.0 ETH') | ||
}) | ||
|
||
it('should handle real USDC transaction data', async () => { | ||
const ticket = { | ||
deposit: { | ||
amount: '120000000', // 12 USDC with 6 decimals | ||
symbol: 'USDC', | ||
decimals: 6, | ||
}, | ||
} as ChildChainTicketReport | ||
|
||
const result = await formatL2Callvalue(ticket) | ||
expect(result).toBe('\n\t *Child chain callvalue:* 12.0 USDC') | ||
}) | ||
|
||
it('should handle very small amounts', async () => { | ||
const ticket = { | ||
deposit: { | ||
amount: '1', // 0.000001 USDC | ||
symbol: 'USDC', | ||
decimals: 6, | ||
}, | ||
} as ChildChainTicketReport | ||
|
||
const result = await formatL2Callvalue(ticket) | ||
expect(result).toBe('\n\t *Child chain callvalue:* 0.000001 USDC') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { defineConfig } from 'vitest/config' | ||
|
||
export default defineConfig({ | ||
test: { | ||
globals: true, | ||
environment: 'node', | ||
}, | ||
}) |
Oops, something went wrong.