Skip to content

Commit 6dc5ce5

Browse files
sebastian-paulasararatnakar
authored andcommitted
[FAB-12587] Fix for Query Block by block hash API
Block Query by hash Fixed in balance transfer app. Change-Id: Iad5c0af657e7359ee787e1f939a6695d470da1cd Signed-off-by: sebastianpaulp <spaul@jeadigital.com>
1 parent df311ce commit 6dc5ce5

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

balance-transfer/app/query.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ var getBlockByHash = async function(peer, channelName, hash, username, org_name)
115115
throw new Error(message);
116116
}
117117

118-
let response_payload = await channel.queryBlockByHash(Buffer.from(hash), peer);
118+
let response_payload = await channel.queryBlockByHash(Buffer.from(hash,'hex'), peer);
119119
if (response_payload) {
120120
logger.debug(response_payload);
121121
return response_payload;

balance-transfer/testAPIs.sh

+16-17
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,13 @@ echo
209209

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

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

227-
############################################################################
228-
### TODO: What to pass to fetch the Block information
229-
############################################################################
230-
#echo "GET query Block by Hash"
231-
#echo
232-
#hash=????
233-
#curl -s -X GET \
234-
# "http://localhost:4000/channels/mychannel/blocks?hash=$hash&peer=peer1" \
235-
# -H "authorization: Bearer $ORG1_TOKEN" \
236-
# -H "cache-control: no-cache" \
237-
# -H "content-type: application/json" \
238-
# -H "x-access-token: $ORG1_TOKEN"
239-
#echo
240-
#echo
229+
230+
echo "GET query Block by Hash - Hash is $HASH"
231+
echo
232+
curl -s -X GET \
233+
"http://localhost:4000/channels/mychannel/blocks?hash=$HASH&peer=peer0.org1.example.com" \
234+
-H "authorization: Bearer $ORG1_TOKEN" \
235+
-H "cache-control: no-cache" \
236+
-H "content-type: application/json" \
237+
-H "x-access-token: $ORG1_TOKEN"
238+
echo
239+
echo
241240

242241
echo "GET query ChainInfo"
243242
echo

0 commit comments

Comments
 (0)