Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm test error #42

Open
mmourani opened this issue Mar 14, 2019 · 7 comments
Open

npm test error #42

mmourani opened this issue Mar 14, 2019 · 7 comments

Comments

@mmourani
Copy link

hi, I get the bellow error when running npm test - unable to create the channel common

[2019-03-14T17:36:05.099] [TRACE] FabricStarterClientTest - logged in with password
✓ registers with random username and password then logs in without password (611ms)
Create-Join channel
#createChannelCommon
[2019-03-14T17:36:05.259] [INFO] FabricStarterClient - common
/bin/sh: /usr/bin/wget: No such file or directory
exec: /bin/sh: /usr/bin/wget: No such file or directory

/bin/sh: /usr/bin/wget: No such file or directory
exec: /bin/sh: /usr/bin/wget: No such file or directory

/bin/sh: /usr/bin/wget: No such file or directory
exec: /bin/sh: /usr/bin/wget: No such file or directory

    1) create channel "Common"
@popov-vladimir
Copy link
Collaborator

@mmourani , the test suite as well as the project itself are supposed to be run inside of a container, which is a part of the fabric deployment suite ( see https://github.com/olegabu/fabric-starter).
As you can see there is a Dockerfile in the project folder, so you can build it yourself. The obvious reason is that you need certain tools ( e.g. wget, fabric sdk ) in certain places to make all the services work.
Alternatively you can clone fabric-starter project , tweak it a little bit, i.e. map your fabric-starter-rest project folder to api container like this:
- path_to_fabric-starter-rest_folder:/fabric-starter-rest
start a network with a single organization via simple command like ./network-create-local.sh org1
And then do something like

docker exec -it  api.org1.example.com sh -c "cd /fabric-starter-rest && npm run test"

@mmourani
Copy link
Author

@dundro ah ok thank you very much for the quick reply and for the details above. I actually copied fabric-starter and fabric-starter-rest and I was modifying the code to suit my needs. what I am doing now is testing the code to see how I can effectively use this as a development environment and testing having the following configuration:
1 - run ./generate-orderer.sh
2 - docker-compose -f docker-compose-orderer.yaml -f orderer-ports.yaml up
3 - ./generate-peer.sh
4 - docker-compose -f docker-compose.yaml -f docker-compose-dev.yaml up
this way I can see all of the logs going through both the orderer and the peer
Then i change my /etc/hosts to map the various elements of the system so i get redirected to the various services in place
something like
127.0.0.1 ca.org1.example.com
127.0.0.1 peer0.org1.example.com
127.0.0.1 api.org1.example.com
127.0.0.1 www.example.com
127.0.0.1 orderer.example.com
127.0.0.1 www.org1.example.com

and then I go to fabric-starter-rest and start testing the network and how every command react on the fabric.

1 - so then I run npm run test
2 - I can also run npm start

then I need to check as well the swagger API but I was not able to see how you have published it and where it is located. I will then use something like postman to send request to the REST API and verify what end points are available.

what do you think ? so you have any other ideas for a dev environment building chaincode on javascript ?

@popov-vladimir
Copy link
Collaborator

@mmourani , fabric-starter-rest is already baked in the fabric-starter environment, you can see it running as "api.org1.example.com" container. So you don't need to download the fabric-starter-rest source code or to run it explicitly for chaincode development purposes. All of the services including Swagger are already available, just check it out at http://localhost:4000/api-docs (be sure that api.org1.example.com exposes the right port like this : 0.0.0.0:4000->3000/tcp )

@mmourani
Copy link
Author

@dundro thank for the clarification. I was able to see the API at http://localhost:4000/api-docs#/. I could see swagger for the following: config, chaincode, users, channels, orgs. Is it possible to see as well the participants, assets, queries, etc ?

@popov-vladimir
Copy link
Collaborator

@mmourani, you can access the ledger data (assets) through chaincode query or chaincode invocation .
Alternatively, you can query the state directly with a database query, if you are using CouchDB (you have to expose corresponding ports to use it's REST service facade).
Query consortium members to see a list of trusted network participants ( it returns the same MSP Id, that you can use to query peers, add organization to channel etc)
I'm not sure what you mean by "queries". Can you elaborate?

@mmourani
Copy link
Author

hello @dundro and thank you for taking the time to explain the system structure. to be more explicit here, I was mainly working on hyperledger composer building the DB structure with the classes and relationships, then adding assets and transactions, queries and ACL. I was then using yeoman hyperledger generator for the webapp and composer-rest-server for the API. The ideal situation would be for me to stay on the same course so I do rapid development but it seems that composer will no longer be supported and I need an alternative. So basically I am trying to understand how to do the same thing I was doing but using your templates and configuration. it is still not clear to me how to write the chaincode ( I can install and instantiate with no issues) but how do I create the DB structure and then make it available on the REST API for someone to use the end points from the Web and Mobile phone apps ? for example I will create participants (users, banks, suppliers, etc), assets (coins, cars, etc) and transactions (CRUD on participants for example) and access them through the APIs and make them visible like the ones you have now.I hope it is clear what I am trying to do. Or should I change all the scripts and try to make composer working so I can develop the chaincode and test like I use to do ? and how do I make composer working here if needed ?

@popov-vladimir
Copy link
Collaborator

how to write the chaincode ( I can install and instantiate with no issues) but how do I create the DB structure and then make it available on the REST API for someone to use the end points from the Web and Mobile phone apps ?

It is not necessary to explicitly configure DB structure, you can just write and deploy chaincode, that puts and gets State. For example, using javascript
You can also see reference chaincode implementation (chaincode/node/reference/chaincode-reference.js) for storing and retrieving of arbitrary data - don't forget to download packages :cd chaincode/node/reference && npm install

You already can use chaincode functionality with Fabric SDK for Go, Node, Java or use the so called API Node , included in the project - it exposes lots of usefull REST services including a way to invoke a chaincode adn state querying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants