Node.js 如何使用ChainCodeMockStub测试nodejs链代码

Node.js 如何使用ChainCodeMockStub测试nodejs链代码,node.js,testing,hyperledger-fabric,Node.js,Testing,Hyperledger Fabric,我正在尝试测试nodejs链码,而不将其部署到hyperledger fabic网络。有一个流行的nodejs库,名为@theledger/fabric mock stub。下面是我的单元测试 const Chaincode = require('./index.js'); // import { ChaincodeMockStub, Transform } from "@theledger/fabric-mock-stub"; const ChaincodeMockStub = require

我正在尝试测试nodejs链码,而不将其部署到hyperledger fabic网络。有一个流行的nodejs库,名为@theledger/fabric mock stub。下面是我的单元测试

const Chaincode = require('./index.js');
// import { ChaincodeMockStub, Transform } from "@theledger/fabric-mock-stub";
const ChaincodeMockStub = require("@theledger/fabric-mock-stub")
// You always need your chaincode so it knows which chaincode to invoke on
const chaincode = new Chaincode();
describe('Test MyChaincode', () => {
    it("Should init without issues", async () => {
        const mockStub = new ChaincodeMockStub("MyMockStub", chaincode);
        const response = await mockStub.mockInit("tx1", []);
        expect(response.status).to.eql(200)
    });
});

运行此测试时,收到以下错误
2019-04-08T18:34:55.530Z错误[lib/chaincode.js]未捕获异常:缺少必需的参数peer.address

有人知道如何使用这个测试库吗


非常感谢您的帮助。

我也遇到了同样的问题,我注意到在我的链码js文件的底部有一个问题

shim.start(新链码())

如果您在进行测试之前将这一行移动到另一个文件或注释掉它,测试应该可以正常工作