{"id":2739,"date":"2018-12-17T23:57:13","date_gmt":"2018-12-17T18:27:13","guid":{"rendered":"http:\/\/navveenbalani.dev\/?p=2739"},"modified":"2019-12-18T16:13:59","modified_gmt":"2019-12-18T10:43:59","slug":"end-to-end-test-execution-of-trade-finance-application","status":"publish","type":"post","link":"https:\/\/navveenbalani.dev\/index.php\/articles\/end-to-end-test-execution-of-trade-finance-application\/","title":{"rendered":"End-to-End Test Execution of Trade Finance application"},"content":{"rendered":"\n<p>In this section, we will execute the entire network setup and business\nworkflow using a single script representing our test cases. <\/p>\n\n\n\n<p>You can download the source code of the book from GitHub location \u2013\nhttps:\/\/github.com\/enterprise-blockchain-book\/first-edition.git, if you haven\u2019t\ndownloaded it yet.<\/p>\n\n\n\n<p>Go to hyperledger-fabric folder. The following shows the structure of\nthe hyperledger-fabric folder<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" src=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-63.png\" alt=\"\" class=\"wp-image-2740\" width=\"400\" height=\"180\"\/><figcaption><br><\/figcaption><\/figure>\n\n\n\n<ul><li>The docker file&nbsp;\n&#8211; docker-trade-finance.yaml, discussed earlier that sets up the trade\nfinance blockchain network, resides in the root folder. <\/li><li>The chaincode folder contains our trade finance\nchaincode &#8211; tradefinancecontract.go.<\/li><li>The crypto-config.yaml, explained in Defining\nNetwork Topology section earlier, is used for generating cryptographic\nartifacts for our entire network.<\/li><li>The script folder contains the script file\nscript.sh, which runs the end-to-end trade finance application. The script is\nbootstrapped in docker-trade-finance.yaml and executed upon the network\nstartup.<\/li><li>The tradee2e.sh script is the entry point to the\napplication, which has commands to generate certificates and execute the\nend-to-end trade application using docker runtime.<\/li><\/ul>\n\n\n\n<p>To start with, change directory to hyperledger-fabric and download the\nIBM Hyperledger platform specific binaries by using the following command<\/p>\n\n\n\n<p>curl -SSL https:\/\/goo.gl\/QM1M4b | bash<\/p>\n\n\n\n<p>You would see a bin folder created, which contains platform-specific\nbinaries, namely cryptogen and configtxgen which are used for generating\ncertificates and channel artifacts respectively<\/p>\n\n\n\n<p>Let\u2019s generate the certificates and channel artifacts for our\nblockchain network using the following command. <\/p>\n\n\n\n<p>.\/tradee2e.sh -m generate<\/p>\n\n\n\n<p>The generate option calls the cryptogen for generating certificates\nand configtxgen for channel artifacts based on our configuration file.&nbsp; We had explained the command and\nconfiguration earlier in Application Deployment section.<\/p>\n\n\n\n<p>You should see the following output.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" src=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-64.png\" alt=\"\" class=\"wp-image-2741\" width=\"450\" height=\"133\"\/><figcaption><br><br><\/figcaption><\/figure>\n\n\n\n<p>This would generate the crypto artifacts in the crypto-config folder\nand channel artifacts in the channel-artifacts folder.<\/p>\n\n\n\n<p>If you inspect the crypto-config folder, you would see &#8220;ordererOrganizations&#8221; and &#8220;peerOrganizations&#8221; folder. If you navigate to the peerOrganizations-&gt; bnk.com and drill down to respective folders, you would see the following structure as shown below.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" src=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-65.png\" alt=\"\" class=\"wp-image-2742\" width=\"450\" height=\"200\"\/><\/figure>\n\n\n\n<p>The msp folder contains cryptographic credentials for <a href=\"mailto:User1@bnk.com\">User1@bnk.com<\/a>. The keystore folder contains the\nUser1 private key and signcerts contains the public key certificate for\nverification. We pass this msp path of <a href=\"mailto:User1@bnk.com\">User1@bnk.com<\/a>\nin our script file (script.sh) to invoke functions on behalf of this user and\nartifacts under this path are used for identification and verification.\nSimilarly, for all peers and users, we have a similar configuration and are\nbeing referenced in the script.sh file.&nbsp; <\/p>\n\n\n\n<p>Next, we would execute the application by running the following\nscript:<\/p>\n\n\n\n<p>.\/trade2e.sh -m up<\/p>\n\n\n\n<p>As discussed earlier, this would set up\nthe network using docker files and execute the script.sh file. The following\nshows the output of running the script<\/p>\n\n\n\n<ul><li>First, you would see channel -\u201ctradechannel,\u201d  being created as shown in the figure below.<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" src=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-66.png\" alt=\"\" class=\"wp-image-2743\" width=\"450\" height=\"250\"\/><\/figure><\/div>\n\n\n\n<ul><li>Next, all peers would join the channel one by one. The following shows peer 0 joining the network.  Similar messages would be displayed for peer 1, peer 2, peer 3, peer 4 and   peer 5.<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" src=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-67.png\" alt=\"\" class=\"wp-image-2745\" width=\"450\" height=\"200\"\/><\/figure><\/div>\n\n\n\n<ul><li> Next, the chain code would be deployed on all peers. You would see a message \u2013 \u201cChaincode is installed on remote peer.\u201d  <\/li><li>Next, the chain code would be      instantiated on peer 1. You should see a message \u2013 \u201cChaincode Instantiation      on PEER 1 on channel &#8216;tradechannel&#8217; is successful.\u201d<\/li><li>Next, we would query the initial  state after instantiation on different peers, say peer 2, which shows that chaincode is instantiated on all other peers as well.<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" src=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-68.png\" alt=\"\" class=\"wp-image-2748\" width=\"450\" height=\"250\"\/><\/figure><\/div>\n\n\n\n<ul><li>Next, we would execute the <em>createLOC<\/em> command using importer      bank user (i.e., User1@bnk.com). Following shows the output of invocation.  A successful message stating \u2013\u201c Invoke:createLOC transaction on PEER PEER2  on channel &#8216;tradechannel&#8217; is successful.\u201d should be printed.<\/li><li>Next, we execute the <em>approveLOC<\/em> method using <a href=\"mailto:User2@bnk.com\">User2@bnk.com<\/a> (exporter bank), <em>initiateShipment<\/em> method using <a href=\"mailto:User2@app.fte.com\">User2@app.fte.com<\/a> (Seller) , <em>deliverGoods<\/em> method using <a href=\"mailto:User1@shp.com\">User1@shp.com<\/a> (Shipment      Org user) and <em>shipmentDelivered<\/em>  method using <a href=\"mailto:User1@app.fte.com\">User1@app.fte.com<\/a>      (Buyer). After every method invocation, we      query the ledger to verify the trade status,<\/li><li>At the final step, we query the  status of the trade, which shows the expected output as \u2018Trade completed\u201d  as shown below.<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" src=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-69.png\" alt=\"\" class=\"wp-image-2749\" width=\"450\" height=\"150\"\/><\/figure><\/div>\n\n\n\n<p>This completes an end-to-end invocation of trade finance blockchain application from grounds up. Another approach of building the blockchain application could be through an open development framework called Hyperledger Composer. Hyperledger Composer is an extensive, open development toolset and framework that makes developing blockchain applications easier. You can use Hyperledger Composer to quickly model assets, business networks, and transactions methods. The Hyperledger Composer generates an archive file that can be deployed to the blockchain network. Hyperledger Composer is under active development, and we would revisit the tooling environment in a later edition. For more details, refer to &#8211; https:\/\/hyperledger.github.io\/composer\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this section, we will execute the entire network setup and business workflow using a single script representing our test cases. You can download the source code of the book from GitHub location \u2013 https:\/\/github.com\/enterprise-blockchain-book\/first-edition.git, if you haven\u2019t downloaded it yet. Go to hyperledger-fabric folder. The following shows the structure of the hyperledger-fabric folder The [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2128,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,174],"tags":[286],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.0.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>End-to-End Test Execution of Trade Finance application - Current and Future Technology Trends by Navveen Balani<\/title>\n<meta name=\"description\" content=\"End-to-End Test Execution of Trade Finance application - Articles\" \/>\n<link rel=\"canonical\" href=\"https:\/\/navveenbalani.dev\/index.php\/articles\/end-to-end-test-execution-of-trade-finance-application\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"End-to-End Test Execution of Trade Finance application - Current and Future Technology Trends by Navveen Balani\" \/>\n<meta property=\"og:description\" content=\"End-to-End Test Execution of Trade Finance application - Articles\" \/>\n<meta property=\"og:url\" content=\"https:\/\/navveenbalani.dev\/index.php\/articles\/end-to-end-test-execution-of-trade-finance-application\/\" \/>\n<meta property=\"og:site_name\" content=\"Current and Future Technology Trends by Navveen Balani\" \/>\n<meta property=\"article:published_time\" content=\"2018-12-17T18:27:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-18T10:43:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2016\/09\/bk6.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"450\" \/>\n\t<meta property=\"og:image:height\" content=\"374\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"4 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/navveenbalani.dev\/#website\",\"url\":\"https:\/\/navveenbalani.dev\/\",\"name\":\"Current and Future Technology Trends by Navveen Balani\",\"description\":\"Current and Future Technology Trends by Navveen Balani\",\"publisher\":{\"@id\":\"https:\/\/navveenbalani.dev\/#\/schema\/person\/51f7ab14b20611d95e3c7fd4ea0950bf\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/navveenbalani.dev\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/end-to-end-test-execution-of-trade-finance-application\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2016\/09\/bk6.jpg\",\"width\":450,\"height\":374},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/end-to-end-test-execution-of-trade-finance-application\/#webpage\",\"url\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/end-to-end-test-execution-of-trade-finance-application\/\",\"name\":\"End-to-End Test Execution of Trade Finance application - Current and Future Technology Trends by Navveen Balani\",\"isPartOf\":{\"@id\":\"https:\/\/navveenbalani.dev\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/end-to-end-test-execution-of-trade-finance-application\/#primaryimage\"},\"datePublished\":\"2018-12-17T18:27:13+00:00\",\"dateModified\":\"2019-12-18T10:43:59+00:00\",\"description\":\"End-to-End Test Execution of Trade Finance application - Articles\",\"breadcrumb\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/end-to-end-test-execution-of-trade-finance-application\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/navveenbalani.dev\/index.php\/articles\/end-to-end-test-execution-of-trade-finance-application\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/end-to-end-test-execution-of-trade-finance-application\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/navveenbalani.dev\/\",\"url\":\"https:\/\/navveenbalani.dev\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/end-to-end-test-execution-of-trade-finance-application\/\",\"url\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/end-to-end-test-execution-of-trade-finance-application\/\",\"name\":\"End-to-End Test Execution of Trade Finance application\"}}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/end-to-end-test-execution-of-trade-finance-application\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/end-to-end-test-execution-of-trade-finance-application\/#webpage\"},\"author\":{\"@id\":\"https:\/\/navveenbalani.dev\/#\/schema\/person\/51f7ab14b20611d95e3c7fd4ea0950bf\"},\"headline\":\"End-to-End Test Execution of Trade Finance application\",\"datePublished\":\"2018-12-17T18:27:13+00:00\",\"dateModified\":\"2019-12-18T10:43:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/end-to-end-test-execution-of-trade-finance-application\/#webpage\"},\"publisher\":{\"@id\":\"https:\/\/navveenbalani.dev\/#\/schema\/person\/51f7ab14b20611d95e3c7fd4ea0950bf\"},\"image\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/end-to-end-test-execution-of-trade-finance-application\/#primaryimage\"},\"keywords\":\"blockchain-guide\",\"articleSection\":\"Articles,Blockchain\",\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/navveenbalani.dev\/#\/schema\/person\/51f7ab14b20611d95e3c7fd4ea0950bf\",\"name\":\"Navveen\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/navveenbalani.dev\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/07\/navveen_balani.jpeg\",\"width\":200,\"height\":200,\"caption\":\"Navveen\"},\"logo\":{\"@id\":\"https:\/\/navveenbalani.dev\/#personlogo\"},\"sameAs\":[\"http:\/\/naveenbalani.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/posts\/2739"}],"collection":[{"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/comments?post=2739"}],"version-history":[{"count":7,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/posts\/2739\/revisions"}],"predecessor-version":[{"id":2759,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/posts\/2739\/revisions\/2759"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/media\/2128"}],"wp:attachment":[{"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/media?parent=2739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/categories?post=2739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/tags?post=2739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}