diff --git a/test/performance-test/artillery/config.yaml b/test/performance-test/artillery/config.yaml index d3e299ae..12674fc3 100644 --- a/test/performance-test/artillery/config.yaml +++ b/test/performance-test/artillery/config.yaml @@ -1,23 +1,25 @@ config: - target: "localhost:8081" - phases: - - duration: 10 - arrivalCount: 10 - environments: - localhost: - target: "http://localhost:8081" - phases: - - duration: 10 - arrivalCount: 10 - testnet: - target: "https://explorer.cardano-testnet.iohkdev.io/rosetta" - phases: - - duration: 120 - arrivalRate: 10 - payload: - path: "{{ $environment }}-vars.csv" - fields: - - "networkId" - - "blockIndex" - - "blockHash" - - "transactionId" + target: "localhost:8081" + phases: + - duration: 60 + arrivalCount: 10 + processor: "../sign-transaction.js" + environments: + localhost: + target: "http://localhost:8081" + phases: + - duration: 120 + #arrivalRate: 60 + arrivalCount: 180 + testnet: + target: "https://explorer.cardano-testnet.iohkdev.io/rosetta" + phases: + - duration: 120 + arrivalRate: 120 + payload: + path: "../vars/{{ $environment }}-vars.csv" + fields: + - "networkId" + - "blockIndex" + - "blockHash" + - "transactionId" diff --git a/test/performance-test/artillery/construction-simple-transaction.yaml b/test/performance-test/artillery/construction-simple-transaction.yaml deleted file mode 100644 index dd37576a..00000000 --- a/test/performance-test/artillery/construction-simple-transaction.yaml +++ /dev/null @@ -1,82 +0,0 @@ -Network-Identifier: &network_identifier - network_identifier: - blockchain: "cardano" - network: "{{ networkId }}" - -Public-Key: &public_key - hex_bytes: "22ae46272bffe077cecc46e1494d790d4ad453ae1c4228aa0c2e9671dcb16344" - curve_type: "edwards25519" - -Ada-Currency: &ada_currency - currency: - symbol: "ADA" - decimals: 6 - -scenarios: - - name: Simple Transaction - flow: - - log: "/construction/derive" - - post: - url: "/construction/derive" - capture: - json: "$.address" - as: "address" - headers: - Content-Type: "application/json" - json: - <<: *network_identifier - public_key: - <<: *public_key - metadata: - relative_ttl: 1000 - - log: "/construction/preprocess" - - post: - url: "/construction/preprocess" - capture: - json: "$.options" - as: "options" - headers: - Content-Type: "application/json" - json: - <<: *network_identifier - operations: - - operation_identifier: - index: 0 - type: "input" - status: "" # maybe can be removed soon - account: - address: "{{ address }}" - amount: - value: "-100000" - <<: *ada_currency - coin_change: - coin_identifier: - identifier: "8f0e1bb31ff09a8dcc8a1b13d6ccb8f873f8d94b17bb7236c62e2d9d63d5426b:0" - coin_action: "coin_spent" - - operation_identifier: - index: 1 - type: "output" - status: "" # maybe can be removed soon - account: - address: "{{ address }}" - amount: - value: 90000 - <<: *ada_currency - - log: "/construction/metadata" - - post: - url: "/construction/metadata" - capture: - - json: "$.suggested_fee[0].value" - as: "suggested_fee_value" - - json: "$.metadata.ttl" - as: "ttl" - headers: - Content-Type: "application/json" - json: - <<: *network_identifier - options: - "{{ options }}" - public_keys: - - <<: *public_key - - log: "suggested_fee_value: {{ suggested_fee_value }}" - - log: "ttl: {{ ttl }}" diff --git a/test/performance-test/artillery/readme.md b/test/performance-test/artillery/readme.md index 4cf9c26b..cd0afe17 100644 --- a/test/performance-test/artillery/readme.md +++ b/test/performance-test/artillery/readme.md @@ -1,5 +1,20 @@ -### Artillery Performance Tests +``` +____ ____ ____ ____ ____ ___ _ _ _ ____ ____ _ _ +|__/ | | [__ |__| |__/ | | | | |___ |__/ \_/ +| \ |__| ___] | | | \ | | |___ |___ |___ | \ | +``` +#### Install +- `npm i artillery` + +#### Configure +- Edit config.yaml and refer to https://artillery.io/docs/guides/guides/test-script-reference.html +- If targetting localhost environment then must have Testnet Rosetta instance running locally on port 8081 + +#### Run test +- `$(npm bin)/artillery run tests/data-block-tests.yaml --environment localhost --config config.yaml --output report` +- `$(npm bin)/artillery run tests/construction-simple-transaction.yaml --environment localhost --config config.yaml --output report` + +#### Produce html report +- `$(npm bin)/artillery report report` + -- npm i artillery -- $(npm bin)/artillery run data-block-tests.yaml --environment localhost --config config.yaml --output report.json -- $(npm bin)/artillery report report.json report.html diff --git a/test/performance-test/artillery/sign-transaction.js b/test/performance-test/artillery/sign-transaction.js new file mode 100644 index 00000000..e3aabb43 --- /dev/null +++ b/test/performance-test/artillery/sign-transaction.js @@ -0,0 +1,23 @@ +const NaCl = require('tweetnacl'); + +module.exports = { + signTransaction +} + +function signTransaction(context, events, done) { + const hex_bytes = context.vars['hex_bytes']; + const private_key = "41d9523b87b9bd89a4d07c9b957ae68a7472d8145d7956a692df1a8ad91957a2c117d9dd874447f47306f50a650f1e08bf4bec2cfcb2af91660f23f2db912977"; + context.vars['public_key'] = "c117d9dd874447f47306f50a650f1e08bf4bec2cfcb2af91660f23f2db912977"; + + const key_pair = NaCl.sign.keyPair.fromSecretKey(Buffer.from(private_key, "hex")) + const secret_key = key_pair.secretKey; + + context.vars['signed_hex_bytes'] = Buffer.from( + NaCl.sign.detached( + Buffer.from(hex_bytes, "hex"), + secret_key + ) + ).toString("hex") + + return done(); +} diff --git a/test/performance-test/artillery/tests/construction-simple-transaction.yaml b/test/performance-test/artillery/tests/construction-simple-transaction.yaml new file mode 100644 index 00000000..6f7b34ba --- /dev/null +++ b/test/performance-test/artillery/tests/construction-simple-transaction.yaml @@ -0,0 +1,171 @@ +Http-Headers: &headers + headers: + Content-Type: "application/json" + +Network-Identifier: &network_identifier + network_identifier: + blockchain: "cardano" + network: "{{ networkId }}" + +Public-Key: &public_key + hex_bytes: "22ae46272bffe077cecc46e1494d790d4ad453ae1c4228aa0c2e9671dcb16344" + curve_type: "edwards25519" + +Ada-Currency: &ada_currency + currency: + symbol: "ADA" + decimals: 6 + +Operations: &operations + operations: + - operation_identifier: + index: 0 + type: "input" + status: "" # maybe can be removed soon + account: + address: "{{ address }}" + amount: + value: "-100000" + <<: *ada_currency + coin_change: + coin_identifier: + identifier: "8f0e1bb31ff09a8dcc8a1b13d6ccb8f873f8d94b17bb7236c62e2d9d63d5426b:0" + coin_action: "coin_spent" + - operation_identifier: + index: 1 + type: "output" + status: "" # maybe can be removed soon + account: + address: "{{ address }}" + amount: + value: 90000 + <<: *ada_currency + +Signatures: &signatures + signatures: + - signing_payload: + account_identifier: + address: "{{ address }}" + #metadata: "" + hex_bytes: "{{ hex_bytes }}" + signature_type: "ed25519" + public_key: + hex_bytes: "{{ public_key }}" # defined in sign-transaction.js + curve_type: "edwards25519" + signature_type: "ed25519" + hex_bytes: "{{ signed_hex_bytes }}" # produced in sign-transaction.js + +scenarios: + - name: Simple Transaction + flow: + - log: "/construction/derive" + - post: + url: "/construction/derive" + capture: + json: "$.address" + as: "address" + <<: *headers + json: + <<: *network_identifier + public_key: + <<: *public_key + metadata: + relative_ttl: 1000 + + - log: "/construction/preprocess" + - post: + url: "/construction/preprocess" + capture: + json: "$.options" + as: "options" + <<: *headers + json: + <<: *network_identifier + <<: *operations + + - log: "/construction/metadata" + - post: + url: "/construction/metadata" + capture: + - json: "$.suggested_fee" + as: "suggested_fee" + - json: "$.metadata" + as: "metadata" + <<: *headers + json: + <<: *network_identifier + options: + "{{ options }}" + public_keys: + - <<: *public_key + + - log: "/construction/payloads" + - post: + url: "/construction/payloads" + capture: + - json: "$.unsigned_transaction" + as: "unsigned_transaction" + - json: "$.payloads[0].hex_bytes" + as: "hex_bytes" + <<: *headers + json: + <<: *network_identifier + <<: *operations + metadata: + "{{ metadata }}" + suggested_fee: + "{{ suggested_fee }}" + + - log: "/construction/parse (unsigned)" + - post: + url: "/construction/parse" + <<: *headers + json: + <<: *network_identifier + signed: "false" + transaction: + "{{ unsigned_transaction }}" + + - function: "signTransaction" # in sign-transaction.js + - log: "signed_hex_bytes: {{ signed_hex_bytes }}" + + - log: "/construction/combine" + - post: + url: "/construction/combine" + capture: + json: "$.signed_transaction" + as: "signed_transaction" + <<: *headers + json: + <<: *network_identifier + unsigned_transaction: "{{ unsigned_transaction }}" + <<: *signatures + + #- log: "signed_transaction={{ signed_transaction }}" + - log: "/construction/parse (signed)" + - post: + url: "/construction/parse" + <<: *headers + json: + <<: *network_identifier + signed: "true" + transaction: "{{ signed_transaction }}" + - log: "/construction/submit" + - post: + url: "/construction/submit" + <<: *headers + json: + <<: *network_identifier + signed_transaction: "{{ signed_transaction }}" + + - log: "/construction/hash" + - post: + url: "/construction/hash" + capture: + json: "$.transaction_identifier.hash" + as: "hash" + <<: *headers + json: + <<: *network_identifier + signed_transaction: "{{ signed_transaction }}" + <<: *signatures diff --git a/test/performance-test/artillery/data-block-tests.yaml b/test/performance-test/artillery/tests/data-block-tests.yaml similarity index 100% rename from test/performance-test/artillery/data-block-tests.yaml rename to test/performance-test/artillery/tests/data-block-tests.yaml diff --git a/test/performance-test/artillery/localhost-vars.csv b/test/performance-test/artillery/vars/localhost-vars.csv similarity index 100% rename from test/performance-test/artillery/localhost-vars.csv rename to test/performance-test/artillery/vars/localhost-vars.csv diff --git a/test/performance-test/artillery/testnet-vars.csv b/test/performance-test/artillery/vars/testnet-vars.csv similarity index 100% rename from test/performance-test/artillery/testnet-vars.csv rename to test/performance-test/artillery/vars/testnet-vars.csv