-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathclient.test.ts
More file actions
59 lines (52 loc) · 2.34 KB
/
client.test.ts
File metadata and controls
59 lines (52 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { describe, test, beforeAll, expect } from '@jest/globals'
import { assertTruthy, BlockchainReadOnlyConnection } from '@rsksmart/bridges-core-sdk'
import { Flyover } from '@rsksmart/flyover-sdk'
import { integrationTestConfig } from '../config'
import { fakeTokenResolver } from './common/utils'
describe('Flyover SDK client should', () => {
let flyover: Flyover
beforeAll(async () => {
flyover = new Flyover({
network: integrationTestConfig.network,
allowInsecureConnections: true,
captchaTokenResolver: fakeTokenResolver,
disableChecksum: true
})
const rsk = await BlockchainReadOnlyConnection.createUsingRpc(integrationTestConfig.nodeUrl)
await flyover.connectToRsk(rsk)
})
test('serialize and deserialize BigInt fields correctly', async () => {
const providers = await flyover.getLiquidityProviders()
if (providers?.length === 0 || providers.at(0)?.provider === '') {
throw new Error('invalid providers response')
}
const provider = providers.find(p => p.id === integrationTestConfig.providerId)
assertTruthy(provider, 'Provider not found')
flyover.useLiquidityProvider(provider)
const peginQuotes = await flyover.getQuotes({
callEoaOrContractAddress: integrationTestConfig.rskAddress,
callContractArguments: '',
valueToTransfer: integrationTestConfig.peginAmount,
rskRefundAddress: integrationTestConfig.rskAddress
})
if (peginQuotes?.length === 0) {
throw new Error('invalid getQuote response')
}
const peginQuote = peginQuotes.at(0)
const pegoutQuotes = await flyover.getPegoutQuotes({
to: integrationTestConfig.btcAddress,
valueToTransfer: integrationTestConfig.pegoutAmount,
rskRefundAddress: integrationTestConfig.rskAddress
})
if (pegoutQuotes?.length === 0) {
throw new Error('invalid getPegoutQuote response')
}
const pegoutQuote = pegoutQuotes.at(0)
expect(typeof peginQuote?.quote.value).toBe('bigint')
expect(peginQuote?.quote.value.toString()).toBe(integrationTestConfig.peginAmount.toString())
expect(typeof peginQuote?.quote.gasLimit).toBe('number')
expect(typeof pegoutQuote?.quote.value).toBe('bigint')
expect(pegoutQuote?.quote.value.toString()).toBe(integrationTestConfig.pegoutAmount.toString())
expect(typeof pegoutQuote?.quote.transferTime).toBe('number')
})
})