{"action":"created","issue":{"url":"https://api.github.com/repos/hyperledger/fabric/issues/2342","repository_url":"https://api.github.com/repos/hyperledger/fabric","labels_url":"https://api.github.com/repos/hyperledger/fabric/issues/2342/labels{/name}","comments_url":"https://api.github.com/repos/hyperledger/fabric/issues/2342/comments","events_url":"https://api.github.com/repos/hyperledger/fabric/issues/2342/events","html_url":"https://github.com/hyperledger/fabric/issues/2342","id":168398505,"number":2342,"title":"hfc.getChain(<brand new name>, create=yes) fails with ReferenceError: name is not defined","user":{"login":"jjjjibm","id":17887475,"avatar_url":"https://avatars.githubusercontent.com/u/17887475?v=3","gravatar_id":"","url":"https://api.github.com/users/jjjjibm","html_url":"https://github.com/jjjjibm","followers_url":"https://api.github.com/users/jjjjibm/followers","following_url":"https://api.github.com/users/jjjjibm/following{/other_user}","gists_url":"https://api.github.com/users/jjjjibm/gists{/gist_id}","starred_url":"https://api.github.com/users/jjjjibm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjjjibm/subscriptions","organizations_url":"https://api.github.com/users/jjjjibm/orgs","repos_url":"https://api.github.com/users/jjjjibm/repos","events_url":"https://api.github.com/users/jjjjibm/events{/privacy}","received_events_url":"https://api.github.com/users/jjjjibm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-29T19:37:53Z","updated_at":"2016-08-22T23:27:48Z","closed_at":null,"body":"\r\n\r\nMy program calls hfc.getChain with a new chain name and the create flag.  \r\nGetChain calls hfc.newChain() because the chain has not been allocated yet. \r\n\r\nThe call fails like this: \r\n_setChainFields: calling getChain()    <--- message from my program_ \r\n\r\nThe rest is from node.js: \r\n/_opt/gopath/src/github.com/hyperledger/fabric/sdk/node/lib/hfc.js:2194\r\n        chain = newChain(name);\r\n                         ^\r\n**ReferenceError: name is not defined**\r\n    at Object.getChain (/opt/gopath/src/github.com/hyperledger/fabric/sdk/node/lib/hfc.js:2194:26)\r\n    at setChainFields (/opt/gopath/src/github.com/hyperledger/fabric/sdk/node/test/unit/registrar2.js:88:18)\r\n    at Test.<anonymous> (/opt/gopath/src/github.com/hyperledger/fabric/sdk/node/test/unit/registrar2.js:65:5)\r\n    at Test.bound [as _cb] (/opt/gopath/src/github.com/hyperledger/fabric/sdk/node/node_modules/tape/lib/test.js:63:32)\r\n    at Test.run (/opt/gopath/src/github.com/hyperledger/fabric/sdk/node/node_modules/tape/lib/test.js:82:10)\r\n    at Test.bound [as run] (/opt/gopath/src/github.com/hyperledger/fabric/sdk/node/node_modules/tape/lib/test.js:63:32)\r\n    at Immediate.next [as _onImmediate] (/opt/gopath/src/github.com/hyperledger/fabric/sdk/node/node_modules/tape/lib/results.js:70:15)\r\n    at processImmediate [as _immediateCallback] (timers.js:367:17)_\r\n\r\nLooking at the getChain function in hfc.ts\r\n\r\nexport function getChain(**chainName**, create) {\r\n    let chain = _chains[**chainName**];\r\n    if (!chain && create) {\r\n        chain = newChain(**name**);\r\n    }\r\n    return chain;\r\n}: \r\n\r\nwe notice getChain() takes the parameter chainName and looks up chainName, but when it creates a new chain, it passes a new variable, name.  Could it be newChain should have been called like this?\r\n   chain = newChain(chainName) \r\n\r\n## Describe How to Reproduce\r\nAdd this to register.js or to a similar program: \r\n **var  create = true; \r\n  var chain = hfc.getChain(\"testChain3\", create);**\r\n\r\nwhere \"testChain3\"  has not been allocated yet.  "},"comment":{"url":"https://api.github.com/repos/hyperledger/fabric/issues/comments/241582176","html_url":"https://github.com/hyperledger/fabric/issues/2342#issuecomment-241582176","issue_url":"https://api.github.com/repos/hyperledger/fabric/issues/2342","id":241582176,"user":{"login":"jjjjibm","id":17887475,"avatar_url":"https://avatars.githubusercontent.com/u/17887475?v=3","gravatar_id":"","url":"https://api.github.com/users/jjjjibm","html_url":"https://github.com/jjjjibm","followers_url":"https://api.github.com/users/jjjjibm/followers","following_url":"https://api.github.com/users/jjjjibm/following{/other_user}","gists_url":"https://api.github.com/users/jjjjibm/gists{/gist_id}","starred_url":"https://api.github.com/users/jjjjibm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjjjibm/subscriptions","organizations_url":"https://api.github.com/users/jjjjibm/orgs","repos_url":"https://api.github.com/users/jjjjibm/repos","events_url":"https://api.github.com/users/jjjjibm/events{/privacy}","received_events_url":"https://api.github.com/users/jjjjibm/received_events","type":"User","site_admin":false},"created_at":"2016-08-22T23:27:48Z","updated_at":"2016-08-22T23:27:48Z","body":"The Jira issue corresponding to this test is FAB-128"}}
{"actor":{"display_login":"jjjjibm"}}