From 10e0966328e0c04dd0edb6a097f5693356a3ff8f Mon Sep 17 00:00:00 2001 From: Cafe137 Date: Wed, 1 Oct 2025 18:10:04 +0200 Subject: [PATCH 1/6] fix: do not error out in status when swap is disabled --- src/command/status.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/command/status.ts b/src/command/status.ts index 90b56905..596a8fdd 100644 --- a/src/command/status.ts +++ b/src/command/status.ts @@ -53,17 +53,27 @@ export class Status extends RootCommand implements LeafCommand { if (nodeInfo.beeMode !== BeeModes.ULTRA_LIGHT && nodeInfo.beeMode !== BeeModes.DEV) { this.console.all('') this.console.all(chalk.bold('Wallet')) - const { bzzBalance, nativeTokenBalance } = await this.bee.getWalletBalance() - this.console.all(createKeyValue('xBZZ', bzzBalance.toDecimalString())) - this.console.all(createKeyValue('xDAI', nativeTokenBalance.toDecimalString())) + try { + const { bzzBalance, nativeTokenBalance } = await this.bee.getWalletBalance() + this.console.all(createKeyValue('xBZZ', bzzBalance.toDecimalString())) + this.console.all(createKeyValue('xDAI', nativeTokenBalance.toDecimalString())) + } catch { + this.console.all(chalk.yellow('Wallet balance not available')) + this.console.all('This is normal if swap is disabled in the node configuration.') + } } if (nodeInfo.beeMode !== BeeModes.ULTRA_LIGHT && nodeInfo.beeMode !== BeeModes.DEV) { this.console.all('') this.console.all(chalk.bold('Chequebook')) - const { totalBalance, availableBalance } = await this.bee.getChequebookBalance() - this.console.all(createKeyValue('Available xBZZ', availableBalance.toDecimalString())) - this.console.all(createKeyValue('Total xBZZ', totalBalance.toDecimalString())) + try { + const { totalBalance, availableBalance } = await this.bee.getChequebookBalance() + this.console.all(createKeyValue('Available xBZZ', availableBalance.toDecimalString())) + this.console.all(createKeyValue('Total xBZZ', totalBalance.toDecimalString())) + } catch { + this.console.all(chalk.yellow('Chequebook balance not available')) + this.console.all('This is normal if swap is disabled in the node configuration.') + } } if (nodeInfo.beeMode === BeeModes.FULL) { From 012d28a02781a10bcfa8a77aabfdd8acd99c0c33 Mon Sep 17 00:00:00 2001 From: Cafe137 Date: Wed, 1 Oct 2025 18:49:17 +0200 Subject: [PATCH 2/6] test: add no-swap tests --- .github/workflows/ci.yaml | 3 +++ package-lock.json | 8 ++++---- package.json | 2 +- src/command/addresses.ts | 2 +- src/command/pss/subscribe.ts | 3 +++ src/command/status.ts | 4 ++-- test/misc/status-swap.spec.ts | 32 ++++++++++++++++++++++++++++++++ 7 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 test/misc/status-swap.spec.ts diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 656cf41b..95616106 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,6 +43,9 @@ jobs: - name: Run bee-dev run: npx bee-dev --port 16337 & + - name: Run bee-dev + run: npx bee-dev --port 16338 --no-swap & + - name: Start fdp-play environment run: fdp-play start --detach --fresh --bee-version ${{ matrix.bee-version }} diff --git a/package-lock.json b/package-lock.json index dbdb0f9b..48fb2578 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "BSD-3-Clause", "dependencies": { "@ethereumjs/wallet": "^2.0.4", - "@ethersphere/bee-js": "^9.8.1", + "@ethersphere/bee-js": "^10.0.1", "cafe-utility": "^31.0.0", "chalk": "^2.4.2", "cli-progress": "^3.11.2", @@ -1129,9 +1129,9 @@ } }, "node_modules/@ethersphere/bee-js": { - "version": "9.8.1", - "resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-9.8.1.tgz", - "integrity": "sha512-crOjFHYPdQPG1ty2KTO5b7spIGRVb6MLucC8KOyUsPk72XYCQLf0FZl8mwKAozqZd6NLOOPZw8E/ftjoz7zYJQ==", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-10.0.1.tgz", + "integrity": "sha512-RYvONkOIrVAOnTHp4y63AQLM4lwioUKwWc+F+1PRNVUmmUUFqx/ZLKiWuk6weRlXR2kWVVr1RcrQaa7ncA7g7w==", "license": "BSD-3-Clause", "dependencies": { "axios": "^0.30.0", diff --git a/package.json b/package.json index 66e5c8de..b34f22bf 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ }, "dependencies": { "@ethereumjs/wallet": "^2.0.4", - "@ethersphere/bee-js": "^9.8.1", + "@ethersphere/bee-js": "^10.0.1", "cafe-utility": "^31.0.0", "chalk": "^2.4.2", "cli-progress": "^3.11.2", diff --git a/src/command/addresses.ts b/src/command/addresses.ts index 636bd2d9..4556eb17 100644 --- a/src/command/addresses.ts +++ b/src/command/addresses.ts @@ -43,7 +43,7 @@ export class Addresses extends RootCommand implements LeafCommand { this.console.log('') this.console.log(chalk.bold('Chequebook Address')) this.console.divider() - this.console.log(chequebookAddress.chequebookAddress) + this.console.log(chequebookAddress.chequebookAddress.toHex()) }) this.console.quiet('Ethereum ' + this.nodeAddresses.ethereum) diff --git a/src/command/pss/subscribe.ts b/src/command/pss/subscribe.ts index e874b895..f00206d9 100644 --- a/src/command/pss/subscribe.ts +++ b/src/command/pss/subscribe.ts @@ -34,6 +34,9 @@ export class Subscribe extends PssCommand implements LeafCommand { onError: (error: BeeError) => { this.console.error(error.message) }, + onClose: () => { + this.console.log('Subscription closed') + }, }) } } diff --git a/src/command/status.ts b/src/command/status.ts index 596a8fdd..cdb81cd6 100644 --- a/src/command/status.ts +++ b/src/command/status.ts @@ -59,7 +59,7 @@ export class Status extends RootCommand implements LeafCommand { this.console.all(createKeyValue('xDAI', nativeTokenBalance.toDecimalString())) } catch { this.console.all(chalk.yellow('Wallet balance not available')) - this.console.all('This is normal if swap is disabled in the node configuration.') + this.console.all('This is normal if chequebook is disabled in the node configuration.') } } @@ -72,7 +72,7 @@ export class Status extends RootCommand implements LeafCommand { this.console.all(createKeyValue('Total xBZZ', totalBalance.toDecimalString())) } catch { this.console.all(chalk.yellow('Chequebook balance not available')) - this.console.all('This is normal if swap is disabled in the node configuration.') + this.console.all('This is normal if chequebook is disabled in the node configuration.') } } diff --git a/test/misc/status-swap.spec.ts b/test/misc/status-swap.spec.ts new file mode 100644 index 00000000..eef012c7 --- /dev/null +++ b/test/misc/status-swap.spec.ts @@ -0,0 +1,32 @@ +import { toMatchLinesInOrder } from '../custom-matcher' +import { describeCommand, invokeTestCli } from '../utility' + +expect.extend({ + toMatchLinesInOrder, +}) + +describeCommand('Status command and swap', ({ consoleMessages }) => { + it('should print wallet and chequebook balance', async () => { + await invokeTestCli(['stamp', 'status', '--bee-api-url', 'http://localhost:16337']) + expect(consoleMessages).toMatchLinesInOrder([ + ['Wallet'], + ['xBZZ'], + ['xDAI'], + ['Chequebook'], + ['Available xBZZ'], + ['Total xBZZ'], + ]) + }) + + it('should handle missing wallet and chequebook balance', async () => { + await invokeTestCli(['stamp', 'status', '--bee-api-url', 'http://localhost:16337']) + expect(consoleMessages).toMatchLinesInOrder([ + ['Wallet'], + ['Wallet balance not available'], + ['This is normal if chequebook is disabled in the node configuration.'], + ['Chequebook'], + ['Wallet balance not available'], + ['This is normal if chequebook is disabled in the node configuration.'], + ]) + }) +}) From 5d8b3b35a728fcb4131e6402385324e84a768bd6 Mon Sep 17 00:00:00 2001 From: Cafe137 Date: Wed, 1 Oct 2025 19:00:56 +0200 Subject: [PATCH 3/6] test(fix): fix command --- .github/workflows/ci.yaml | 2 +- test/misc/status-swap.spec.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 95616106..6760bb1d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,7 +43,7 @@ jobs: - name: Run bee-dev run: npx bee-dev --port 16337 & - - name: Run bee-dev + - name: Run bee-dev with --no-swap run: npx bee-dev --port 16338 --no-swap & - name: Start fdp-play environment diff --git a/test/misc/status-swap.spec.ts b/test/misc/status-swap.spec.ts index eef012c7..df7c98d6 100644 --- a/test/misc/status-swap.spec.ts +++ b/test/misc/status-swap.spec.ts @@ -7,7 +7,7 @@ expect.extend({ describeCommand('Status command and swap', ({ consoleMessages }) => { it('should print wallet and chequebook balance', async () => { - await invokeTestCli(['stamp', 'status', '--bee-api-url', 'http://localhost:16337']) + await invokeTestCli(['status', '--bee-api-url', 'http://localhost:16337']) expect(consoleMessages).toMatchLinesInOrder([ ['Wallet'], ['xBZZ'], @@ -19,7 +19,7 @@ describeCommand('Status command and swap', ({ consoleMessages }) => { }) it('should handle missing wallet and chequebook balance', async () => { - await invokeTestCli(['stamp', 'status', '--bee-api-url', 'http://localhost:16337']) + await invokeTestCli(['status', '--bee-api-url', 'http://localhost:16337']) expect(consoleMessages).toMatchLinesInOrder([ ['Wallet'], ['Wallet balance not available'], From c3308c32abdbe65c87181188b7958ff0d6cbd9f5 Mon Sep 17 00:00:00 2001 From: Cafe137 Date: Wed, 1 Oct 2025 19:11:23 +0200 Subject: [PATCH 4/6] test(fix): fix wrong url used in test --- test/misc/status-swap.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/misc/status-swap.spec.ts b/test/misc/status-swap.spec.ts index df7c98d6..97e72674 100644 --- a/test/misc/status-swap.spec.ts +++ b/test/misc/status-swap.spec.ts @@ -19,7 +19,7 @@ describeCommand('Status command and swap', ({ consoleMessages }) => { }) it('should handle missing wallet and chequebook balance', async () => { - await invokeTestCli(['status', '--bee-api-url', 'http://localhost:16337']) + await invokeTestCli(['status', '--bee-api-url', 'http://localhost:16338']) expect(consoleMessages).toMatchLinesInOrder([ ['Wallet'], ['Wallet balance not available'], From a34750627a5186543cc825d0a0d9bf97a9602590 Mon Sep 17 00:00:00 2001 From: Cafe137 Date: Wed, 1 Oct 2025 19:28:40 +0200 Subject: [PATCH 5/6] test(fix): fix name --- test/misc/status-swap.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/misc/status-swap.spec.ts b/test/misc/status-swap.spec.ts index 97e72674..34596ea9 100644 --- a/test/misc/status-swap.spec.ts +++ b/test/misc/status-swap.spec.ts @@ -25,7 +25,7 @@ describeCommand('Status command and swap', ({ consoleMessages }) => { ['Wallet balance not available'], ['This is normal if chequebook is disabled in the node configuration.'], ['Chequebook'], - ['Wallet balance not available'], + ['Chequebook balance not available'], ['This is normal if chequebook is disabled in the node configuration.'], ]) }) From 2925fc055e2834ee5337f2adbe6756ad53feb3de Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 17:41:26 +0000 Subject: [PATCH 6/6] test: update test coverage --- test/coverage/coverage-summary.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/coverage/coverage-summary.json b/test/coverage/coverage-summary.json index 1e48a1cd..60b130b6 100644 --- a/test/coverage/coverage-summary.json +++ b/test/coverage/coverage-summary.json @@ -1,4 +1,4 @@ -{"total": {"lines":{"total":2674,"covered":1953,"skipped":0,"pct":73.03},"statements":{"total":2694,"covered":1966,"skipped":0,"pct":72.97},"functions":{"total":318,"covered":242,"skipped":0,"pct":76.1},"branches":{"total":569,"covered":302,"skipped":0,"pct":53.07},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}} +{"total": {"lines":{"total":2681,"covered":1959,"skipped":0,"pct":73.06},"statements":{"total":2701,"covered":1972,"skipped":0,"pct":73},"functions":{"total":319,"covered":242,"skipped":0,"pct":75.86},"branches":{"total":569,"covered":302,"skipped":0,"pct":53.07},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}} ,"/home/runner/work/swarm-cli/swarm-cli/src/application.ts": {"lines":{"total":2,"covered":0,"skipped":0,"pct":0},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":2,"covered":0,"skipped":0,"pct":0},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} ,"/home/runner/work/swarm-cli/swarm-cli/src/config.ts": {"lines":{"total":31,"covered":30,"skipped":0,"pct":96.77},"functions":{"total":1,"covered":0,"skipped":0,"pct":0},"statements":{"total":31,"covered":30,"skipped":0,"pct":96.77},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} ,"/home/runner/work/swarm-cli/swarm-cli/src/curl.ts": {"lines":{"total":24,"covered":24,"skipped":0,"pct":100},"functions":{"total":7,"covered":7,"skipped":0,"pct":100},"statements":{"total":25,"covered":25,"skipped":0,"pct":100},"branches":{"total":13,"covered":12,"skipped":0,"pct":92.3}} @@ -7,7 +7,7 @@ ,"/home/runner/work/swarm-cli/swarm-cli/src/command/addresses.ts": {"lines":{"total":37,"covered":32,"skipped":0,"pct":86.48},"functions":{"total":6,"covered":5,"skipped":0,"pct":83.33},"statements":{"total":37,"covered":32,"skipped":0,"pct":86.48},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} ,"/home/runner/work/swarm-cli/swarm-cli/src/command/download.ts": {"lines":{"total":35,"covered":28,"skipped":0,"pct":80},"functions":{"total":4,"covered":4,"skipped":0,"pct":100},"statements":{"total":35,"covered":28,"skipped":0,"pct":80},"branches":{"total":11,"covered":4,"skipped":0,"pct":36.36}} ,"/home/runner/work/swarm-cli/swarm-cli/src/command/hash.ts": {"lines":{"total":10,"covered":8,"skipped":0,"pct":80},"functions":{"total":2,"covered":1,"skipped":0,"pct":50},"statements":{"total":10,"covered":8,"skipped":0,"pct":80},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} -,"/home/runner/work/swarm-cli/swarm-cli/src/command/status.ts": {"lines":{"total":73,"covered":51,"skipped":0,"pct":69.86},"functions":{"total":2,"covered":2,"skipped":0,"pct":100},"statements":{"total":73,"covered":51,"skipped":0,"pct":69.86},"branches":{"total":11,"covered":11,"skipped":0,"pct":100}} +,"/home/runner/work/swarm-cli/swarm-cli/src/command/status.ts": {"lines":{"total":79,"covered":57,"skipped":0,"pct":72.15},"functions":{"total":2,"covered":2,"skipped":0,"pct":100},"statements":{"total":79,"covered":57,"skipped":0,"pct":72.15},"branches":{"total":11,"covered":11,"skipped":0,"pct":100}} ,"/home/runner/work/swarm-cli/swarm-cli/src/command/upload.ts": {"lines":{"total":212,"covered":147,"skipped":0,"pct":69.33},"functions":{"total":15,"covered":13,"skipped":0,"pct":86.66},"statements":{"total":213,"covered":148,"skipped":0,"pct":69.48},"branches":{"total":95,"covered":53,"skipped":0,"pct":55.78}} ,"/home/runner/work/swarm-cli/swarm-cli/src/command/cheque/cashout.ts": {"lines":{"total":32,"covered":30,"skipped":0,"pct":93.75},"functions":{"total":4,"covered":4,"skipped":0,"pct":100},"statements":{"total":32,"covered":30,"skipped":0,"pct":93.75},"branches":{"total":2,"covered":2,"skipped":0,"pct":100}} ,"/home/runner/work/swarm-cli/swarm-cli/src/command/cheque/cheque-command.ts": {"lines":{"total":25,"covered":21,"skipped":0,"pct":84},"functions":{"total":5,"covered":5,"skipped":0,"pct":100},"statements":{"total":26,"covered":22,"skipped":0,"pct":84.61},"branches":{"total":2,"covered":0,"skipped":0,"pct":0}} @@ -54,7 +54,7 @@ ,"/home/runner/work/swarm-cli/swarm-cli/src/command/pss/pss-command.ts": {"lines":{"total":8,"covered":8,"skipped":0,"pct":100},"functions":{"total":2,"covered":2,"skipped":0,"pct":100},"statements":{"total":8,"covered":8,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} ,"/home/runner/work/swarm-cli/swarm-cli/src/command/pss/receive.ts": {"lines":{"total":24,"covered":18,"skipped":0,"pct":75},"functions":{"total":2,"covered":2,"skipped":0,"pct":100},"statements":{"total":24,"covered":18,"skipped":0,"pct":75},"branches":{"total":6,"covered":2,"skipped":0,"pct":33.33}} ,"/home/runner/work/swarm-cli/swarm-cli/src/command/pss/send.ts": {"lines":{"total":34,"covered":29,"skipped":0,"pct":85.29},"functions":{"total":2,"covered":2,"skipped":0,"pct":100},"statements":{"total":34,"covered":29,"skipped":0,"pct":85.29},"branches":{"total":5,"covered":2,"skipped":0,"pct":40}} -,"/home/runner/work/swarm-cli/swarm-cli/src/command/pss/subscribe.ts": {"lines":{"total":17,"covered":8,"skipped":0,"pct":47.05},"functions":{"total":4,"covered":1,"skipped":0,"pct":25},"statements":{"total":17,"covered":8,"skipped":0,"pct":47.05},"branches":{"total":4,"covered":0,"skipped":0,"pct":0}} +,"/home/runner/work/swarm-cli/swarm-cli/src/command/pss/subscribe.ts": {"lines":{"total":18,"covered":8,"skipped":0,"pct":44.44},"functions":{"total":5,"covered":1,"skipped":0,"pct":20},"statements":{"total":18,"covered":8,"skipped":0,"pct":44.44},"branches":{"total":4,"covered":0,"skipped":0,"pct":0}} ,"/home/runner/work/swarm-cli/swarm-cli/src/command/root-command/command-config.ts": {"lines":{"total":36,"covered":30,"skipped":0,"pct":83.33},"functions":{"total":6,"covered":6,"skipped":0,"pct":100},"statements":{"total":39,"covered":32,"skipped":0,"pct":82.05},"branches":{"total":9,"covered":5,"skipped":0,"pct":55.55}} ,"/home/runner/work/swarm-cli/swarm-cli/src/command/root-command/command-log.ts": {"lines":{"total":78,"covered":60,"skipped":0,"pct":76.92},"functions":{"total":9,"covered":6,"skipped":0,"pct":66.66},"statements":{"total":78,"covered":60,"skipped":0,"pct":76.92},"branches":{"total":11,"covered":7,"skipped":0,"pct":63.63}} ,"/home/runner/work/swarm-cli/swarm-cli/src/command/root-command/index.ts": {"lines":{"total":44,"covered":40,"skipped":0,"pct":90.9},"functions":{"total":4,"covered":4,"skipped":0,"pct":100},"statements":{"total":44,"covered":40,"skipped":0,"pct":90.9},"branches":{"total":9,"covered":5,"skipped":0,"pct":55.55}}