github.com/inklabsfoundation/inkchain@v0.17.1-0.20181025012015-c3cef8062f19/examples/cli_test/scripts/test_marbles.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  #
     4  #Copyright Ziggurat Corp. 2017 All Rights Reserved.
     5  #
     6  #SPDX-License-Identifier: Apache-2.0
     7  #
     8  
     9  # Detecting whether can import the header file to render colorful cli output
    10  if [ -f ./header.sh ]; then
    11   source ./header.sh
    12  elif [ -f scripts/header.sh ]; then
    13   source scripts/header.sh
    14  else
    15   alias echo_r="echo"
    16   alias echo_g="echo"
    17   alias echo_b="echo"
    18  fi
    19  
    20  CHANNEL_NAME="$1"
    21  : ${CHANNEL_NAME:="mychannel"}
    22  : ${TIMEOUT:="60"}
    23  COUNTER=0
    24  MAX_RETRY=5
    25  
    26  ORDERER_CA=/opt/gopath/src/github.com/inklabsfoundation/inkchain/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
    27  
    28  echo_b "Chaincode Path : "$CC_PATH
    29  echo_b "Channel name : "$CHANNEL_NAME
    30  
    31  verifyResult () {
    32      if [ $1 -ne 0 ] ; then
    33          echo_b "!!!!!!!!!!!!!!! "$2" !!!!!!!!!!!!!!!!"
    34          echo_r "================== ERROR !!! FAILED to execute MVE =================="
    35          echo
    36          exit 1
    37      fi
    38  }
    39  
    40  marbleInvoke(){
    41      peer chaincode invoke -C mychannel -n marbles --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["initMarble","marble1","blue","35","tom"]}' -z bc4bcb06a0793961aec4ee377796e050561b6a84852deccea5ad4583bb31eebe >&log.txt
    42      res=$?
    43      cat log.txt
    44      verifyResult $res "marble invoke has Failed."
    45      echo_g "===================== marble invoke successfully======================= "
    46      echo
    47  }
    48  
    49  marbleQuery () {
    50      echo_b "Attempting to Query marble1 "
    51      sleep 3
    52      peer chaincode query -C mychannel -n marbles -c '{"Args":["readMarble","marble1"]}' >log.txt
    53      res=$?
    54      cat log.txt
    55      verifyResult $res "query account A Failed."
    56  }
    57  
    58  echo_b "=====================6.marble invoke======================="
    59  marbleInvoke
    60  
    61  echo_b "=====================7.query marble1====================="
    62  marbleQuery
    63  
    64  echo
    65  echo_g "=====================All GOOD, MVE Test completed ===================== "
    66  echo
    67  exit 0
    68