Skip to content

Commit 06ae618

Browse files
authored
ci: set explicit fdp-play bee version (#642)
* ci: set explicit fdp-play bee version * chore: update bee-js * test: use line matcher to be able to see actual output * chore: increase sync polling trials * ci: wait for all bee nodes to stabilize * test: increase warm up waiting time * test: use line matcher to be able to see actual output * test: add more sync and sync encrypt tests * ci: deposit to chequebook * ci: also test with 2.5 with a different warmup detection * ci: add swarm-cli status step, ignoring errors * ci: also test with bee 2.4.0 * ci: adjust warmup check for 2.4 * ci: fund chequebook of all nodes * ci: check chequebook balance in ci * ci: print actual chequebook balance * ci: adjust deposit to 10 bzz * ci: use different dockerfile
1 parent 91016e1 commit 06ae618

File tree

5 files changed

+96
-29
lines changed

5 files changed

+96
-29
lines changed

.github/workflows/ci.yaml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,45 @@ jobs:
1818

1919
strategy:
2020
matrix:
21-
node-version: [18.x, 20.x, 22.x]
21+
bee-version: ['d0aa8b9-commit']
2222

2323
steps:
2424
- name: Checkout
2525
uses: actions/checkout@v2
2626
with:
2727
fetch-depth: 1
2828

29-
- name: Use Node.js ${{ matrix.node-version }}
29+
- name: Set up Node.js
3030
uses: actions/setup-node@v1
3131
with:
32-
node-version: ${{ matrix.node-version }}
32+
node-version: 20.x
3333

34-
- name: Install npm deps
35-
run: npm ci && npm install -g @fairdatasociety/fdp-play
34+
- name: Install dependencies
35+
run: npm ci
36+
37+
- name: Install fdp-play
38+
run: npm install --global @fairdatasociety/fdp-play
39+
40+
- name: Install swarm-cli
41+
run: npm install --global @ethersphere/swarm-cli
3642

3743
- name: Run bee-dev
3844
run: npx bee-dev --port 16337 &
3945

4046
- name: Start fdp-play environment
41-
run: npm run bee
47+
run: fdp-play start --detach --fresh --bee-version ${{ matrix.bee-version }}
48+
49+
- name: Deposit to chequebook
50+
run: |
51+
swarm-cli cheque deposit 100000000000000000
52+
swarm-cli cheque deposit 100000000000000000 --bee-api-url http://localhost:11633
53+
swarm-cli cheque deposit 100000000000000000 --bee-api-url http://localhost:21633
54+
swarm-cli cheque deposit 100000000000000000 --bee-api-url http://localhost:31633
55+
swarm-cli cheque deposit 100000000000000000 --bee-api-url http://localhost:41633
56+
57+
- name: Print swarm-cli status
58+
continue-on-error: true
59+
run: swarm-cli status
4260

4361
- name: Tests
4462
run: npm run test

jest.config.ts

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* For a detailed explanation regarding each configuration property and type check, visit:
33
* https://jestjs.io/docs/en/configuration.html
44
*/
5-
import { Bee } from '@ethersphere/bee-js'
5+
import { Bee, BZZ } from '@ethersphere/bee-js'
66
import type { Config } from '@jest/types'
77
import { Dates, System } from 'cafe-utility'
88
import { getPssAddress } from './test/utility/address'
@@ -22,13 +22,40 @@ export default async (): Promise<Config.InitialOptions> => {
2222
process.env.TEST_STAMP = (await getOrBuyStamp()).toHex()
2323
}
2424

25-
const bee = new Bee('http://localhost:1633')
26-
while (1) {
27-
const topology = await bee.getTopology()
28-
if (topology.depth < 31) {
29-
break
25+
for (let i = 0; i < 5; i++) {
26+
const port = 1633 + i * 10000
27+
const bee = new Bee(`http://localhost:${port}`)
28+
29+
const startedAt = Date.now()
30+
console.log('Waiting for Bee node to warm up on port', port)
31+
const { version } = await bee.getHealth()
32+
if (version.includes('2.5') || version.startsWith('2.4')) {
33+
await System.waitFor(async () => (await bee.getTopology()).depth < 31, {
34+
attempts: 300,
35+
waitMillis: Dates.seconds(1),
36+
requiredConsecutivePasses: 3,
37+
})
38+
} else {
39+
await System.waitFor(async () => (await bee.getStatus()).isWarmingUp === false, {
40+
attempts: 300,
41+
waitMillis: Dates.seconds(1),
42+
requiredConsecutivePasses: 3,
43+
})
44+
}
45+
const elapsed = Date.now() - startedAt
46+
console.log(`Bee node on port ${port} warmed up in ${elapsed} milliseconds`)
47+
}
48+
49+
for (let i = 0; i < 5; i++) {
50+
const port = 1633 + i * 10000
51+
const bee = new Bee(`http://localhost:${port}`)
52+
53+
console.log('Asserting chequebook balance on port', port)
54+
const chequebookBalance = await bee.getChequebookBalance()
55+
if (!chequebookBalance.totalBalance.eq(BZZ.fromDecimalString('10'))) {
56+
throw Error('Chequebook total balance is not 10 xBZZ: ' + chequebookBalance.totalBalance.toDecimalString())
3057
}
31-
await System.sleepMillis(Dates.seconds(15))
58+
console.log(`Chequebook balance on port ${port} is 10 xBZZ`)
3259
}
3360

3461
return {

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"start": "ts-node src/index.ts",
3232
"lint": "eslint --fix \"src/**/*.ts\" \"test/**/*.ts\" && prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
3333
"lint:check": "eslint \"src/**/*.ts\" \"test/**/*.ts\" && prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
34-
"bee": "npx @fairdatasociety/[email protected] start --detach --fresh"
34+
"bee": "npx @fairdatasociety/[email protected] start --detach --fresh --bee-version 2.6.0"
3535
},
3636
"engines": {
3737
"node": ">=14.0.0",
@@ -63,8 +63,8 @@
6363
},
6464
"dependencies": {
6565
"@ethereumjs/wallet": "^2.0.4",
66-
"@ethersphere/bee-js": "^9.6.1",
67-
"cafe-utility": "^27.14.0",
66+
"@ethersphere/bee-js": "^9.7.0",
67+
"cafe-utility": "^31.0.0",
6868
"chalk": "^2.4.2",
6969
"cli-progress": "^3.11.2",
7070
"ethers": "^5.7.2",

test/command/upload.spec.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
import { existsSync, unlinkSync, writeFileSync } from 'fs'
22
import { LeafCommand } from 'furious-commander'
33
import type { Upload } from '../../src/command/upload'
4+
import { toMatchLinesInOrder } from '../custom-matcher'
45
import { describeCommand, invokeTestCli } from '../utility'
56
import { getStampOption } from '../utility/stamp'
67

8+
const SUCCESSFUL_SYNC_PATTERN = [
9+
['Data has been sent to the Bee node successfully!'],
10+
['Waiting for file chunks to be synced on Swarm network...'],
11+
['Data has been synced on Swarm network'],
12+
['Uploading was successful!'],
13+
]
14+
15+
expect.extend({
16+
toMatchLinesInOrder,
17+
})
18+
719
function actUpload(command: { runnable?: LeafCommand | undefined }): [string, string] {
820
const uploadCommand = command.runnable as Upload
921
const ref = uploadCommand.result.getOrThrow().toHex()
@@ -132,14 +144,24 @@ describeCommand('Test Upload command', ({ consoleMessages, hasMessageContaining
132144
expect(hasMessageContaining('does not support syncing')).toBeTruthy()
133145
})
134146

135-
it('should succeed with --sync', async () => {
147+
it('should succeed with --sync <1MB', async () => {
136148
await invokeTestCli(['upload', 'README.md', '--sync', '-v', ...getStampOption()])
137-
expect(hasMessageContaining('Uploading was successful!')).toBeTruthy()
149+
expect(consoleMessages).toMatchLinesInOrder(SUCCESSFUL_SYNC_PATTERN)
138150
})
139151

140-
it('should succeed with --sync and --encrypt', async () => {
152+
it('should succeed with --sync >1MB', async () => {
153+
await invokeTestCli(['upload', 'docs/stamp-buy.gif', '--sync', '-v', ...getStampOption()])
154+
expect(consoleMessages).toMatchLinesInOrder(SUCCESSFUL_SYNC_PATTERN)
155+
})
156+
157+
it('should succeed with --sync and --encrypt <1MB', async () => {
141158
await invokeTestCli(['upload', 'README.md', '--sync', '--encrypt', '-v', ...getStampOption()])
142-
expect(hasMessageContaining('Uploading was successful!')).toBeTruthy()
159+
expect(consoleMessages).toMatchLinesInOrder(SUCCESSFUL_SYNC_PATTERN)
160+
})
161+
162+
it('should succeed with --sync and --encrypt >1MB', async () => {
163+
await invokeTestCli(['upload', 'docs/stamp-buy.gif', '--sync', '--encrypt', '-v', ...getStampOption()])
164+
expect(consoleMessages).toMatchLinesInOrder(SUCCESSFUL_SYNC_PATTERN)
143165
})
144166

145167
it('should not print double trailing slashes', async () => {

0 commit comments

Comments
 (0)