-
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
662 additions
and
51 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
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,76 @@ | ||
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 not format non-ETH amounts', async () => { | ||
const ticket = { | ||
deposit: { | ||
amount: '12000000', | ||
symbol: 'XAI', | ||
decimals: 6, | ||
}, | ||
} as ChildChainTicketReport | ||
|
||
const result = await formatL2Callvalue(ticket) | ||
expect(result).toBe('\n\t *Child chain callvalue:* 12000000 XAI') | ||
}) | ||
|
||
it('should handle non-ETH amounts regardless of decimals field', async () => { | ||
const ticket = { | ||
deposit: { | ||
amount: '12000000', | ||
symbol: 'XAI', | ||
// no decimals field | ||
}, | ||
} as ChildChainTicketReport | ||
|
||
const result = await formatL2Callvalue(ticket) | ||
expect(result).toBe('\n\t *Child chain callvalue:* 12000000 XAI') | ||
}) | ||
|
||
it('should handle real transaction data from Arbitrum chain', async () => { | ||
// This is real data from a retryable ticket on Arbitrum Sepolia | ||
const ticket = { | ||
deposit: { | ||
// This is a real L2 call value from a retryable ticket | ||
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 XAI transaction data', async () => { | ||
// This is example data that would come from an USDC chain | ||
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:* 120000000 XAI') | ||
}) | ||
}) | ||
}) |
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.