Skip to content

Commit ca0003d

Browse files
authored
test: depend on bee-dev instead of custom mock server (#639)
* test: depend on bee-dev instead of custom mock server * fix: remove dependency on mock server as a test file * fix: remove dependency on mock server as a test file
1 parent 8639497 commit ca0003d

File tree

5 files changed

+18
-262
lines changed

5 files changed

+18
-262
lines changed

test/command/cheque.spec.ts

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { Server } from 'http'
2-
import { createChequeMockHttpServer } from '../http-mock/cheque-mock'
31
import { describeCommand, invokeTestCli } from '../utility'
42

53
async function runCommandAndExpectError(
@@ -15,39 +13,27 @@ async function runCommandAndExpectError(
1513
describeCommand(
1614
'Test Cheque command',
1715
({ consoleMessages, getNthLastMessage, getLastMessage }) => {
18-
let server: Server
19-
20-
beforeAll(() => {
21-
if (!server) {
22-
server = createChequeMockHttpServer(1377)
23-
}
24-
})
25-
26-
afterAll(() => {
27-
server.close()
28-
})
29-
3016
it('should print cheques', async () => {
31-
process.env.BEE_API_URL = 'http://localhost:1377'
17+
process.env.BEE_API_URL = 'http://localhost:16337'
3218
await invokeTestCli(['cheque', 'list'])
3319
expect(getLastMessage()).toContain('Cheque Value:')
3420
expect(getLastMessage()).toContain('0.0008944000000000 xBZZ')
3521
})
3622

3723
it('should not print cheques when --minimum is higher', async () => {
38-
process.env.BEE_API_URL = 'http://localhost:1377'
24+
process.env.BEE_API_URL = 'http://localhost:16337'
3925
await invokeTestCli(['cheque', 'list', '--minimum', '10000000000000000000'])
4026
expect(getLastMessage()).toContain('No uncashed cheques found')
4127
})
4228

4329
it('should print cheques when --minimum is lower', async () => {
44-
process.env.BEE_API_URL = 'http://localhost:1377'
30+
process.env.BEE_API_URL = 'http://localhost:16337'
4531
await invokeTestCli(['cheque', 'list', '--minimum', '1000'])
4632
expect(getLastMessage()).toContain('Cheque Value')
4733
})
4834

4935
it('should cashout all cheques', async () => {
50-
process.env.BEE_API_URL = 'http://localhost:1377'
36+
process.env.BEE_API_URL = 'http://localhost:16337'
5137
await invokeTestCli(['cheque', 'cashout', '--all'])
5238
expect(getNthLastMessage(3)).toContain('Peer Address:')
5339
expect(getNthLastMessage(3)).toContain('1105536d0f270ecaa9e6e4347e687d1a1afbde7b534354dfd7050d66b3c0faad')
@@ -58,20 +44,20 @@ describeCommand(
5844
})
5945

6046
it('should allow specifying gas price and limit for cashout', async () => {
61-
process.env.BEE_API_URL = 'http://localhost:1377'
47+
process.env.BEE_API_URL = 'http://localhost:16337'
6248
await invokeTestCli(['cheque', 'cashout', '--all', '--gas-price', '100', '--gas-limit', '100'])
6349
expect(getLastMessage()).toContain('Tx:')
6450
expect(getLastMessage()).toContain('11df9811dc8caaa1ff4389503f2493a8c46b30c0a0b5f8aa54adbb965374c0ae')
6551
})
6652

6753
it('should not cashout any cheques when --minimum is higher', async () => {
68-
process.env.BEE_API_URL = 'http://localhost:1377'
54+
process.env.BEE_API_URL = 'http://localhost:16337'
6955
await invokeTestCli(['cheque', 'cashout', '--all', '--minimum', '10000000000000000000'])
7056
expect(getLastMessage()).toContain('Found 0 cheques')
7157
})
7258

7359
it('should cashout one specific cheque', async () => {
74-
process.env.BEE_API_URL = 'http://localhost:1377'
60+
process.env.BEE_API_URL = 'http://localhost:16337'
7561
await invokeTestCli([
7662
'cheque',
7763
'cashout',

test/command/manifest.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ describeCommand('Test Manifest command', ({ consoleMessages, hasMessageContainin
124124
['address.ts', 'UNCHANGED'],
125125
])
126126
consoleMessages.length = 0
127-
hash = await runAndGetManifest(['manifest', 'sync', hash, 'test/http-mock'])
128-
expect(consoleMessages).toMatchLinesInOrder([['cheque-mock.ts', 'NEW']])
127+
hash = await runAndGetManifest(['manifest', 'sync', hash, 'test/testpage/images'])
128+
expect(consoleMessages).toMatchLinesInOrder([['swarm.png', 'NEW']])
129129
consoleMessages.length = 0
130-
await runAndGetManifest(['manifest', 'sync', hash, 'test/http-mock', '--remove'])
130+
await runAndGetManifest(['manifest', 'sync', hash, 'test/testpage/images', '--remove'])
131131
expect(consoleMessages).toMatchLinesInAnyOrder([
132-
['cheque-mock.ts', 'UNCHANGED'],
132+
['swarm.png', 'UNCHANGED'],
133133
['address.ts', 'REMOVED'],
134134
['index.ts', 'REMOVED'],
135135
['stamp.ts', 'REMOVED'],

test/command/status.spec.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
import { toMatchLinesInOrder } from '../custom-matcher'
2-
import { createChequeMockHttpServer } from '../http-mock/cheque-mock'
32
import { describeCommand, invokeTestCli } from '../utility'
43

54
expect.extend({
65
toMatchLinesInOrder,
76
})
87

98
describeCommand('Test Status command', ({ consoleMessages }) => {
10-
let server: ReturnType<typeof createChequeMockHttpServer>
11-
12-
beforeAll(() => {
13-
server = createChequeMockHttpServer(1333)
14-
})
15-
16-
afterAll(() => {
17-
server.close()
18-
})
19-
209
it('should print when api is unavailable', async () => {
2110
await invokeTestCli(['status', '--bee-api-url', 'http://localhost:14999'])
2211
await invokeTestCli(['status'])

test/http-mock/cheque-mock.ts

Lines changed: 0 additions & 208 deletions
This file was deleted.

test/misc/monetary-units.spec.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
import { toMatchLinesInOrder } from '../custom-matcher'
2-
import { createChequeMockHttpServer } from '../http-mock/cheque-mock'
32
import { describeCommand, invokeTestCli } from '../utility'
43

54
expect.extend({
65
toMatchLinesInOrder,
76
})
87

98
describeCommand('Test Monetary units', ({ consoleMessages }) => {
10-
let server: ReturnType<typeof createChequeMockHttpServer>
11-
12-
beforeAll(() => {
13-
server = createChequeMockHttpServer(1378)
14-
})
15-
16-
afterAll(() => {
17-
server.close()
18-
})
19-
209
const containsAllSubstrings = (string: string, substrings: string[]): boolean => {
2110
return substrings.every(substring => string.includes(substring))
2211
}
@@ -58,24 +47,24 @@ describeCommand('Test Monetary units', ({ consoleMessages }) => {
5847
})
5948

6049
it('should show units after running: cheque list', async () => {
61-
await invokeTestCli(['cheque', 'list', '--bee-api-url', 'http://localhost:1378'])
50+
await invokeTestCli(['cheque', 'list', '--bee-api-url', 'http://localhost:16337'])
6251
expectSubstringsPrinted('Cheque Value', 'xBZZ')
6352
})
6453

6554
it('should show units after running: cheque cashout', async () => {
66-
await invokeTestCli(['cheque', 'cashout', '--all', '--bee-api-url', 'http://localhost:1378'])
55+
await invokeTestCli(['cheque', 'cashout', '--all', '--bee-api-url', 'http://localhost:16337'])
6756
expectSubstringsPrinted('Cheque Value', 'xBZZ')
6857
})
6958

7059
it('should show units after running: balance', async () => {
71-
await invokeTestCli(['status', '--bee-api-url', 'http://localhost:1378'])
60+
await invokeTestCli(['status', '--bee-api-url', 'http://localhost:16337'])
7261
const pattern = [
7362
['Wallet'],
74-
['xBZZ', '0.3904'],
75-
['xDAI', '0.0961'],
63+
['xBZZ', '10.0000000000000000'],
64+
['xDAI', '5.000000000000000000'],
7665
['Chequebook'],
77-
['Available xBZZ', '10.001856'],
78-
['Total xBZZ', '10.002685'],
66+
['Available xBZZ', '0.0000000001000000'],
67+
['Total xBZZ', '0.0000000001000000'],
7968
]
8069
expect(consoleMessages).toMatchLinesInOrder(pattern)
8170
})

0 commit comments

Comments
 (0)