-
Notifications
You must be signed in to change notification settings - Fork 1
/
test-load.sh
executable file
·59 lines (44 loc) · 2.03 KB
/
test-load.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# Documentation on JSON API
# https://docs.daml.com/json-api/index.html
source env.sh
# Set the following to the user token
# UPDATE THE FOLLOWING
#
AUTH_TOKEN_NAME="george.token"
PARTY_ID=`cat data/parties.txt | jq ."george"`
#AUTH_TOKEN_NAME="bob.token"
#PARTY_ID=`cat data/parties.txt | jq ."bob"`
if [ ! -f "certs/participant2/jwt/$AUTH_TOKEN_NAME" ] ; then
echo "ERROR: Please set user authentication up first!"
exit 1
fi
PACKAGE_ID=`daml damlc inspect-dar --json dars/SecureDaml.dar | jq -r .main_package_id`
AUTH_TOKEN=`cat "certs/participant2/jwt/$AUTH_TOKEN_NAME"`
DOMAIN=customer2.com
# Tests
# Create a new Asset for Party
# Move Asset to new owner
create_asset() {
# Create a new contract via JSON API
echo ""
echo "Creating new contract"
RANDOM_STRING=`openssl rand -hex 16`
RESULT=`curl -s --cacert ./certs/participant2/intermediate/certs/ca-chain.cert.pem --key $(pwd)/certs/participant2/client/admin-api.$DOMAIN.key.pem --cert $(pwd)/certs/participant2/client/admin-api.$DOMAIN.cert.pem -X POST -H 'Content-Type: application/json' -H "Authorization: Bearer $AUTH_TOKEN" -d "{ \"templateId\": \"$PACKAGE_ID:Main:Asset\", \"payload\": {\"owner\": $PARTY_ID,\"name\": \"TV-$RANDOM_STRING\", \"issuer\": $PARTY_ID}}" https://$JSON_API_2_HOST:$JSON_API_2_PORT/v1/create`
#RESULT=`curl -s -X POST -H 'Content-Type: application/json' -H "Authorization: Bearer $AUTH_TOKEN" -d "{ \"templateId\": \"$PACKAGE_ID:Main:Asset\", \"payload\": {\"owner\": $PARTY_ID,\"name\": \"TV-$RANDOM_STRING\", \"issuer\": $PARTY_ID}}" http://$JSON_API_2_HOST:$JSON_API_2_PORT/v1/create`
#echo $RESULT | jq .
STATUS=`echo $RESULT | jq .status `
if [ "$STATUS" != "200" ] ; then
echo "ERROR: Failure executing command!"
exit
fi
echo "Status: $STATUS"
CONTRACT_ID=`echo $RESULT | jq .result.contractId | tr -d '"'`
echo "Contract ID: $CONTRACT_ID"
}
for i in {0..1000}
do
create_asset
done