2

我正在 Ubuntu 虚拟机版本 16.04 中配置 Hyperledger Explorer,以与基于此链接的 Hyperledger Composer 集成:https ://github.com/hyperledger/blockchain-explorer/blob/master/README.md

我已经按照 github 链接执行了所有配置步骤,包括数据库设置,并修改了 config.json 文件以使用 Hyperledger Fabric 示例的 first-network 的结构,如下所示:

  {
  "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"
}

然后在构建 Hyperledger Explorer 时,运行命令时:

npm test -- -u --coverage

最后一个测试抛出以下错误:

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. 

有人知道如何解决这个问题吗?

4

2 回答 2

4

我也遇到了同样的问题,并且能够解决如下。我只需要在我的blockchain-explorer-0.3.7.1\client\src\components\View\LandingPage.spec.js文件中添加一个条目:

getBlockActivity:jest.fn(),

常量设置中缺少此行。我添加了这一行,它对我来说很好。

于 2018-10-10T14:00:23.133 回答
1

可能是 config.json 文件错误

在作曲家频道默认作曲家频道中,因此您应该将频道名称更改为 mychannel 的 composerchannel 并将通信协议 grpcs 更改为 grpc

我希望它会帮助你...

于 2018-09-26T10:31:44.297 回答