Skip to content

Commit c80ae48

Browse files
author
James Browning
committed
Finished simple transaction scenario with Artillery
1 parent dcd76f4 commit c80ae48

File tree

8 files changed

+237
-108
lines changed

8 files changed

+237
-108
lines changed
Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
config:
2-
target: "localhost:8081"
3-
phases:
4-
- duration: 10
5-
arrivalCount: 10
6-
environments:
7-
localhost:
8-
target: "http://localhost:8081"
9-
phases:
10-
- duration: 10
11-
arrivalCount: 10
12-
testnet:
13-
target: "https://explorer.cardano-testnet.iohkdev.io/rosetta"
14-
phases:
15-
- duration: 120
16-
arrivalRate: 10
17-
payload:
18-
path: "{{ $environment }}-vars.csv"
19-
fields:
20-
- "networkId"
21-
- "blockIndex"
22-
- "blockHash"
23-
- "transactionId"
2+
target: "localhost:8081"
3+
phases:
4+
- duration: 60
5+
arrivalCount: 10
6+
processor: "../sign-transaction.js"
7+
environments:
8+
localhost:
9+
target: "http://localhost:8081"
10+
phases:
11+
- duration: 120
12+
#arrivalRate: 60
13+
arrivalCount: 180
14+
testnet:
15+
target: "https://explorer.cardano-testnet.iohkdev.io/rosetta"
16+
phases:
17+
- duration: 120
18+
arrivalRate: 120
19+
payload:
20+
path: "../vars/{{ $environment }}-vars.csv"
21+
fields:
22+
- "networkId"
23+
- "blockIndex"
24+
- "blockHash"
25+
- "transactionId"

test/performance-test/artillery/construction-simple-transaction.yaml

Lines changed: 0 additions & 82 deletions
This file was deleted.

test/performance-test/artillery/readme.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1-
### Artillery Performance Tests
1+
```
2+
____ ____ ____ ____ ____ ___ _ _ _ ____ ____ _ _
3+
|__/ | | [__ |__| |__/ | | | | |___ |__/ \_/
4+
| \ |__| ___] | | | \ | | |___ |___ |___ | \ |
5+
```
6+
#### Install
7+
- `npm i artillery`
8+
9+
#### Configure
10+
- Edit config.yaml and refer to https://artillery.io/docs/guides/guides/test-script-reference.html
11+
- If targetting localhost environment then must have Testnet Rosetta instance running locally on port 8081
12+
13+
#### Run test
14+
- `$(npm bin)/artillery run tests/data-block-tests.yaml --environment localhost --config config.yaml --output report`
15+
- `$(npm bin)/artillery run tests/construction-simple-transaction.yaml --environment localhost --config config.yaml --output report`
16+
17+
#### Produce html report
18+
- `$(npm bin)/artillery report report`
19+
220

