Skip to content

Commit 360683a

Browse files
authored
test: add staking tests (#617)
* test: add staking tests * fix: fix command name in test
1 parent 4c0af61 commit 360683a

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ jobs:
3434
- name: Install npm deps
3535
run: npm ci && npm install -g @fairdatasociety/fdp-play
3636

37+
- name: Run bee-dev
38+
run: npx bee-dev &
39+
3740
- name: Start fdp-play environment
3841
run: npm run bee
3942

test/command/stake.spec.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1+
import { toMatchLinesInOrder } from '../custom-matcher'
12
import { describeCommand, invokeTestCli } from '../utility'
3+
import { getBeeDevOption } from '../utility/stamp'
24

3-
describeCommand('Test Stake command', ({ consoleMessages }) => {
4-
it.skip('should print stake balance', async () => {
5-
await invokeTestCli(['stake'])
6-
expect(consoleMessages[0]).toContain('Staked xBZZ')
7-
})
8-
9-
it.skip('should print balance in quiet mode', async () => {
10-
await invokeTestCli(['stake', '--quiet'])
5+
expect.extend({
6+
toMatchLinesInOrder,
7+
})
118

12-
const initialStake = parseFloat(consoleMessages[0].split(' ')[1])
13-
await invokeTestCli(['stake', '--quiet', '--deposit', '100_000T'])
14-
const afterDepositStake = parseFloat(consoleMessages[1].split(' ')[1])
15-
expect(afterDepositStake).toBeGreaterThan(initialStake)
9+
describeCommand('Test Stake command', ({ consoleMessages }) => {
10+
test('should stake with bzz, plur, and print stake', async () => {
11+
await invokeTestCli(['stake', ...getBeeDevOption()])
12+
await invokeTestCli(['stake', '--deposit-bzz', '10', '--yes', ...getBeeDevOption()])
13+
await invokeTestCli(['stake', '--deposit', '10', '--yes', ...getBeeDevOption()])
14+
await invokeTestCli(['stake', ...getBeeDevOption()])
15+
expect(consoleMessages).toMatchLinesInOrder([
16+
['Staked xBZZ', '0.0000000000000000'],
17+
['Successfully staked!'],
18+
['Staked xBZZ', '10.0000000000000000'],
19+
['Successfully staked!'],
20+
['Staked xBZZ', '10.0000000000000010'],
21+
['Staked xBZZ', '10.0000000000000010'],
22+
])
1623
})
1724
})

test/utility/stamp.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ export const getOrBuyStamp = async (): Promise<BatchId> => {
2121
}
2222

2323
export const getStampOption = (): string[] => ['--stamp', process.env.TEST_STAMP || '']
24+
25+
export const getBeeDevOption = (): string[] => ['--bee-api-url', 'http://localhost:16337']

0 commit comments

Comments
 (0)