Skip to content

Commit

Permalink
feat: add chainsync info to status command (#549)
Browse files Browse the repository at this point in the history
* feat: add chainsync info to status command

* test: add chainstate response to mock server
  • Loading branch information
Cafe137 authored Dec 9, 2024
1 parent a0bbf58 commit 951814d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/command/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class Status extends RootCommand implements LeafCommand {
public readonly description = 'Check Bee status'

public async run(): Promise<void> {
await super.init()
super.init()

this.console.all(chalk.bold('Bee'))
process.stdout.write(createKeyValue('API', this.beeApiUrl))
Expand Down Expand Up @@ -44,6 +44,15 @@ export class Status extends RootCommand implements LeafCommand {
const { bzzBalance, nativeTokenBalance } = await this.bee.getWalletBalance()
this.console.all(createKeyValue('xBZZ', Numbers.fromDecimals(bzzBalance, 16)))
this.console.all(createKeyValue('xDAI', Numbers.fromDecimals(nativeTokenBalance, 18)))
this.console.all('')
this.console.all(chalk.bold('Chainsync'))
const { block, chainTip } = await this.bee.getChainState()
this.console.all(
createKeyValue(
'Block',
`${block.toLocaleString()} / ${chainTip.toLocaleString()}${(chainTip - block).toLocaleString()})`,
),
)
}

if (nodeInfo.beeMode !== BeeModes.ULTRA_LIGHT && nodeInfo.beeMode !== BeeModes.DEV) {
Expand Down
11 changes: 11 additions & 0 deletions test/http-mock/cheque-mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export function createChequeMockHttpServer(port: number): Server {
response.end(JSON.stringify(balance))
}

if (request.url === '/chainstate') {
response.end(JSON.stringify(chainstate))
}

if (request.url === '/wallet') {
response.end(JSON.stringify(wallet))
}
Expand Down Expand Up @@ -92,6 +96,13 @@ const lastCashoutCheque1 = {

const balance = { totalBalance: '100026853000000000', availableBalance: '100018560000000000' }

const chainstate = {
chainTip: 37439274,
block: 37439270,
totalAmount: '153434201871',
currentPrice: '27356',
}

const wallet = {
bzzBalance: '3904697022414848',
nativeTokenBalance: '96106482372132023',
Expand Down

0 comments on commit 951814d

Please sign in to comment.