3-
- npm i artillery
4-
- $(npm bin)/artillery run data-block-tests.yaml --environment localhost --config config.yaml --output report.json
5-
- $(npm bin)/artillery report report.json report.html
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const NaCl = require('tweetnacl');
2+
3+
module.exports = {
4+
signTransaction
5+
}
6+
7+
function signTransaction(context, events, done) {
8+
const hex_bytes = context.vars['hex_bytes'];
9+
const private_key = "41d9523b87b9bd89a4d07c9b957ae68a7472d8145d7956a692df1a8ad91957a2c117d9dd874447f47306f50a650f1e08bf4bec2cfcb2af91660f23f2db912977";
10+
context.vars['public_key'] = "c117d9dd874447f47306f50a650f1e08bf4bec2cfcb2af91660f23f2db912977";
11+
12+
const key_pair = NaCl.sign.keyPair.fromSecretKey(Buffer.from(private_key, "hex"))
13+
const secret_key = key_pair.secretKey;
14+
15+
context.vars['signed_hex_bytes'] = Buffer.from(
16+
NaCl.sign.detached(
17+
Buffer.from(hex_bytes, "hex"),
18+
secret_key
19+
)
20+
).toString("hex")
21+
22+
return done();
23+
}
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
Http-Headers: &headers
2+
headers:
3+
Content-Type: "application/json"
4+
5+
Network-Identifier: &network_identifier
6+
network_identifier:
7+
blockchain: "cardano"
8+
network: "{{ networkId }}"
9+
10+
Public-Key: &public_key
11+
hex_bytes: "22ae46272bffe077cecc46e1494d790d4ad453ae1c4228aa0c2e9671dcb16344"
12+
curve_type: "edwards25519"
13+
14+
Ada-Currency: &ada_currency
15+
currency:
16+
symbol: "ADA"
17+
decimals: 6
18+
19+
Operations: &operations
20+
operations:
21+
- operation_identifier:
22+
index: 0
23+
type: "input"
24+
status: "" # maybe can be removed soon
25+
account:
26+
address: "{{ address }}"
27+
amount:
28+
value: "-100000"
29+
<<: *ada_currency
30+
coin_change:
31+
coin_identifier:
32+
identifier: "8f0e1bb31ff09a8dcc8a1b13d6ccb8f873f8d94b17bb7236c62e2d9d63d5426b:0"
33+
coin_action: "coin_spent"
34+
- operation_identifier:
35+
index: 1
36+
type: "output"
37+
status: "" # maybe can be removed soon
38+
account:
39+
address: "{{ address }}"
40+
amount:
41+
value: 90000
42+
<<: *ada_currency
43+
44+
Signatures: &signatures
45+
signatures:
46+
- signing_payload:
47+
account_identifier:
48+
address: "{{ address }}"
49+
#metadata: ""
50+
hex_bytes: "{{ hex_bytes }}"
51+
signature_type: "ed25519"
52+
public_key:
53+
hex_bytes: "{{ public_key }}" # defined in sign-transaction.js
54+
curve_type: "edwards25519"
55+
signature_type: "ed25519"
56+
hex_bytes: "{{ signed_hex_bytes }}" # produced in sign-transaction.js
57+
58+
scenarios:
59+
- name: Simple Transaction
60+
flow:
61+
- log: "/construction/derive"
62+
- post:
63+
url: "/construction/derive"
64+
capture:
65+
json: "$.address"
66+
as: "address"
67+
<<: *headers
68+
json:
69+
<<: *network_identifier
70+
public_key:
71+
<<: *public_key
72+
metadata:
73+
relative_ttl: 1000
74+
75+
- log: "/construction/preprocess"
76+
- post:
77+
url: "/construction/preprocess"
78+
capture:
79+
json: "$.options"
80+
as: "options"
81+
<<: *headers
82+
json:
83+
<<: *network_identifier
84+
<<: *operations
85+
86+
- log: "/construction/metadata"
87+
- post:
88+
url: "/construction/metadata"
89+
capture:
90+
- json: "$.suggested_fee"
91+
as: "suggested_fee"
92+
- json: "$.metadata"
93+
as: "metadata"
94+
<<: *headers
95+
json:
96+
<<: *network_identifier
97+
options:
98+
"{{ options }}"
99+
public_keys:
100+
- <<: *public_key
101+
102+
- log: "/construction/payloads"
103+
- post:
104+
url: "/construction/payloads"
105+
capture:
106+
- json: "$.unsigned_transaction"
107+
as: "unsigned_transaction"
108+
- json: "$.payloads[0].hex_bytes"
109+
as: "hex_bytes"
110+
<<: *headers
111+
json:
112+
<<: *network_identifier
113+
<<: *operations
114+
metadata:
115+
"{{ metadata }}"
116+
suggested_fee:
117+
"{{ suggested_fee }}"
118+
119+
- log: "/construction/parse (unsigned)"
120+
- post:
121+
url: "/construction/parse"
122+
<<: *headers
123+
json:
124+
<<: *network_identifier
125+
signed: "false"
126+
transaction:
127+
"{{ unsigned_transaction }}"
128+
129+
- function: "signTransaction" # in sign-transaction.js
130+
- log: "signed_hex_bytes: {{ signed_hex_bytes }}"
131+
132+
- log: "/construction/combine"
133+
- post:
134+
url: "/construction/combine"
135+
capture:
136+
json: "$.signed_transaction"
137+
as: "signed_transaction"
138+
<<: *headers
139+
json:
140+
<<: *network_identifier
141+
unsigned_transaction: "{{ unsigned_transaction }}"
142+
<<: *signatures
143+
144+
#- log: "signed_transaction={{ signed_transaction }}"
145+
- log: "/construction/parse (signed)"
146+
- post:
147+
url: "/construction/parse"
148+
<<: *headers
149+
json:
150+
<<: *network_identifier
151+
signed: "true"
152+
transaction: "{{ signed_transaction }}"
153+
- log: "/construction/submit"
154+
- post:
155+
url: "/construction/submit"
156+
<<: *headers
157+
json:
158+
<<: *network_identifier
159+
signed_transaction: "{{ signed_transaction }}"
160+
161+
- log: "/construction/hash"
162+
- post:
163+
url: "/construction/hash"
164+
capture:
165+
json: "$.transaction_identifier.hash"
166+
as: "hash"
167+
<<: *headers
168+
json:
169+
<<: *network_identifier
170+
signed_transaction: "{{ signed_transaction }}"
171+
<<: *signatures

0 commit comments

Comments
 (0)