Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
path = packages/composer-runtime-hlf/vendor/github.com/hyperledger/fabric
url = https://github.com/hyperledger/fabric.git
branch = v0.6
[submodule "packages/composer-runtime-hlf/vendor/gopkg.in/sourcemap.v1"]
path = packages/composer-runtime-hlf/vendor/gopkg.in/sourcemap.v1
url = https://gopkg.in/sourcemap.v1.git
[submodule "packages/composer-runtime-hlf/vendor/github.com/robertkrimen/otto"]
path = packages/composer-runtime-hlf/vendor/github.com/robertkrimen/otto
url = https://github.com/robertkrimen/otto.git
[submodule "packages/composer-runtime-hlfv1/vendor/gopkg.in/olebedev/go-duktape.v3"]
path = packages/composer-runtime-hlfv1/vendor/gopkg.in/olebedev/go-duktape.v3
url = https://gopkg.in/olebedev/go-duktape.v3.git
[submodule "packages/composer-runtime-hlf/vendor/gopkg.in/olebedev/go-duktape.v3"]
path = packages/composer-runtime-hlf/vendor/gopkg.in/olebedev/go-duktape.v3
url = https://gopkg.in/olebedev/go-duktape.v3.git
22 changes: 6 additions & 16 deletions .travis/before-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,16 @@ npm install -g @alrra/travis-scripts
echo "ABORT_BUILD=false" > ${DIR}/build.cfg
echo "ABORT_CODE=0" >> ${DIR}/build.cfg

if [ "${SYSTEST}" = "hlf" ] && [ "${SYSTEST_HLF}" = "ibm" ]; then

if [ "${TRAVIS_EVENT_TYPE}" = "cron" ]; then
echo Valid to run hlf with ibm systest as CRON build
else
echo "ABORT_BUILD=true" > ${DIR}/build.cfg
echo "ABORT_CODE=0" >> ${DIR}/build.cfg
echo Not running as a PR or merge build
exit 0
fi
fi

# Abort the systest if this is a merge build
# Check for the FC_TASK that is set in travis.yml, also the pull request is false => merge build
# and that the TRAVIS_TAG is empty meaning this is not a release build
if [ "${FC_TASK}" = "systest" ] && [ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ -z "${TRAVIS_TAG}" ]; then
echo "ABORT_BUILD=true" > ${DIR}/build.cfg
echo "ABORT_CODE=0" >> ${DIR}/build.cfg
echo Merge build from non release PR: ergo not running systest
exit 0
if [[ "${TRAVIS_REPO_SLUG}" = hyperledger* ]]; then
echo "ABORT_BUILD=true" > ${DIR}/build.cfg
echo "ABORT_CODE=0" >> ${DIR}/build.cfg
echo Merge build from non release PR: ergo not running systest
exit 0
fi
fi

