-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathMstakingAPI.spec.ts
More file actions
62 lines (55 loc) · 1.96 KB
/
MstakingAPI.spec.ts
File metadata and controls
62 lines (55 loc) · 1.96 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
import { describe, it, expect } from 'vitest'
import { APIRequester } from '../APIRequester'
import { MstakingAPI } from './MstakingAPI'
import { Coins, MstakingParams, ValConsPublicKey } from '../../../core'
const c = new APIRequester('https://rest.testnet.initia.xyz')
const api = new MstakingAPI(c)
describe('MstakingAPI', () => {
it('delegations without parameter should throw an error', async () => {
await expect(api.delegations()).rejects.toThrowError()
})
it('unbondingDelegations without parameter should throw an error', async () => {
await expect(api.unbondingDelegations()).rejects.toThrowError()
})
it('validators', async () => {
const validators = await api.validators().then((v) => v[0])
expect(validators).toContainEqual({
operator_address: expect.any(String),
consensus_pubkey: expect.any(ValConsPublicKey),
jailed: expect.any(Boolean),
status: expect.any(Number),
tokens: expect.any(Coins),
delegator_shares: expect.any(Coins),
description: {
moniker: expect.any(String),
identity: expect.any(String),
website: expect.any(String),
details: expect.any(String),
security_contact: expect.any(String),
},
unbonding_height: expect.any(Number),
unbonding_time: expect.any(Date),
commission: {
commission_rates: {
rate: expect.any(String),
max_rate: expect.any(String),
max_change_rate: expect.any(String),
},
update_time: expect.any(Date),
},
voting_powers: expect.any(Coins),
voting_power: expect.any(String),
})
})
it('pool', async () => {
await expect(api.pool()).resolves.toMatchObject({
bonded_tokens: expect.any(Coins),
not_bonded_tokens: expect.any(Coins),
voting_power_weights: expect.any(Coins),
})
})
it('params', async () => {
const params = await api.parameters()
expect(params).toEqual(expect.any(MstakingParams))
})
})