-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.js
More file actions
75 lines (60 loc) · 2.12 KB
/
test.js
File metadata and controls
75 lines (60 loc) · 2.12 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const CryptAPI = require('./index')
const test = require('node:test')
const callbackUrl = 'https://webhook.site/58abc808-8bf6-4dad-8097-7bc364915f46'
test('Test requesting service info', async (t) => {
const info = await CryptAPI.getInfo()
console.log(info)
if (info === null) throw new Error('fail')
})
test('Test requesting coin info', async (t) => {
const info = await CryptAPI.getInfo('sol_sol')
console.log(info)
if (info === null) throw new Error('fail')
})
test('Test requesting supported cryptocurrencies', async (t) => {
const _r = await CryptAPI.getSupportedCoins()
if (_r === null) throw new Error('fail')
})
test('Test generating address', async (t) => {
const ca = new CryptAPI('sol_sol', 'DSo1MN64SWBCNR7dQKP2bkQnXMhXeFYFSqgJAMQL9kw5', callbackUrl, {
order_id: 123457,
}, {
multi_token: 1,
convert: 1
})
const address = await ca.getAddress()
if (address === null) throw new Error('fail')
})
test('Test getting logs', async (t) => {
const ca = new CryptAPI('polygon_pol', '0xA6B78B56ee062185E405a1DDDD18cE8fcBC4395d', callbackUrl, {
order_id: 12345,
}, {
convert: 1,
multi_token: 1,
})
const logs = await ca.checkLogs()
if (logs === null) throw new Error('fail')
})
test('Test getting QrCode', async (t) => {
const ca = new CryptAPI('polygon_pol', '0xA6B78B56ee062185E405a1DDDD18cE8fcBC4395d', callbackUrl, {}, {
convert: 1,
multi_chain: 1,
})
/**
* First is important to run getAddress otherwise the remaining requests won't function
*/
await ca.getAddress()
const qrCode = await ca.getQrcode(1, 300)
console.log(qrCode)
if (qrCode === null) throw new Error('fail')
})
test('Test getting getEstimate', async (t) => {
const estimate = await CryptAPI.getEstimate('polygon_pol',1, 'default')
console.log(estimate)
if (estimate === null) throw new Error('fail')
})
test('Test getting getConvert', async (t) => {
const convert = await CryptAPI.getConvert('polygon_pol', 300,'USD')
console.log(convert)
if (convert === null) throw new Error('fail')
})