forked from blockchain-desktop/hyperledger-fabric-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request blockchain-desktop#191 from dengyi9/master
Improve test config, blockchain-desktop#49 & add introduction video. blockchain-desktop#187
- Loading branch information
Showing
14 changed files
with
179 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"name":"Org1MSP","mspid":"Org1MSP","roles":null,"affiliation":"","enrollmentSecret":"","enrollment":{"signingIdentity":"cd96d5260ad4757551ed4a5a991e62130f8008a0bf996e4e4b84cd097a747fec","identity":{"certificate":"-----BEGIN CERTIFICATE-----\nMIICGDCCAb+gAwIBAgIQFSxnLAGsu04zrFkAEwzn6zAKBggqhkjOPQQDAjBzMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEcMBoGA1UEAxMTY2Eu\nb3JnMS5leGFtcGxlLmNvbTAeFw0xNzA4MzEwOTE0MzJaFw0yNzA4MjkwOTE0MzJa\nMFsxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T\nYW4gRnJhbmNpc2NvMR8wHQYDVQQDDBZBZG1pbkBvcmcxLmV4YW1wbGUuY29tMFkw\nEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEV1dfmKxsFKWo7o6DNBIaIVebCCPAM9C/\nsLBt4pJRre9pWE987DjXZoZ3glc4+DoPMtTmBRqbPVwYcUvpbYY8p6NNMEswDgYD\nVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwKwYDVR0jBCQwIoAgQjmqDc122u64\nugzacBhR0UUE0xqtGy3d26xqVzZeSXwwCgYIKoZIzj0EAwIDRwAwRAIgXMy26AEU\n/GUMPfCMs/nQjQME1ZxBHAYZtKEuRR361JsCIEg9BOZdIoioRivJC+ZUzvJUnkXu\no2HkWiuxLsibGxtE\n-----END CERTIFICATE-----\n"}}} |
5 changes: 5 additions & 0 deletions
5
...resources/key/users/cd96d5260ad4757551ed4a5a991e62130f8008a0bf996e4e4b84cd097a747fec-priv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgRgQr347ij6cjwX7m | ||
KjzbbD8Tlwdfu6FaubjWJWLGyqahRANCAARXV1+YrGwUpajujoM0EhohV5sII8Az | ||
0L+wsG3iklGt72lYT3zsONdmhneCVzj4Og8y1OYFGps9XBhxS+lthjyn | ||
-----END PRIVATE KEY----- |
4 changes: 4 additions & 0 deletions
4
.../resources/key/users/cd96d5260ad4757551ed4a5a991e62130f8008a0bf996e4e4b84cd097a747fec-pub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-----BEGIN PUBLIC KEY----- | ||
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEV1dfmKxsFKWo7o6DNBIaIVebCCPA | ||
M9C/sLBt4pJRre9pWE987DjXZoZ3glc4+DoPMtTmBRqbPVwYcUvpbYY8pw== | ||
-----END PUBLIC KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file !.gitkeep |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"id":0,"isSign":1,"_id":"0RYjfGm5ZQNGBcxV","peerGrpcUrl":"grpc://localhost:7051","peerEventUrl":"grpc://localhost:7053","ordererUrl":"grpc://localhost:7050","mspid":"Org1MSP","tlsPeerPath":"","tlsOrdererPath":"","path":"test/resources/key/users/"} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
// Copyright 2019 The hyperledger-fabric-desktop Authors. All rights reserved. | ||
import { getFabricClientSingletonHelper } from '../../src/util/fabric'; | ||
|
||
const { execSync } = require('child_process'); | ||
const logger = require('electron-log'); | ||
const Datastore = require('nedb'); | ||
const path = require('path'); | ||
|
||
// Steps | ||
// 1. start fabric network | ||
// 2. call client functions | ||
// 3. stop fabric network, clean up | ||
|
||
function initFabricNetwork() { | ||
logger.info('Shuting down old Fabric Network.'); | ||
let buf = execSync('cd fabric/v1.1/basic-network && ./teardown.sh'); | ||
logger.debug(buf.toString()); | ||
|
||
logger.info('Initiating Fabric Network.'); | ||
buf = execSync('cd fabric/v1.1/fabcar && ./startFabric.sh'); | ||
logger.debug(buf.toString()); | ||
} | ||
|
||
function clearFabricNetwork() { | ||
// FIXME: 关闭网络需处理异步问题。 直接关闭会导致异步测试未结束,而网络被关闭。 | ||
// 当前解决方案,在initFabricNetwork()中关闭网络 | ||
|
||
// logger.info('clearing Fabric Network.'); | ||
// const buf = execSync('cd fabric/v1.1/basic-network && ./teardown.sh'); | ||
// logger.debug(buf.toString()); | ||
} | ||
|
||
beforeAll(() => { | ||
jest.setTimeout(10000); | ||
initFabricNetwork(); | ||
}); | ||
|
||
afterAll(clearFabricNetwork); | ||
|
||
// 注意, config.db文件中的"path"字段,对应fabric-node-sdk的用户私钥仓库路径,需根据测试环境配置, | ||
// 目前只处理fabric v1.1-basic-network的例子,处理fabric v1.3需同时考虑sdk版本升级,以及启动脚本的调整等 | ||
const configDbForTest = new Datastore({ | ||
filename: path.join(__dirname, '../resources/persistence/config.db'), | ||
autoload: true, | ||
}); | ||
|
||
describe('Fabric Client Basic', () => { | ||
it('instantiate client.', () => | ||
getFabricClientSingletonHelper(configDbForTest) | ||
.then((client) => { | ||
expect(client) | ||
.not | ||
.toBeNull(); | ||
})); | ||
|
||
it('query chaincode', () => { | ||
const clientPromise = getFabricClientSingletonHelper(configDbForTest); | ||
return clientPromise.then((client) => { | ||
logger.info('OK. Got client. client.channel: ', client.channels); | ||
client.queryCc('fabcar', 'queryAllCars', null, 'mychannel') | ||
.then((result) => { | ||
logger.info('query result: ', result); | ||
expect(result) | ||
.not | ||
.toBeNull(); | ||
}) | ||
.catch((err) => { | ||
logger.error(err); | ||
throw new Error(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Fabric Client Advanced', () => { | ||
describe('invoke chaincode', () => { | ||
it('invoke for one peer', () => getFabricClientSingletonHelper(configDbForTest) | ||
.then(client => client.invokeCc('fabcar', | ||
'changeCarOwner', | ||
['CAR0', 'newPerson'], | ||
'mychannel', | ||
[], | ||
[], | ||
[]) | ||
.then((result) => { | ||
logger.info('invoke result: ', result); | ||
expect(result) | ||
.not | ||
.toBeNull(); | ||
return Promise.resolve(); | ||
})) | ||
.catch((err) => { | ||
logger.info('catch invoke reject'); | ||
logger.info(err); | ||
throw err; | ||
})); | ||
|
||
it('invoke for multiple peers', () => { | ||
// TODO: to be implemented | ||
}); | ||
}); | ||
|
||
it('install chaincode', () => { | ||
|
||
}); | ||
|
||
it('instantiate chaincode', () => { | ||
|
||
}); | ||
|
||
it('upgrade chaincode', () => { | ||
|
||
}); | ||
|
||
it('query block info', () => { | ||
|
||
}); | ||
|
||
it('create channel', () => { | ||
|
||
}); | ||
|
||
it('join peer to channel', () => { | ||
|
||
}); | ||
}); | ||
|