#
Expand Down
4 changes: 0 additions & 4 deletions packages/composer-connector-hlfv1/lib/hlfconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,7 @@ class HLFConnection extends Connection {
let ccid = HLFConnection.generateCcid(this.businessNetworkIdentifier);
LOG.debug(method, 'registerChaincodeEvent', ccid, 'composer');
let ccEvent = this.eventHubs[0].registerChaincodeEvent(ccid, 'composer', (event) => {
//let evt = Buffer.from(event.payload, 'hex').toString('utf8');
// Remove the first set of "" around the event so it can be parsed first time
let evt = event.payload.toString('utf8');
evt = evt.replace(/^"(.*)"$/, '$1'); // Remove end quotes
evt = evt.replace(/\\/g, '');
evt = JSON.parse(evt);
this.emit('events', evt);
});
Expand Down
3 changes: 2 additions & 1 deletion packages/composer-connector-hlfv1/test/hlfconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ describe('HLFConnection', () => {
const events = {
payload: {
toString: () => {
return '"{"event":"event"}"';
return '{"event":"event"}';
}
}
};
Expand All @@ -207,6 +207,7 @@ describe('HLFConnection', () => {
sinon.assert.calledOnce(mockEventHub.registerChaincodeEvent);
sinon.assert.calledWith(mockEventHub.registerChaincodeEvent, 'org-acme-biznet', 'composer', sinon.match.func);
sinon.assert.calledOnce(connection.emit);
sinon.assert.calledWith(connection.emit, 'events', {'event':'event'});
});

it('should not register any listeners for chaincode events if no business network is specified', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class EmbeddedEventService extends EventService {
transactionCommit() {
return super.transactionCommit()
.then(() => {
const jsonEvent = JSON.parse(this.serializeBuffer());
const jsonEvent = this.getEvents();
this.eventSink.emit('events', jsonEvent);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,12 @@ class EmbeddedQueryService extends QueryService {

/**
* Query the underlying world-state store using a store native query string.
* @abstract
* @param {string} queryString - the native query string
* @return {Promise} A promise that will be resolved with a JS object containing the results of the query
*/
queryNative(queryString) {
const method = 'queryNative';
LOG.entry(method, queryString);
this.queryString = queryString;
LOG.debug(method, queryString);
// TODO (DCS) - we need an implementation!
return Promise.resolve({data: 'not implemented'});
throw new Error('The native query functionality is not available on this Blockchain platform');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ describe('EmbeddedEventService', () => {

describe('#transactionCommit', () => {
it ('should emit a list of events', () => {
sinon.stub(eventService, 'serializeBuffer').returns('[{"event":"event"}]');
sinon.stub(eventService, 'getEvents').returns([{'event':'event'}]);
return eventService.transactionCommit()
.then(() => {
sinon.assert.calledOnce(eventService.serializeBuffer);
sinon.assert.calledOnce(eventService.getEvents);
sinon.assert.calledOnce(mockEventEmitter.emit);
sinon.assert.calledWith(mockEventEmitter.emit, 'events', [{'event':'event'}]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ describe('EmbeddedQueryService', () => {


describe('#queryNative', () => {
it ('should return the query string', () => {
return queryService.queryNative('dummyString')
.then((result) => {
result.should.deep.equal({data: 'not implemented'});
});
it ('should throw as not supported on this runtime', () => {
(() => {
queryService.queryNative('dummyString');
}).should.throw(/not available on this Blockchain platform/);
});
});
});
10 changes: 5 additions & 5 deletions packages/composer-runtime-hlf/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ out
*.swp

# Build generated files should be ignored by git, but not by npm.
concerto
concerto.js.go
concerto.js
concerto.js.map
concerto.min.js
composer
composer.js.go
composer.js
composer.js.map
composer.min.js
10 changes: 5 additions & 5 deletions packages/composer-runtime-hlf/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ out
*.swp

# Build generated files should be ignored by git, but not by npm.
concerto
# concerto.js.go
concerto.js
concerto.js.map
concerto.min.js
composer
# composer.js.go
composer.js
composer.js.map
composer.min.js
28 changes: 14 additions & 14 deletions packages/composer-runtime-hlf/chaincode.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import "github.com/hyperledger/fabric/core/chaincode/shim"
// Chaincode is the chaincode class. It is an implementation of the
// Chaincode interface.
type Chaincode struct {
ConcertoPool *ConcertoPool
ComposerPool *ComposerPool
}

// NewChaincode creates a new instance of the Chaincode chaincode class.
Expand All @@ -28,39 +28,39 @@ func NewChaincode() (result *Chaincode) {
defer func() { logger.Debug("Exiting NewChaincode", result) }()

return &Chaincode{
ConcertoPool: NewConcertoPool(8),
ComposerPool: NewComposerPool(8),
}
}

// Init is called by the Hyperledger Fabric when the chaincode is deployed.
// Init can read from and write to the world state.
func (chaincode *Chaincode) Init(stub shim.ChaincodeStubInterface, function string, arguments []string) (result []byte, err error) {
logger.Debug("Entering Chaincode.Init", stub, function, arguments)
logger.Debug("Entering Chaincode.Init", &stub, function, arguments)
defer func() { logger.Debug("Exiting Chaincode.Init", string(result), err) }()

concerto := chaincode.ConcertoPool.Get()
defer chaincode.ConcertoPool.Put(concerto)
return concerto.Init(stub, function, arguments)
composer := chaincode.ComposerPool.Get()
defer chaincode.ComposerPool.Put(composer)
return composer.Init(stub, function, arguments)
}

// Invoke is called by the Hyperledger Fabric when the chaincode is invoked.
// Invoke can read from and write to the world state.
func (chaincode *Chaincode) Invoke(stub shim.ChaincodeStubInterface, function string, arguments []string) (result []byte, err error) {
logger.Debug("Entering Chaincode.Invoke", stub, function, arguments)
logger.Debug("Entering Chaincode.Invoke", &stub, function, arguments)
defer func() { logger.Debug("Exiting Chaincode.Invoke", string(result), err) }()

concerto := chaincode.ConcertoPool.Get()
defer chaincode.ConcertoPool.Put(concerto)
return concerto.Invoke(stub, function, arguments)
composer := chaincode.ComposerPool.Get()
defer chaincode.ComposerPool.Put(composer)
return composer.Invoke(stub, function, arguments)
}

// Query is called by the Hyperledger Fabric when the chaincode is queried.
// Query can read from, but not write to the world state.
func (chaincode *Chaincode) Query(stub shim.ChaincodeStubInterface, function string, arguments []string) (result []byte, err error) {
logger.Debug("Entering Chaincode.Query", stub, function, arguments)
logger.Debug("Entering Chaincode.Query", &stub, function, arguments)
defer func() { logger.Debug("Exiting Chaincode.Query", string(result), err) }()

concerto := chaincode.ConcertoPool.Get()
defer chaincode.ConcertoPool.Put(concerto)
return concerto.Query(stub, function, arguments)
composer := chaincode.ComposerPool.Get()
defer chaincode.ComposerPool.Put(composer)
return composer.Query(stub, function, arguments)
}
15 changes: 0 additions & 15 deletions packages/composer-runtime-hlf/chaincode_test.go

This file was deleted.

Loading