Skip to content

Commit 4992604

Browse files
authored
ci: wait for depth stabilization before running tests (#574)
* test: print console messages for --sync and --encrypt * test: add a test that prints curl commands * ci: test with node 20 and 22 * feat: add data sync progress to timeout message * chore: increase polling time and attempts * chore: print status before and after sync * chore: wait for depth to stabilize * chore: revert additional test printings
1 parent 9c06134 commit 4992604

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

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

2323
steps:
2424
- name: Checkout

jest.config.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
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'
56
import type { Config } from '@jest/types'
6-
import { Dates } from 'cafe-utility'
7+
import { Dates, System } from 'cafe-utility'
78
import { getPssAddress } from './test/utility/address'
89
import { getOrBuyStamp } from './test/utility/stamp'
910

@@ -21,6 +22,15 @@ export default async (): Promise<Config.InitialOptions> => {
2122
process.env.TEST_STAMP = (await getOrBuyStamp()).toHex()
2223
}
2324

25+
const bee = new Bee('http://localhost:1633')
26+
while (1) {
27+
const topology = await bee.getTopology()
28+
if (topology.depth < 31) {
29+
break
30+
}
31+
await System.sleepMillis(Dates.seconds(15))
32+
}
33+
2434
return {
2535
// Indicates whether the coverage information should be collected while executing the test
2636
// collectCoverage: false,

src/command/upload.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ export class Upload extends RootCommand implements LeafCommand {
7676
key: 'sync-polling-time',
7777
description: 'Waiting time in ms between sync pollings',
7878
type: 'number',
79-
default: 500,
79+
default: 1000,
8080
})
8181
public syncPollingTime!: number
8282

8383
@Option({
8484
key: 'sync-polling-trials',
8585
description: 'After the given trials the sync polling will stop',
8686
type: 'number',
87-
default: 15,
87+
default: 60,
8888
})
8989
public syncPollingTrials!: number
9090

@@ -363,7 +363,11 @@ export class Upload extends RootCommand implements LeafCommand {
363363
if (synced) {
364364
this.console.dim('Data has been synced on Swarm network')
365365
} else {
366-
this.console.error(this.path ? `'Data syncing timeout for ${this.path}'` : 'Data syncing timeout')
366+
this.console.error(
367+
this.path
368+
? `Data syncing timeout for ${this.path} (${syncProgress} / ${tag.split})`
369+
: `Data syncing timeout (${syncProgress} / ${tag.split})`,
370+
)
367371
exit(1)
368372
}
369373
}

test/command/upload.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { existsSync, unlinkSync, writeFileSync } from 'fs'
2+
import { LeafCommand } from 'furious-commander'
23
import type { Upload } from '../../src/command/upload'
34
import { describeCommand, invokeTestCli } from '../utility'
45
import { getStampOption } from '../utility/stamp'
5-
import { LeafCommand } from 'furious-commander'
66

77
function actUpload(command: { runnable?: LeafCommand | undefined }): [string, string] {
88
const uploadCommand = command.runnable as Upload

0 commit comments

Comments
 (0)