-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathstake.spec.ts
More file actions
49 lines (38 loc) · 1.07 KB
/
stake.spec.ts
File metadata and controls
49 lines (38 loc) · 1.07 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
import { Dates, System } from 'cafe-utility'
import { BZZ } from '../../src'
import { currentBeeMode, makeBee } from '../utils'
const bee = makeBee()
test('GET stake', async () => {
const stake = await bee.getStake()
if (currentBeeMode() === 'full') {
expect(parseFloat(stake.toDecimalString())).toBeGreaterThan(200)
} else {
expect(parseFloat(stake.toDecimalString())).toBe(0)
}
})
test('POST stake', async () => {
if (currentBeeMode() !== 'full') {
return
}
const stakePreviously = await bee.getStake()
let transactionId = await bee.depositStake('1')
expect(transactionId.toHex()).toHaveLength(64)
await System.waitFor(
async () => {
const stake = await bee.getStake()
return stake.eq(stakePreviously.plus('1'))
},
Dates.seconds(1),
180,
)
transactionId = await bee.depositStake(BZZ.fromPLUR(1n))
expect(transactionId.toHex()).toHaveLength(64)
await System.waitFor(
async () => {
const stake = await bee.getStake()
return stake.eq(stakePreviously.plus('2'))
},
Dates.seconds(1),
180,
)
})