mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-20 08:35:09 +00:00
Change-Id: I235cb62df492b7713bb1c355b7457f679903bd34 Signed-off-by: Anthony O'Dowd <a_o-dowd@uk.ibm.com>
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
/*
|
|
SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
'use strict';
|
|
|
|
const Chaincode = require('../lib/chaincode');
|
|
const { Stub } = require('fabric-shim');
|
|
|
|
require('chai').should();
|
|
const sinon = require('sinon');
|
|
|
|
describe('Chaincode', () => {
|
|
|
|
describe('#Init', () => {
|
|
|
|
it('should work', async () => {
|
|
const cc = new Chaincode();
|
|
const stub = sinon.createStubInstance(Stub);
|
|
stub.getFunctionAndParameters.returns({ fcn: 'initFunc', params: [] });
|
|
const res = await cc.Init(stub);
|
|
res.status.should.equal(Stub.RESPONSE_CODE.OK);
|
|
});
|
|
|
|
});
|
|
|
|
describe('#Invoke', async () => {
|
|
|
|
it('should work', async () => {
|
|
const cc = new Chaincode();
|
|
const stub = sinon.createStubInstance(Stub);
|
|
stub.getFunctionAndParameters.returns({ fcn: 'initFunc', params: [] });
|
|
let res = await cc.Init(stub);
|
|
res.status.should.equal(Stub.RESPONSE_CODE.OK);
|
|
stub.getFunctionAndParameters.returns({ fcn: 'invokeFunc', params: [] });
|
|
res = await cc.Invoke(stub);
|
|
res.status.should.equal(Stub.RESPONSE_CODE.OK);
|
|
});
|
|
|
|
});
|
|
|
|
});
|