From 4c4d9251d05fba61d6fbc6cfb1742ac0cce93402 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Wed, 16 Oct 2024 23:23:05 +0700 Subject: [PATCH 1/7] fix(dashmate): invalid platform version in the status command --- packages/dashmate/src/commands/group/status.js | 2 +- packages/dashmate/src/commands/status/index.js | 2 +- packages/dashmate/src/commands/status/platform.js | 1 - packages/dashmate/src/status/scopes/overview.js | 3 ++- packages/dashmate/src/status/scopes/platform.js | 12 ++++++++++++ packages/rs-drive-abci/src/main.rs | 10 ++++++++++ 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/packages/dashmate/src/commands/group/status.js b/packages/dashmate/src/commands/group/status.js index d3edbd8800..f9c20f800f 100644 --- a/packages/dashmate/src/commands/group/status.js +++ b/packages/dashmate/src/commands/group/status.js @@ -86,7 +86,7 @@ export default class GroupStatusCommand extends GroupBaseCommand { plain['Platform Status'] = colors.status(scope.platform.tenderdash.serviceStatus)(scope.platform.tenderdash.serviceStatus) || 'n/a'; } else { plain['Platform Status'] = colors.status(scope.platform.tenderdash.serviceStatus)(scope.platform.tenderdash.serviceStatus) || 'n/a'; - plain['Platform Version'] = scope.platform.tenderdash.version || 'n/a'; + plain['Platform Version'] = scope.platform.drive.version || 'n/a'; plain['Platform Block Height'] = scope.platform.tenderdash.latestBlockHeight || 'n/a'; plain['Platform Peers'] = scope.platform.tenderdash.peers || 'n/a'; plain['Platform Network'] = scope.platform.tenderdash.network || 'n/a'; diff --git a/packages/dashmate/src/commands/status/index.js b/packages/dashmate/src/commands/status/index.js index 6276bb9796..dff8849d3a 100644 --- a/packages/dashmate/src/commands/status/index.js +++ b/packages/dashmate/src/commands/status/index.js @@ -112,7 +112,7 @@ export default class StatusCommand extends ConfigBaseCommand { plain['Platform Status'] = colors.status(platform.tenderdash.serviceStatus)(platform.tenderdash.serviceStatus) || 'n/a'; if (platform.tenderdash.serviceStatus === ServiceStatusEnum.up) { - plain['Platform Version'] = platform.tenderdash.version || 'n/a'; + plain['Platform Version'] = platform.drive.version || 'n/a'; plain['Platform Block Height'] = platform.tenderdash.latestBlockHeight || 'n/a'; plain['Platform Peers'] = platform.tenderdash.peers || 'n/a'; plain['Platform Network'] = platform.tenderdash.network || 'n/a'; diff --git a/packages/dashmate/src/commands/status/platform.js b/packages/dashmate/src/commands/status/platform.js index 2c0e401f18..4f6eba5fbb 100644 --- a/packages/dashmate/src/commands/status/platform.js +++ b/packages/dashmate/src/commands/status/platform.js @@ -32,7 +32,6 @@ export default class PlatformStatusCommand extends ConfigBaseCommand { flags, dockerCompose, createRpcClient, - getConnectionHost, config, getPlatformScope, ) { diff --git a/packages/dashmate/src/status/scopes/overview.js b/packages/dashmate/src/status/scopes/overview.js index a38d9ffb5e..2a56bd3678 100644 --- a/packages/dashmate/src/status/scopes/overview.js +++ b/packages/dashmate/src/status/scopes/overview.js @@ -57,8 +57,9 @@ export default function getOverviewScopeFactory( } if (config.get('platform.enable')) { - const { tenderdash } = await getPlatformScope(config); + const { drive, tenderdash } = await getPlatformScope(config); + platform.drive = drive; platform.tenderdash = tenderdash; } diff --git a/packages/dashmate/src/status/scopes/platform.js b/packages/dashmate/src/status/scopes/platform.js index 7605104ecb..56860d5056 100644 --- a/packages/dashmate/src/status/scopes/platform.js +++ b/packages/dashmate/src/status/scopes/platform.js @@ -174,6 +174,18 @@ export default function getPlatformScopeFactory( if (driveEchoResult.exitCode !== 0) { info.serviceStatus = ServiceStatusEnum.error; } + + const driveVersionResult = await dockerCompose.execCommand( + config, + 'drive_abci', + 'drive-abci version', + ); + + console.dir(driveVersionResult); + + if (driveVersionResult.exitCode === 0) { + info.version = driveVersionResult.stdout; + } } return info; diff --git a/packages/rs-drive-abci/src/main.rs b/packages/rs-drive-abci/src/main.rs index aab50e3e06..ad82c770c1 100644 --- a/packages/rs-drive-abci/src/main.rs +++ b/packages/rs-drive-abci/src/main.rs @@ -54,6 +54,10 @@ enum Commands { /// by creating `.fsck` file in database directory (`DB_PATH`). #[command()] Verify, + + /// Print current software version + #[command()] + Version, } /// Server that accepts connections from Tenderdash, and @@ -134,6 +138,7 @@ impl Cli { Commands::Config => dump_config(&config)?, Commands::Status => check_status(&config)?, Commands::Verify => verify_grovedb(&config.db_path, true)?, + Commands::Version => print_version(), }; Ok(()) @@ -386,6 +391,11 @@ fn verify_grovedb(db_path: &PathBuf, force: bool) -> Result<(), String> { } } +/// Print current software version. +fn print_version() { + println!("{}", env!("CARGO_PKG_VERSION")); +} + fn load_config(path: &Option) -> PlatformConfig { if let Some(path) = path { if let Err(e) = dotenvy::from_path(path) { From f088a3c5e3350c29fb575b3e150576be8adb36ab Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Fri, 18 Oct 2024 18:23:12 +0700 Subject: [PATCH 2/7] fix: getting version from drive --- packages/dashmate/src/status/scopes/platform.js | 14 ++++++++++---- packages/rs-drive-abci/src/main.rs | 15 +++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/dashmate/src/status/scopes/platform.js b/packages/dashmate/src/status/scopes/platform.js index 8f537508f3..cb53d89788 100644 --- a/packages/dashmate/src/status/scopes/platform.js +++ b/packages/dashmate/src/status/scopes/platform.js @@ -159,6 +159,7 @@ export default function getPlatformScopeFactory( const info = { dockerStatus: null, serviceStatus: null, + version: null, }; try { @@ -189,17 +190,22 @@ export default function getPlatformScopeFactory( } else { throw e; } + } + try { const driveVersionResult = await dockerCompose.execCommand( config, 'drive_abci', 'drive-abci version', ); - console.dir(driveVersionResult); - - if (driveVersionResult.exitCode === 0) { - info.version = driveVersionResult.stdout; + info.version = driveVersionResult.out.trim(); + } catch (e) { + // Throw an error if it's not a Drive issue + if (!(e instanceof DockerComposeError + && e.dockerComposeExecutionResult + && e.dockerComposeExecutionResult.exitCode !== 0)) { + throw e; } } } diff --git a/packages/rs-drive-abci/src/main.rs b/packages/rs-drive-abci/src/main.rs index e6c702e3dc..a8ae1adccd 100644 --- a/packages/rs-drive-abci/src/main.rs +++ b/packages/rs-drive-abci/src/main.rs @@ -225,16 +225,11 @@ fn main() -> Result<(), ExitCode> { runtime.spawn(handle_signals(cancel.clone(), loggers)); - let result = match cli.run(&runtime, config, cancel) { - Ok(()) => { - tracing::debug!("shutdown complete"); - Ok(()) - } - Err(e) => { - tracing::error!(error = e, "drive-abci failed: {e}"); - Err(ExitCode::FAILURE) - } - }; + let result = cli.run(&runtime, config, cancel).map_err(|e| { + tracing::error!(error = e, "drive-abci failed: {e}"); + + ExitCode::FAILURE + }); drop(runtime_guard); runtime.shutdown_timeout(Duration::from_millis(SHUTDOWN_TIMEOUT_MILIS)); From ca0c22324d0b680cfe91a04ad83ba7294e7e64b6 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Fri, 18 Oct 2024 18:36:26 +0700 Subject: [PATCH 3/7] chore: temporary ignore elliptic audit --- .yarnrc.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.yarnrc.yml b/.yarnrc.yml index dd002648b0..c59f803d7d 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -16,6 +16,7 @@ npmAuditExcludePackages: - "@humanwhocodes/object-schema" # TODO: Update eslint - micromatch # TODO: remove when new micromatch will be released https://github.com/advisories/GHSA-952p-6rrq-rcjv - eslint # TODO: Update eslint https://github.com/dashpay/platform/issues/2212 + - elliptic # TODO: Remove when elliptic >6.5.7 released packageExtensions: "@dashevo/protobufjs@*": From bd518c94731cb35f24e675e3e0664ad805fe6c56 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Fri, 18 Oct 2024 22:22:21 +0700 Subject: [PATCH 4/7] fix: version is available only when Drive is up --- .../dashmate/src/status/scopes/platform.js | 28 +++++++++---------- .../test/unit/status/scopes/platform.spec.js | 25 ++++++++++++----- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/packages/dashmate/src/status/scopes/platform.js b/packages/dashmate/src/status/scopes/platform.js index cb53d89788..04daa6070f 100644 --- a/packages/dashmate/src/status/scopes/platform.js +++ b/packages/dashmate/src/status/scopes/platform.js @@ -191,22 +191,22 @@ export default function getPlatformScopeFactory( throw e; } } + } - try { - const driveVersionResult = await dockerCompose.execCommand( - config, - 'drive_abci', - 'drive-abci version', - ); + try { + const driveVersionResult = await dockerCompose.execCommand( + config, + 'drive_abci', + 'drive-abci version', + ); - info.version = driveVersionResult.out.trim(); - } catch (e) { - // Throw an error if it's not a Drive issue - if (!(e instanceof DockerComposeError - && e.dockerComposeExecutionResult - && e.dockerComposeExecutionResult.exitCode !== 0)) { - throw e; - } + info.version = driveVersionResult.out.trim(); + } catch (e) { + // Throw an error if it's not a Drive issue + if (!(e instanceof DockerComposeError + && e.dockerComposeExecutionResult + && e.dockerComposeExecutionResult.exitCode !== 0)) { + throw e; } } diff --git a/packages/dashmate/test/unit/status/scopes/platform.spec.js b/packages/dashmate/test/unit/status/scopes/platform.spec.js index b94f0da636..fc8bc8bf1c 100644 --- a/packages/dashmate/test/unit/status/scopes/platform.spec.js +++ b/packages/dashmate/test/unit/status/scopes/platform.spec.js @@ -1,5 +1,6 @@ import ContainerIsNotPresentError from '../../../../src/docker/errors/ContainerIsNotPresentError.js'; +import DockerComposeError from '../../../../src/docker/errors/DockerComposeError.js'; import providers from '../../../../src/status/providers.js'; import determineStatus from '../../../../src/status/determineStatus.js'; import getConfigMock from '../../../../src/test/mock/getConfigMock.js'; @@ -73,7 +74,8 @@ describe('getPlatformScopeFactory', () => { }, }); mockDockerCompose.isServiceRunning.returns(true); - mockDockerCompose.execCommand.returns({ exitCode: 0, out: '' }); + mockDockerCompose.execCommand.withArgs(config, 'drive_abci', 'drive-abci status').resolves({ exitCode: 0, out: '' }); + mockDockerCompose.execCommand.withArgs(config, 'drive_abci', 'drive-abci version').resolves({ exitCode: 0, out: '1.4.1' }); mockMNOWatchProvider.returns(Promise.resolve('OPEN')); const mockStatus = { @@ -121,6 +123,7 @@ describe('getPlatformScopeFactory', () => { drive: { dockerStatus: DockerStatusEnum.running, serviceStatus: ServiceStatusEnum.up, + version: '1.4.1', }, }; @@ -147,7 +150,7 @@ describe('getPlatformScopeFactory', () => { }, }); mockDockerCompose.isServiceRunning.returns(true); - mockDockerCompose.execCommand.returns({ exitCode: 0, out: '' }); + mockDockerCompose.execCommand.withArgs(config, 'drive_abci', 'drive-abci version').resolves({ exitCode: 0, out: '1.4.1' }); mockMNOWatchProvider.returns(Promise.resolve('OPEN')); const mockStatus = { @@ -195,6 +198,7 @@ describe('getPlatformScopeFactory', () => { drive: { dockerStatus: DockerStatusEnum.running, serviceStatus: ServiceStatusEnum.up, + version: '1.4.1', }, }; @@ -212,7 +216,6 @@ describe('getPlatformScopeFactory', () => { it('should return empty scope if error during request to core', async () => { mockRpcClient.mnsync.withArgs('status').throws(new Error()); - mockDockerCompose.execCommand.returns({ exitCode: 0, out: '' }); mockDockerCompose.isServiceRunning.returns(true); mockDetermineDockerStatus.withArgs(mockDockerCompose, config, 'drive_tenderdash') .returns(DockerStatusEnum.running); @@ -268,7 +271,7 @@ describe('getPlatformScopeFactory', () => { }, }, }); - mockDockerCompose.execCommand.returns({ exitCode: 1, out: '' }); + mockDockerCompose.execCommand.withArgs(config, 'drive_abci', 'drive-abci version').resolves({ exitCode: 0, out: '1.4.1' }); mockMNOWatchProvider.returns(Promise.resolve('OPEN')); const expectedScope = { @@ -300,6 +303,7 @@ describe('getPlatformScopeFactory', () => { drive: { dockerStatus: DockerStatusEnum.running, serviceStatus: ServiceStatusEnum.wait_for_core, + version: '1.4.1', }, }; @@ -324,7 +328,7 @@ describe('getPlatformScopeFactory', () => { .returns(DockerStatusEnum.running); mockDetermineDockerStatus.withArgs(mockDockerCompose, config, 'drive_abci') .returns(DockerStatusEnum.running); - mockDockerCompose.execCommand.returns({ exitCode: 0, out: '' }); + mockDockerCompose.execCommand.withArgs(config, 'drive_abci', 'drive-abci version').resolves({ exitCode: 0, out: '1.4.1' }); mockMNOWatchProvider.returns(Promise.resolve('OPEN')); const expectedScope = { @@ -356,6 +360,7 @@ describe('getPlatformScopeFactory', () => { drive: { dockerStatus: DockerStatusEnum.running, serviceStatus: ServiceStatusEnum.up, + version: '1.4.1', }, }; @@ -380,8 +385,11 @@ describe('getPlatformScopeFactory', () => { .returns(DockerStatusEnum.running); mockDetermineDockerStatus.withArgs(mockDockerCompose, config, 'drive_abci') .throws(new ContainerIsNotPresentError('drive_abci')); - mockDockerCompose.execCommand.returns({ exitCode: 0, out: '' }); mockMNOWatchProvider.returns(Promise.resolve('OPEN')); + const error = new DockerComposeError({ + exitCode: 1, + }); + mockDockerCompose.execCommand.withArgs(config, 'drive_abci', 'drive-abci version').rejects(error); const mockStatus = { node_info: { @@ -434,6 +442,7 @@ describe('getPlatformScopeFactory', () => { drive: { dockerStatus: DockerStatusEnum.not_started, serviceStatus: ServiceStatusEnum.stopped, + version: null, }, }; @@ -454,7 +463,8 @@ describe('getPlatformScopeFactory', () => { mockDockerCompose.isServiceRunning .withArgs(config, 'drive_tenderdash') .returns(true); - mockDockerCompose.execCommand.returns({ exitCode: 0, out: '' }); + mockDockerCompose.execCommand.withArgs(config, 'drive_abci', 'drive-abci status').resolves({ exitCode: 0, out: '' }); + mockDockerCompose.execCommand.withArgs(config, 'drive_abci', 'drive-abci version').resolves({ exitCode: 0, out: '1.4.1' }); mockDetermineDockerStatus.returns(DockerStatusEnum.running); mockMNOWatchProvider.returns(Promise.resolve('OPEN')); mockFetch.returns(Promise.reject(new Error('FetchError'))); @@ -488,6 +498,7 @@ describe('getPlatformScopeFactory', () => { drive: { dockerStatus: DockerStatusEnum.running, serviceStatus: ServiceStatusEnum.up, + version: '1.4.1', }, }; From b477cdaacb2e4938174ee7211cf4748782738332 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Sat, 19 Oct 2024 00:10:50 +0700 Subject: [PATCH 5/7] feat(dashmate): add protocol version to the status command --- .../dashmate/src/commands/status/platform.js | 6 ++++++ packages/dashmate/src/status/scopes/platform.js | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/dashmate/src/commands/status/platform.js b/packages/dashmate/src/commands/status/platform.js index 4f6eba5fbb..17abfcdf1e 100644 --- a/packages/dashmate/src/commands/status/platform.js +++ b/packages/dashmate/src/commands/status/platform.js @@ -47,6 +47,8 @@ export default class PlatformStatusCommand extends ConfigBaseCommand { 'Drive Service Status': 'n/a', 'Network': 'n/a', 'Tenderdash Version': 'n/a', + 'Protocol Version': 'n/a', + 'Desired Protocol Version': 'n/a', 'Block height': 'n/a', 'Peer count': 'n/a', 'App hash': 'n/a', @@ -92,6 +94,8 @@ export default class PlatformStatusCommand extends ConfigBaseCommand { if (tenderdash.version) { const { version: tenderdashVersion, + protocolVersion, + desiredProtocolVersion, latestBlockHeight: platformBlockHeight, latestAppHash: platformLatestAppHash, peers: platformPeers, @@ -100,6 +104,8 @@ export default class PlatformStatusCommand extends ConfigBaseCommand { plain['Network'] = tenderdashNetwork || 'n/a'; plain['Tenderdash Version'] = tenderdashVersion || 'n/a'; + plain['Protocol Version'] = protocolVersion || 'n/a'; + plain['Desired Protocol Version'] = desiredProtocolVersion || 'n/a'; plain['Block height'] = platformBlockHeight || 'n/a'; plain['Peer count'] = platformPeers || 'n/a'; plain['App hash'] = platformLatestAppHash || 'n/a'; diff --git a/packages/dashmate/src/status/scopes/platform.js b/packages/dashmate/src/status/scopes/platform.js index 04daa6070f..ca7780ae89 100644 --- a/packages/dashmate/src/status/scopes/platform.js +++ b/packages/dashmate/src/status/scopes/platform.js @@ -52,6 +52,8 @@ export default function getPlatformScopeFactory( dockerStatus: null, serviceStatus: null, version: null, + protocolVersion: null, + desiredProtocolVersion: null, listening: null, catchingUp: null, latestBlockHash: null, @@ -107,14 +109,20 @@ export default function getPlatformScopeFactory( const port = config.get('platform.drive.tenderdash.rpc.port'); - const [tenderdashStatusResponse, tenderdashNetInfoResponse] = await Promise.all([ + const [ + tenderdashStatusResponse, + tenderdashNetInfoResponse, + tenderdashAbciInfoResponse, + ] = await Promise.all([ fetch(`http://${tenderdashHost}:${port}/status`), fetch(`http://${tenderdashHost}:${port}/net_info`), + fetch(`http://${tenderdashHost}:${port}/abci_info`), ]); - const [tenderdashStatus, tenderdashNetInfo] = await Promise.all([ + const [tenderdashStatus, tenderdashNetInfo, tenderdashAbciInfo] = await Promise.all([ tenderdashStatusResponse.json(), tenderdashNetInfoResponse.json(), + tenderdashAbciInfoResponse.json(), ]); const { version, network, moniker } = tenderdashStatus.node_info; @@ -133,6 +141,8 @@ export default function getPlatformScopeFactory( } info.version = version; + info.protocolVersion = tenderdashStatus.node_info.protocol_version.app; + info.desiredProtocolVersion = tenderdashAbciInfo.response.app_version; info.listening = listening; info.latestBlockHeight = latestBlockHeight; info.latestBlockTime = latestBlockTime; @@ -245,6 +255,8 @@ export default function getPlatformScopeFactory( dockerStatus: null, serviceStatus: null, version: null, + protocolVersion: null, + desiredProtocolVersion: null, listening: null, catchingUp: null, latestBlockHash: null, @@ -258,6 +270,7 @@ export default function getPlatformScopeFactory( drive: { dockerStatus: null, serviceStatus: null, + version: null, }, }; From ca6f4bc057b249e9e53cf6ad99760cc289800ed5 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Sat, 19 Oct 2024 00:26:52 +0700 Subject: [PATCH 6/7] test: update test --- .../dashmate/src/status/scopes/platform.js | 2 +- .../test/unit/status/scopes/platform.spec.js | 71 +++++++++++++++++-- 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/packages/dashmate/src/status/scopes/platform.js b/packages/dashmate/src/status/scopes/platform.js index ca7780ae89..de427e04b0 100644 --- a/packages/dashmate/src/status/scopes/platform.js +++ b/packages/dashmate/src/status/scopes/platform.js @@ -141,7 +141,7 @@ export default function getPlatformScopeFactory( } info.version = version; - info.protocolVersion = tenderdashStatus.node_info.protocol_version.app; + info.protocolVersion = parseInt(tenderdashStatus.node_info.protocol_version.app, 10); info.desiredProtocolVersion = tenderdashAbciInfo.response.app_version; info.listening = listening; info.latestBlockHeight = latestBlockHeight; diff --git a/packages/dashmate/test/unit/status/scopes/platform.spec.js b/packages/dashmate/test/unit/status/scopes/platform.spec.js index fc8bc8bf1c..fd768a40a9 100644 --- a/packages/dashmate/test/unit/status/scopes/platform.spec.js +++ b/packages/dashmate/test/unit/status/scopes/platform.spec.js @@ -80,6 +80,11 @@ describe('getPlatformScopeFactory', () => { const mockStatus = { node_info: { + protocol_version: { + p2p: '10', + block: '14', + app: '3', + }, version: '0', network: 'test', moniker: 'test', @@ -94,6 +99,15 @@ describe('getPlatformScopeFactory', () => { }; const mockNetInfo = { n_peers: 6, listening: true }; + const mockAbciInfo = { + response: { + version: '1.4.1', + app_version: 4, + last_block_height: 90, + last_block_app_hash: 's0CySQxgRg96DrnJ7HCsql+k/Sk4JiT3y0psCaUI3TI=', + }, + }; + const expectedScope = { platformActivation: 'Activated (at height 1337)', coreIsSynced: true, @@ -109,6 +123,8 @@ describe('getPlatformScopeFactory', () => { p2pPortState: PortStateEnum.OPEN, dockerStatus: DockerStatusEnum.running, serviceStatus: ServiceStatusEnum.up, + protocolVersion: 3, + desiredProtocolVersion: 4, version: '0', listening: true, catchingUp: false, @@ -131,7 +147,9 @@ describe('getPlatformScopeFactory', () => { .onFirstCall() .returns(Promise.resolve({ json: () => Promise.resolve(mockStatus) })) .onSecondCall() - .returns(Promise.resolve({ json: () => Promise.resolve(mockNetInfo) })); + .returns(Promise.resolve({ json: () => Promise.resolve(mockNetInfo) })) + .onThirdCall() + .resolves({ json: () => Promise.resolve(mockAbciInfo) }); mockMNOWatchProvider.returns(Promise.resolve('OPEN')); const scope = await getPlatformScope(config); @@ -155,6 +173,11 @@ describe('getPlatformScopeFactory', () => { const mockStatus = { node_info: { + protocol_version: { + p2p: '10', + block: '14', + app: '3', + }, version: '0', network: 'test', moniker: 'test', @@ -169,6 +192,15 @@ describe('getPlatformScopeFactory', () => { }; const mockNetInfo = { n_peers: 6, listening: true }; + const mockAbciInfo = { + response: { + version: '1.4.1', + app_version: 4, + last_block_height: 90, + last_block_app_hash: 's0CySQxgRg96DrnJ7HCsql+k/Sk4JiT3y0psCaUI3TI=', + }, + }; + const expectedScope = { platformActivation: 'Activated (at height 1337)', coreIsSynced: true, @@ -185,6 +217,8 @@ describe('getPlatformScopeFactory', () => { dockerStatus: DockerStatusEnum.running, serviceStatus: ServiceStatusEnum.syncing, version: '0', + protocolVersion: 3, + desiredProtocolVersion: 4, listening: true, catchingUp: true, latestBlockHash: 'DEADBEEF', @@ -206,7 +240,9 @@ describe('getPlatformScopeFactory', () => { .onFirstCall() .returns(Promise.resolve({ json: () => Promise.resolve(mockStatus) })) .onSecondCall() - .returns(Promise.resolve({ json: () => Promise.resolve(mockNetInfo) })); + .returns(Promise.resolve({ json: () => Promise.resolve(mockNetInfo) })) + .onThirdCall() + .resolves({ json: () => Promise.resolve(mockAbciInfo) }); mockMNOWatchProvider.returns(Promise.resolve('OPEN')); const scope = await getPlatformScope(config); @@ -238,6 +274,8 @@ describe('getPlatformScopeFactory', () => { dockerStatus: null, serviceStatus: null, version: null, + protocolVersion: null, + desiredProtocolVersion: null, listening: null, catchingUp: null, latestBlockHash: null, @@ -251,6 +289,7 @@ describe('getPlatformScopeFactory', () => { drive: { dockerStatus: null, serviceStatus: null, + version: null, }, }; @@ -290,6 +329,8 @@ describe('getPlatformScopeFactory', () => { dockerStatus: DockerStatusEnum.running, serviceStatus: ServiceStatusEnum.wait_for_core, version: null, + protocolVersion: null, + desiredProtocolVersion: null, listening: null, catchingUp: null, latestBlockHash: null, @@ -347,6 +388,8 @@ describe('getPlatformScopeFactory', () => { dockerStatus: DockerStatusEnum.running, serviceStatus: ServiceStatusEnum.error, version: null, + protocolVersion: null, + desiredProtocolVersion: null, listening: null, catchingUp: null, latestBlockHash: null, @@ -393,6 +436,11 @@ describe('getPlatformScopeFactory', () => { const mockStatus = { node_info: { + protocol_version: { + p2p: '10', + block: '14', + app: '3', + }, version: '0', network: 'test', moniker: 'test', @@ -405,13 +453,24 @@ describe('getPlatformScopeFactory', () => { latest_block_time: 1337, }, }; - const mockNetInfo = { n_peers: 6, listening: true }; + const mockNetInfo = { n_peers: 6, listening: true } + + const mockAbciInfo = { + response: { + version: '1.4.1', + app_version: 4, + last_block_height: 90, + last_block_app_hash: 's0CySQxgRg96DrnJ7HCsql+k/Sk4JiT3y0psCaUI3TI=', + }, + }; mockFetch .onFirstCall() .returns(Promise.resolve({ json: () => Promise.resolve(mockStatus) })) .onSecondCall() - .returns(Promise.resolve({ json: () => Promise.resolve(mockNetInfo) })); + .returns(Promise.resolve({ json: () => Promise.resolve(mockNetInfo) })) + .onThirdCall() + .resolves({ json: () => Promise.resolve(mockAbciInfo) }); const expectedScope = { platformActivation: 'Activated (at height 1337)', @@ -429,6 +488,8 @@ describe('getPlatformScopeFactory', () => { dockerStatus: DockerStatusEnum.running, serviceStatus: ServiceStatusEnum.up, version: '0', + protocolVersion: 3, + desiredProtocolVersion: 4, listening: true, catchingUp: false, latestBlockHash: 'DEADBEEF', @@ -485,6 +546,8 @@ describe('getPlatformScopeFactory', () => { dockerStatus: DockerStatusEnum.running, serviceStatus: ServiceStatusEnum.error, version: null, + protocolVersion: null, + desiredProtocolVersion: null, listening: null, catchingUp: null, latestBlockHash: null, From bfd2b769bede35f3a9bfefdffc4c22edb87aacf1 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Sat, 19 Oct 2024 12:31:00 +0700 Subject: [PATCH 7/7] style: add missing semicolon --- packages/dashmate/test/unit/status/scopes/platform.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dashmate/test/unit/status/scopes/platform.spec.js b/packages/dashmate/test/unit/status/scopes/platform.spec.js index fd768a40a9..14f0d88cff 100644 --- a/packages/dashmate/test/unit/status/scopes/platform.spec.js +++ b/packages/dashmate/test/unit/status/scopes/platform.spec.js @@ -453,7 +453,7 @@ describe('getPlatformScopeFactory', () => { latest_block_time: 1337, }, }; - const mockNetInfo = { n_peers: 6, listening: true } + const mockNetInfo = { n_peers: 6, listening: true }; const mockAbciInfo = { response: {