-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
139 lines (114 loc) · 4.27 KB
/
test.js
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
const BlockBee = require('./index')
const test = require('node:test')
const apiKey = '' // <- Insert your API Key here to run tests.
test('Test requesting service info', async (t) => {
const info = await BlockBee.getInfo()
if (info === null) throw new Error('fail')
})
test('Test requesting coin info', async (t) => {
const info = await BlockBee.getInfo('btc')
if (info === null) throw new Error('fail')
})
test('Test requesting supported cryptocurrencies', async (t) => {
const supportedCoins = await BlockBee.getSupportedCoinsTest(apiKey)
if (supportedCoins === null) throw new Error('fail')
})
test('Test generating address', async (t) => {
const bb = new BlockBee('polygon_pol', null, 'https://webhook.site/19a994f1-54eb-47dc-8516-4107851f9a5s', {
order_id: 1235,
}, {
convert: 1,
multi_chain: 1,
}, apiKey)
const address = await bb.getAddress()
if (address === null) throw new Error('fail')
})
test('Test getting logs', async (t) => {
const bb = new BlockBee('polygon_pol', null, 'https://webhook.site/19a994f1-54eb-47dc-8516-4107851f9a5s', {
order_id: 1235,
}, {
convert: 1,
multi_chain: 1,
}, apiKey)
const logs = await bb.checkLogs()
if (logs === null) throw new Error('fail')
})
test('Test getting QrCode', async (t) => {
const bb = new BlockBee('polygon_pol', null, 'https://webhook.site/19a994f1-54eb-47dc-8516-4107851f9a5f', {}, {
convert: 1,
multi_chain: 1,
}, apiKey)
const qrCode = await bb.getQrcode(2, 300)
if (qrCode === null) throw new Error('fail')
})
test('Test getting getEstimate', async (t) => {
const estimate = await BlockBee.getEstimate('polygon_pol', apiKey,1, 'default')
if (estimate === null) throw new Error('fail')
})
test('Test getting getConvert', async (t) => {
const convert = await BlockBee.getConvert('polygon_pol', 300,'USD', apiKey)
if (convert === null) throw new Error('fail')
})
test('Test creating Payout Request', async (t) => {
const requests = {
'0xA6B78B56ee062185E405a1DDDD18cE8fcBC4395d': 0.2,
'0x18B211A1Ba5880C7d62C250B6441C2400d588589': 0.1
}
const payout = await BlockBee.createPayout('polygon_pol', requests, apiKey, false)
if (payout === null) throw new Error('fail')
})
test('Test fetching Payout list', async (t) => {
const payout = await BlockBee.listPayouts('bep20_usdt', 'all', 1, apiKey, true)
if (payout === null) throw new Error('fail')
})
test('Get Payout Wallet / and balance', async (t) => {
const wallet = await BlockBee.getPayoutWallet('polygon_pol', apiKey, true)
if (wallet === null) throw new Error('fail')
})
test('Create Payout by IDs', async (t) => {
const ids = [
'b88972c9-058a-47a2-8e5e-8ee601cdb7d8'
]
const payout = await BlockBee.createPayoutByIds(apiKey, ids)
if (payout === null) throw new Error('fail')
})
test('Process Payout by ID', async (t) => {
const payout = await BlockBee.processPayout(apiKey, '3da6bff6-f0f7-4f93-8512-b4611d80077e')
if (payout === null) throw new Error('fail')
})
test('Check Payout status by ID', async (t) => {
const status = await BlockBee.checkPayoutStatus(apiKey, '3da6bff6-f0f7-4f93-8512-b4611d80077e')
if (status === null) throw new Error('fail')
})
test('Test generating a payment link', async (t) => {
const paymentLink = await BlockBee.paymentRequest(
'https://example.com',
'https://example.com',
10,
apiKey,
{
order_id: 12345
}
)
if (paymentLink === null) throw new Error('fail')
})
test('Test fetching payment logs', async (t) => {
const token = 'OcRrZGsKQFGsoi0asqZkr97WbitMxFMb'
const paymentLogs = await BlockBee.paymentLogs(token, apiKey)
if (paymentLogs === null) throw new Error('fail')
})
test('Test generating a deposit link', async (t) => {
const depositLink = await BlockBee.depositRequest(
'https://arianoangelo.com/',
apiKey,
{
deposit_id: 100,
}
)
if (depositLink === null) throw new Error('fail')
})
test('Test fetching deposit logs', async (t) => {
const token = 'jv12du8IWqS96WVDjZK2J285WOBOBycc'
const depositLogs = await BlockBee.depositLogs(token, apiKey)
if (depositLogs === null) throw new Error('fail')
})