Skip to content

Commit

Permalink
[FAB-12587] Fix for Query Block by block hash API
Browse files Browse the repository at this point in the history
Block Query by hash Fixed in balance transfer app.

Change-Id: Iad5c0af657e7359ee787e1f939a6695d470da1cd
Signed-off-by: sebastianpaulp <spaul@jeadigital.com>
  • Loading branch information
sebastian-paul authored and asararatnakar committed Oct 24, 2018
1 parent df311ce commit 6dc5ce5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion balance-transfer/app/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ var getBlockByHash = async function(peer, channelName, hash, username, org_name)
throw new Error(message);
}

let response_payload = await channel.queryBlockByHash(Buffer.from(hash), peer);
let response_payload = await channel.queryBlockByHash(Buffer.from(hash,'hex'), peer);
if (response_payload) {
logger.debug(response_payload);
return response_payload;
Expand Down
33 changes: 16 additions & 17 deletions balance-transfer/testAPIs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,13 @@ echo

echo "GET query Block by blockNumber"
echo
curl -s -X GET \
BLOCK_INFO=$(curl -s -X GET \
"http://localhost:4000/channels/mychannel/blocks/1?peer=peer0.org1.example.com" \
-H "authorization: Bearer $ORG1_TOKEN" \
-H "content-type: application/json"
echo
-H "content-type: application/json")
echo $BLOCK_INFO
# Assign previvious block hash to HASH
HASH=$(echo $BLOCK_INFO | jq -r ".header.previous_hash")
echo

echo "GET query Transaction by TransactionID"
Expand All @@ -224,20 +226,17 @@ curl -s -X GET http://localhost:4000/channels/mychannel/transactions/$TRX_ID?pee
echo
echo

############################################################################
### TODO: What to pass to fetch the Block information
############################################################################
#echo "GET query Block by Hash"
#echo
#hash=????
#curl -s -X GET \
# "http://localhost:4000/channels/mychannel/blocks?hash=$hash&peer=peer1" \
# -H "authorization: Bearer $ORG1_TOKEN" \
# -H "cache-control: no-cache" \
# -H "content-type: application/json" \
# -H "x-access-token: $ORG1_TOKEN"
#echo
#echo

echo "GET query Block by Hash - Hash is $HASH"
echo
curl -s -X GET \
"http://localhost:4000/channels/mychannel/blocks?hash=$HASH&peer=peer0.org1.example.com" \
-H "authorization: Bearer $ORG1_TOKEN" \
-H "cache-control: no-cache" \
-H "content-type: application/json" \
-H "x-access-token: $ORG1_TOKEN"
echo
echo

echo "GET query ChainInfo"
echo
Expand Down

0 comments on commit 6dc5ce5

Please sign in to comment.