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..de427e04b0 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 = parseInt(tenderdashStatus.node_info.protocol_version.app, 10); + 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, }, }; diff --git a/packages/dashmate/test/unit/status/scopes/platform.spec.js b/packages/dashmate/test/unit/status/scopes/platform.spec.js index fc8bc8bf1c..14f0d88cff 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', @@ -407,11 +455,22 @@ 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=', + }, + }; + 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,