Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

fix: getStatus wrong hashes serialization #362

Merged
merged 18 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/grpcServer/handlers/core/getStatusHandlerFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ function getStatusHandlerFactory(coreRPCClient) {
chain.setName(blockchainInfoResponse.chain);
chain.setBlocksCount(blockchainInfoResponse.blocks);
chain.setHeadersCount(blockchainInfoResponse.headers);
chain.setBestBlockHash(blockchainInfoResponse.bestblockhash);
chain.setBestBlockHash(Buffer.from(blockchainInfoResponse.bestblockhash, 'hex'));
chain.setDifficulty(blockchainInfoResponse.difficulty);
chain.setChainWork(blockchainInfoResponse.chainwork);
chain.setChainWork(Buffer.from(blockchainInfoResponse.chainwork, 'hex'));
chain.setIsSynced(mnSyncStatusResponse.IsBlockchainSynced);
chain.setSyncProgress(blockchainInfoResponse.verificationprogress);

Expand All @@ -53,7 +53,7 @@ function getStatusHandlerFactory(coreRPCClient) {
const masternodeStatus = GetStatusResponse.Masternode.Status[masternodeStatusResponse.state];

masternode.setStatus(masternodeStatus);
masternode.setProTxHash(masternodeStatusResponse.proTxHash);
masternode.setProTxHash(Buffer.from(masternodeStatusResponse.proTxHash, 'hex'));
masternode.setPosePenalty(masternodeStatusResponse.dmnState.PoSePenalty);
masternode.setIsSynced(mnSyncStatusResponse.IsSynced);

Expand Down
8 changes: 4 additions & 4 deletions test/unit/grpcServer/handlers/core/getStatusHandlerFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('getStatusHandlerFactory', () => {
expect(result).to.be.an.instanceOf(GetStatusResponse);

// Validate protobuf object values
result.serializeBinary();
const serialized = result.serializeBinary();

const version = result.getVersion();
expect(version.getProtocol()).to.equal(networkInfo.protocolversion);
Expand All @@ -118,15 +118,15 @@ describe('getStatusHandlerFactory', () => {
expect(chain.getName()).to.be.equal(blockchainInfo.chain);
expect(chain.getBlocksCount()).to.be.equal(blockchainInfo.blocks);
expect(chain.getHeadersCount()).to.be.equal(blockchainInfo.headers);
expect(chain.getBestBlockHash()).to.be.equal(blockchainInfo.bestblockhash);
expect(chain.getBestBlockHash().toString('hex')).to.be.equal(blockchainInfo.bestblockhash);
expect(chain.getDifficulty()).to.be.equal(blockchainInfo.difficulty);
expect(chain.getChainWork()).to.be.equal(blockchainInfo.chainwork);
expect(chain.getChainWork().toString('hex')).to.be.equal(blockchainInfo.chainwork);
expect(chain.getIsSynced()).to.be.equal(mnSyncInfo.IsBlockchainSynced);
expect(chain.getSyncProgress()).to.be.equal(blockchainInfo.verificationprogress);

const masternode = result.getMasternode();
expect(masternode.getStatus()).to.be.equal(GetStatusResponse.Masternode.Status.READY);
expect(masternode.getProTxHash()).to.be.equal(masternodeStatus.proTxHash);
expect(masternode.getProTxHash().toString('hex')).to.be.equal(masternodeStatus.proTxHash);
expect(masternode.getPosePenalty()).to.be.equal(masternodeStatus.dmnState.PoSePenalty);
expect(masternode.getIsSynced()).to.be.equal(mnSyncInfo.IsSynced);
expect(masternode.getSyncProgress()).to.be.equal(1);
Expand Down