2

I am configuring Hyperledger Explorer, in a Ubuntu virtual machine version 16.04, to integrate with Hyperledger Composer based in this link: https://github.com/hyperledger/blockchain-explorer/blob/master/README.md

I have followed all the steps of the configuration according to github link including the database setup and modified the config.json file to use the structure of the first-network of Hyperledger Fabric samples like this:

  {
  "network-config": {
    "org1": {
      "name": "peerOrg1",
      "mspid": "Org1MSP",
      "peer1": {
        "requests": "grpcs://127.0.0.1:7051",
        "events": "grpcs://127.0.0.1:7053",
        "server-hostname": "peer0.org1.example.com",
        "tls_cacerts":
          "/home/diogosilva/fabric-dev-servers/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
      },
      "peer2": {
        "requests": "grpcs://127.0.0.1:8051",
        "events": "grpcs://127.0.0.1:8053",
        "server-hostname": "peer1.org1.example.com",
        "tls_cacerts":
          "/home/diogosilva/fabric-dev-servers/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/ca.crt"
      },
      "admin": {
        "key":
          "/home/diogosilva/fabric-dev-servers/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore",
        "cert":
          "/home/diogosilva/fabric-dev-servers/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts"
      }
    },
    "org2": {
      "name": "peerOrg2",
      "mspid": "Org2MSP",
      "peer1": {
        "requests": "grpcs://127.0.0.1:9051",
        "events": "grpcs://127.0.0.1:9053",
        "server-hostname": "peer0.org2.example.com",
        "tls_cacerts":
          "/home/diogosilva/fabric-dev-servers/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
      },
      "peer2": {
        "requests": "grpcs://127.0.0.1:10051",
        "events": "grpcs://127.0.0.1:10053",
        "server-hostname": "peer1.org2.example.com",
        "tls_cacerts":
          "/home/diogosilva/fabric-dev-servers/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/ca.crt"
      },
      "admin": {
        "key":
          "/home/diogosilva/fabric-dev-servers/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore",
        "cert":
          "/home/diogosilva/fabric-dev-servers/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts"
      }
    }
  },
  "channel": "mychannel",
  "orderers": [
    {
      "mspid": "OrdererMSP",
      "server-hostname": "orderer.example.com",
      "requests": "grpcs://127.0.0.1:7050",
      "tls_cacerts":
        "/home/diogosilva/fabric-dev-servers/fabric-samples/first-network/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt"
    }
  ],
  "keyValueStore": "/tmp/fabric-client-kvs",
  "configtxgenToolPath": "/home/diogosilva/fabric-dev-servers/fabric-samples/bin",
  "SYNC_START_DATE_FORMAT": "YYYY/MM/DD",
  "syncStartDate": "2018/01/01",
  "eventWaitTime": "30000",
  "license": "Apache-2.0",
  "version": "1.1"
}

Then when building Hyperledger Explorer, when running the command:

npm test -- -u --coverage

The last test throws the following error:

RUNS  src/components/View/LandingPage.spec.js
/home/diogosilva/blockchain-explorer/client/node_modules/react-scripts/scripts/test.js:20
  throw err;
  ^ 

TypeError: getBlockActivity is not a function
    at LandingPage.componentDidMount (/home/diogosilva/blockchain-explorer/client/src/components/View/LandingPage.js:136:5)
    at <anonymous>
npm ERR! Test failed.  See above for more details. 

Anybody know how to fix this ?

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Diogo Silva
  • 87
  • 1
  • 8
  • New version of hyperledger explorer is out now. Configuration structure is different now. Hope you wont have this error now. https://github.com/hyperledger/blockchain-explorer/releases/tag/v0.3.6 – abdul rashid Sep 13 '18 at 15:47

2 Answers2

4

I also faced the same issue, and was able to solve it as follows. I just needed to put one entry in my blockchain-explorer-0.3.7.1\client\src\components\View\LandingPage.spec.js file:

getBlockActivity:jest.fn(),

This line is missing in constant setup. I added this line and it works for me fine.

dbc
  • 104,963
  • 20
  • 228
  • 340
1

It might be config.json file error

In composer channel default composerchannel so you should change your channel name to composerchannel insted of mychannel and the communication protocol grpcs to grpc

I hope it will help you out ...

  • Hello Thrithin, why do you change channel to composerchannel and why the other ? I am trying to do it with this https://stackoverflow.com/questions/53129074/hyperledger-explorer-in-docker-compose-is-not-working-with-the-hyperledger-block – Phil Nov 03 '18 at 07:41
  • actually the hyperledger explorer there is config.json file by default it call the mychannel ,so in hyperledger the channel also matter but in composer the channel name is composerchannel. so channel name should be same , the thing you can do is either change the composer channel name to mychannel or change hyperledger explorer channel name to composerchannel ..... – Thrithin chand Nov 29 '18 at 05:24
  • while it is true that for blockchain-explorer to work with hyperledger composer business networks, and mychannel needs to be renamed, but the error posted by OP is resolved by @Prafull Rawal solution. I faced the same error *EVEN AFTER* changing config.json params. By making the changes suggested by Prafull Rawal, the 'npm test -- -u --coverage' ran successfully. – Bharat Mallapur Dec 01 '18 at 10:04
  • there is more you need to do with the database , getBlockActivity is not a function this error because of the database issue , you need to check the database table name .... and check the is there BlockActivity table is there or not .... and one more thing requests": "grpcs://127.0.0.1:7050 you just change grpcs to grpc because by default we are not using grpcs – Thrithin chand Dec 07 '18 at 04:59