@@ -140,6 +140,7 @@ test_debug() {
140140}
141141
142142WALLET_UUID=" "
143+ WALLET2_UUID=" "
143144ESCROW_UUID=" "
144145DIGITAL_ASSET_UUID=" "
145146DIGITAL_ASSET_JSON=" "
@@ -192,12 +193,24 @@ test_create_wallet() {
192193test_create_wallet2 () {
193194 log_info " Creating second wallet..."
194195 cd $FPC_PATH /samples/application/simple-cli-go
195- ./fpcclient invoke createWallet " {
196+ local output= $( ./fpcclient invoke createWallet " {
196197 \" walletId\" : \" wallet-222\" ,
197198 \" ownerId\" : \" Bob\" ,
198199 \" ownerCertHash\" : \" sha256:ghi789\" ,
199200 \" balances\" : [0],
200201 \" digitalAssetTypes\" : [$DIGITAL_ASSET_JSON ]
202+ }" 2>&1 )
203+ echo " $output "
204+ WALLET2_UUID=$( echo " $output " | grep ' ^>' | sed ' s/^> //' | grep -o ' "@key":"wallet:[^"]*"' | cut -d' :' -f3 | tr -d ' "' )
205+ }
206+
207+ test_create_user_dir () {
208+ log_info " Creating user directory..."
209+ cd $FPC_PATH /samples/application/simple-cli-go
210+ ./fpcclient invoke createUserDir " {
211+ \" publicKeyHash\" : \" pubkey-hash-123\" ,
212+ \" walletId\" : \" $WALLET_UUID \" ,
213+ \" certHash\" : \" sha256:def456\"
201214 }"
202215}
203216
@@ -208,9 +221,9 @@ test_create_escrow() {
208221 \" escrowId\" : \" escrow-111\" ,
209222 \" buyerPubKey\" : \" buyer_pub\" ,
210223 \" sellerPubKey\" : \" seller_pub\" ,
211- \" amount\" : 1000 ,
224+ \" amount\" : 20 ,
212225 \" assetType\" : $DIGITAL_ASSET_JSON ,
213- \" conditionValue\" : \" sha256: secret123\" ,
226+ \" conditionValue\" : \" $( echo -n ' secret123' | sha256sum | cut -d ' ' -f1 ) \" ,
214227 \" status\" : \" Active\" ,
215228 \" buyerCertHash\" : \" sha256:buyer_cert\"
216229 }" 2>&1 )
@@ -237,28 +250,28 @@ test_get_balance() {
237250
238251 # Test getting balance for CBDCC in wallet1
239252 cd $FPC_PATH /samples/application/simple-cli-go
240- ./fpcclient query getBalance ' {
241- "walletId": "wallet-111 ",
242- "assetSymbol": "CBDCC",
243- "ownerCertHash": "sha256:def456"
244- }'
253+ ./fpcclient query getBalance " {
254+ \ " walletId\ " : \" $WALLET_UUID \ " ,
255+ \ " assetSymbol\ " : \ " CBDCC\ " ,
256+ \ " ownerCertHash\ " : \ " sha256:def456\ "
257+ }"
245258}
246259
247260test_get_wallet_by_owner () {
248261 log_info " Testing getWalletByOwner transaction"
249262 cd $FPC_PATH /samples/application/simple-cli-go
250- ./fpcclient query getWalletByOwner ' {
251- "ownerId ": "Abhinav ",
252- "ownerCertHash": "sha256:def456"
253- }'
263+ ./fpcclient query getWalletByOwner " {
264+ \" walletUuid \ " : \" $WALLET_UUID \ " ,
265+ \ " ownerCertHash\ " : \ " sha256:def456\ "
266+ }"
254267}
255268
256269test_mint_tokens () {
257270 log_info " Testing mintTokens transaction"
258271 cd $FPC_PATH /samples/application/simple-cli-go
259272 ./fpcclient invoke mintTokens " {
260273 \" assetId\" : \" $DIGITAL_ASSET_UUID \" ,
261- \" walletId\" : \" wallet-111 \" ,
274+ \" walletId\" : \" $WALLET_UUID \" ,
262275 \" amount\" : 100,
263276 \" issuerCertHash\" : \" sha256:abc123\"
264277 }"
@@ -268,8 +281,8 @@ test_transfer_tokens() {
268281 log_info " Testing transferTokens transaction"
269282 cd $FPC_PATH /samples/application/simple-cli-go
270283 ./fpcclient invoke transferTokens " {
271- \" fromWalletId\" : \" wallet-111 \" ,
272- \" toWalletId\" : \" wallet-222 \" ,
284+ \" fromWalletId\" : \" $WALLET_UUID \" ,
285+ \" toWalletId\" : \" $WALLET2_UUID \" ,
273286 \" assetId\" : \" $DIGITAL_ASSET_UUID \" ,
274287 \" amount\" : 50,
275288 \" senderCertHash\" : \" sha256:def456\"
@@ -281,12 +294,104 @@ test_burn_tokens() {
281294 cd $FPC_PATH /samples/application/simple-cli-go
282295 ./fpcclient invoke burnTokens " {
283296 \" assetId\" : \" $DIGITAL_ASSET_UUID \" ,
284- \" walletId\" : \" wallet-111 \" ,
297+ \" walletId\" : \" $WALLET_UUID \" ,
285298 \" amount\" : 25,
286299 \" issuerCertHash\" : \" sha256:abc123\"
287300 }"
288301}
289302
303+ test_lock_funds_in_escrow () {
304+ log_info " Testing lockFundsInEscrow transaction"
305+ cd $FPC_PATH /samples/application/simple-cli-go
306+ ./fpcclient invoke lockFundsInEscrow " {
307+ \" escrowId\" : \" $ESCROW_UUID \" ,
308+ \" payerWalletId\" : \" $WALLET_UUID \" ,
309+ \" amount\" : 20,
310+ \" assetId\" : \" $DIGITAL_ASSET_UUID \" ,
311+ \" payerCertHash\" : \" sha256:def456\"
312+ }"
313+ }
314+
315+ test_get_escrow_balance () {
316+ log_info " Testing getEscrowBalance transaction"
317+ cd $FPC_PATH /samples/application/simple-cli-go
318+ ./fpcclient query getEscrowBalance " {
319+ \" walletId\" : \" $WALLET_UUID \" ,
320+ \" assetSymbol\" : \" CBDCC\" ,
321+ \" ownerCertHash\" : \" sha256:def456\"
322+ }"
323+ }
324+
325+ test_verify_escrow_condition () {
326+ log_info " Testing verifyEscrowCondition transaction"
327+ cd $FPC_PATH /samples/application/simple-cli-go
328+ ./fpcclient invoke verifyEscrowCondition " {
329+ \" escrowId\" : \" $ESCROW_UUID \" ,
330+ \" secret\" : \" secret\" ,
331+ \" parcelId\" : \" 123\"
332+ }"
333+ }
334+
335+ test_release_escrow () {
336+ log_info " Testing releaseEscrow transaction"
337+ cd $FPC_PATH /samples/application/simple-cli-go
338+ ./fpcclient invoke releaseEscrow " {
339+ \" escrowId\" : \" $ESCROW_UUID \" ,
340+ \" payerWalletId\" : \" $WALLET_UUID \" ,
341+ \" payeeWalletId\" : \" $WALLET2_UUID \"
342+ }"
343+ }
344+
345+ test_refund_escrow () {
346+ log_info " Testing refundEscrow transaction (on new escrow)"
347+ cd $FPC_PATH /samples/application/simple-cli-go
348+ # Create another escrow for refund test
349+ local output=$( ./fpcclient invoke createEscrow " {
350+ \" escrowId\" : \" escrow-refund\" ,
351+ \" buyerPubKey\" : \" buyer_pub2\" ,
352+ \" sellerPubKey\" : \" seller_pub2\" ,
353+ \" amount\" : 5,
354+ \" assetType\" : $DIGITAL_ASSET_JSON ,
355+ \" conditionValue\" : \" different_condition\" ,
356+ \" status\" : \" Created\" ,
357+ \" buyerCertHash\" : \" sha256:buyer_cert2\"
358+ }" 2>&1 )
359+
360+ local REFUND_ESCROW_UUID=$( echo " $output " | grep ' ^>' | sed ' s/^> //' | grep -o ' "@key":"escrow:[^"]*"' | cut -d' :' -f3 | tr -d ' "' )
361+
362+ # Lock funds in refund escrow
363+ ./fpcclient invoke lockFundsInEscrow " {
364+ \" escrowId\" : \" $REFUND_ESCROW_UUID \" ,
365+ \" payerWalletId\" : \" $WALLET_UUID \" ,
366+ \" amount\" : 5,
367+ \" assetId\" : \" $DIGITAL_ASSET_UUID \" ,
368+ \" payerCertHash\" : \" sha256:def456\"
369+ }"
370+
371+ # Now refund
372+ ./fpcclient invoke refundEscrow " {
373+ \" escrowId\" : \" $REFUND_ESCROW_UUID \" ,
374+ \" payerWalletId\" : \" $WALLET_UUID \"
375+ }"
376+ }
377+
378+ # test_read_user_dir() {
379+ # log_info "Testing readUserDir transaction with authentication"
380+ # cd $FPC_PATH/samples/application/simple-cli-go
381+ # # This should work - correct cert hash
382+ # ./fpcclient query readUserDir "{
383+ # \"uuid\": \"pubkey-hash-123\",
384+ # \"certHash\": \"sha256:def456\"
385+ # }"
386+ #
387+ # log_info "Testing unauthorized access (should fail)"
388+ # # This should fail - wrong cert hash
389+ # ./fpcclient query readUserDir "{
390+ # \"uuid\": \"pubkey-hash-123\",
391+ # \"certHash\": \"wrong_hash\"
392+ # }" || log_info "Expected failure - unauthorized access blocked"
393+ # }
394+
290395test_query_escrow () {
291396 log_info " Querying escrow..."
292397 cd $FPC_PATH /samples/application/simple-cli-go
@@ -302,18 +407,34 @@ run_tests() {
302407 test_create_asset
303408 test_create_wallet
304409 test_create_wallet2
410+ test_create_user_dir
305411 test_create_escrow
306412 test_query_asset
307413 test_query_wallet
308414 test_query_escrow
309- test_get_balance
310415 test_get_wallet_by_owner
311416 test_mint_tokens
312417 test_get_balance
313418 test_transfer_tokens
314419 test_get_balance
315420 test_burn_tokens
316421 test_get_balance
422+ test_get_wallet_by_owner
423+
424+ # New escrow tests
425+ log_info " === ESCROW SYSTEM TESTS ==="
426+ test_lock_funds_in_escrow
427+ test_get_balance
428+ test_get_escrow_balance
429+ test_verify_escrow_condition
430+ test_release_escrow
431+ test_get_balance
432+ test_get_escrow_balance
433+ test_refund_escrow
434+ test_get_balance
435+ test_get_escrow_balance
436+ # test_read_user_dir
437+
317438 log_success " === TESTS COMPLETED ==="
318439}
319440
0 commit comments