nodejs测试hyperledger composer v0.15失败,并显示错误:找不到卡:PeerAdmin @ hlfv1 [英] nodejs test hyperledger composer v0.15 fails with Error: Card not found: PeerAdmin@hlfv1

查看:82
本文介绍了nodejs测试hyperledger composer v0.15失败,并显示错误:找不到卡:PeerAdmin @ hlfv1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着v0.15中卡的实现,使用概要文件的测试例程的先前版本(显然)将无法工作.但是,我找不到一种SDK方法来创建运行测试所需的卡.通过v0.14进行测试的代码的之前"部分如下所示,该代码使用嵌入式配置文件,创建网络的临时实例并运行测试:

With the implementation of cards in v0.15, previous versions of test routines which used profiles (obviously) won't work. However, I cannot find an SDK approach to create the necessary cards to run tests. The 'before' section of code up through v0.14 for my tests has looked like the following, which uses an embedded profile, creates a temporary instance of the network and runs the tests:

describe('Finance Network', () => {

    // let adminConnection;
    let businessNetworkConnection;

    before(() => {
        BrowserFS.initialize(new BrowserFS.FileSystem.InMemory());
        const adminConnection = new AdminConnection({ fs: bfs_fs });
        return adminConnection.createProfile('defaultProfile', {
            type: 'embedded'
        })
            .then(() => {
                return adminConnection.connect('defaultProfile', adminID, adminPW);
            })
            .then(() => {
                return BusinessNetworkDefinition.fromDirectory(path.resolve(__dirname, '..'));
            })
            .then((businessNetworkDefinition) => {
                return adminConnection.deploy(businessNetworkDefinition);
            })
            .then(() => {
                businessNetworkConnection = new BusinessNetworkConnection({ fs: bfs_fs });
                return businessNetworkConnection.connect('defaultProfile', network, adminID, adminPW);
            });
    });

在nodejs文档中,我试图找到(但尚未发现)的是如何在使用相同方法的同时创建必要的卡来完成这项工作.

What I'm trying to find (and haven't yet) in the nodejs documentation is how to create the necessary cards to make this work, while using this same approach.

我希望将以下代码行替换为可创建所需卡片的内容:

I expect to replace the following lines of code with something that creates the necessary cards:

        return adminConnection.createProfile('defaultProfile', {
            type: 'embedded'
        })
            .then(() => {
                return adminConnection.connect('defaultProfile', adminID, adminPW);
            })

我看到卡创建的唯一位置是composer-client Participant Registry,但是在Catch-22的情况下,必须连接才能创建卡,但是需要连接卡.像我们过去对Hyperledger-Composer的众多发行版所做的那样,建议编写基于摩卡的测试的推荐方法是什么?

The only place where I see card creation is in composer-client Participant Registry, but it's a Catch-22 situation where I have to be connected to create the card, but I need a card to get connected. What is the recommended approach for writing mocha-based testing as we have been doing for the past umpteen releases of Hyperledger-Composer?

谢谢!

推荐答案

经过几天的试验,我找到了解决此问题的方法.以下代码序列使用在v0.15版本中创建的PeerAdmin卡.我导入该卡,并在adminConnect之后,更新卡的元数据中的businessNetwork元素,然后在重新导入卡后,部署并连接到业务网络.

After a couple of days of experimenting, I've found a way to solve this problem. The following code sequence uses the PeerAdmin card created as part of the v0.15 release. I import that card and, after adminConnect, update the businessNetwork element in the card's metadata and then, after re-importing the card, deploy and connect to the business network.

describe('Finance Network', function () {
    this.timeout(_timeout);
    let businessNetworkConnection;
    let peerName = 'PeerAdmin@hlfv1';
    before(function () {
        const adminConnection = new AdminConnection();
        let idPeer;
        return hlc_idCard.fromDirectory(_home+'/.composer/cards/'+peerName)
        .then ((_idPeer) => {
            idPeer = _idPeer;
            return adminConnection.importCard(peerName, idPeer);
        })
        .then(() => {
            return adminConnection.connect(peerName);
        })
        .then(() => {
            return BusinessNetworkDefinition.fromDirectory(path.resolve(__dirname, '..'));
        })
        .then((businessNetworkDefinition) => {
            idPeer.metadata.businessNetwork = network;
            return adminConnection.importCard(peerName, idPeer)
            .then(() => {
                return adminConnection.deploy(businessNetworkDefinition,{'card': idPeer});
            });
        })
        .then(() => {
            businessNetworkConnection = new BusinessNetworkConnection();
            return businessNetworkConnection.connect(peerName);
        });
    });

这篇关于nodejs测试hyperledger composer v0.15失败,并显示错误:找不到卡:PeerAdmin @ hlfv1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