Created
August 15, 2019 16:37
-
-
Save shal/45d19895022e15f528d78bc6ddcca8c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { check } from "k6"; | |
import http from "k6/http"; | |
import { hmac } from "k6/crypto"; | |
export let options = { | |
// simulate rampup of trafficm 1 to 200 users over 5 minutes. | |
stages: [ | |
{ duration: "12m", target: 50 }, | |
] | |
}; | |
class Order { | |
constructor() { | |
this.side = 'sell'; | |
this.market = 'fthusd'; | |
this.volume = '0.1'; | |
this.price = '0.01'; | |
} | |
} | |
var data = [ | |
{ | |
"kid": "ec3bdb9d635b6e94", | |
"secret": "9547d5eebe39cce258627be6a5518fb6" | |
}, | |
{ | |
"kid": "0afbe027933912e8", | |
"secret": "4154b864cf2c810971bf760032dea63c" | |
}, | |
{ | |
"kid": "8ee9c9cb5ec7efe6", | |
"secret": "60adf01f9a40373087ce68d1804398b6" | |
}, | |
{ | |
"kid": "bc63340d2e861d7e", | |
"secret": "82dd4be3b2d46c9a969a29cb8f25d8d7" | |
}, | |
{ | |
"kid": "51c899c1faa992bd", | |
"secret": "2b0a34e84359e3d1b7208cd25b50095e" | |
}, | |
{ | |
"kid": "ca00175a679d3280", | |
"secret": "55c39ce3d3efc148ed5a965a845a7ec1" | |
}, | |
{ | |
"kid": "526a4a42a3176c20", | |
"secret": "c03d7087ff689a2614da92d0fd1d7209" | |
}, | |
{ | |
"kid": "75c4f26b0523671a", | |
"secret": "00dd57c3e5e11e2ffa712ae1c3b92975" | |
}, | |
{ | |
"kid": "0ad71a3488a35413", | |
"secret": "d65e6e875acdb9853938e207ae5b6b1d" | |
}, | |
{ | |
"kid": "3aaf0bbb2df29940", | |
"secret": "6610cde8bdd37797e1157d8d9ead98aa" | |
}, | |
{ | |
"kid": "21fb44192d099120", | |
"secret": "402b1fdc9e61d660284079c671c1ea80" | |
}, | |
{ | |
"kid": "3eb66d4f66f18f19", | |
"secret": "cae72eab831abfdaafbdf5e3c2594c79" | |
}, | |
{ | |
"kid": "575f84e13419a1ea", | |
"secret": "01f75f138622f2f516173b4dd23fccf2" | |
}, | |
{ | |
"kid": "0f6e61c98e0686fb", | |
"secret": "a8214cb934d92c16a01d2450f8faa8c2" | |
}, | |
{ | |
"kid": "122f409ed3a36cac", | |
"secret": "afd50cb4b12011c546cfc967d4d69542" | |
}, | |
{ | |
"kid": "4b741b34eea347b1", | |
"secret": "fd22beb0893614de51fd3a4f03568aaa" | |
}, | |
{ | |
"kid": "bc6eb4470a185778", | |
"secret": "81234c1872f800f5fe9158f30285e24e" | |
}, | |
{ | |
"kid": "5d13e2a0f964f97f", | |
"secret": "8154522057b6467f437a7740628e02c9" | |
}, | |
{ | |
"kid": "40b6fe5b715dd33b", | |
"secret": "74a17cf6e02122f1c0cfd9a33904d5d7" | |
}, | |
{ | |
"kid": "0e70a425c71f1abf", | |
"secret": "c695e86b38708f769c9b798764e20fe7" | |
}, | |
{ | |
"kid": "21d3bf36e0d1b9a4", | |
"secret": "cb93d1a05ac7b4ef13379d785810d492" | |
}, | |
{ | |
"kid": "bf9b28c1701f878d", | |
"secret": "c488f05bbecf422112fbfeba6c11a394" | |
}, | |
{ | |
"kid": "15d666659c1dc47c", | |
"secret": "45055bda6350faee97d22d3c9b53044a" | |
}, | |
{ | |
"kid": "149b26aa8c9a1d87", | |
"secret": "f116151400538f6f1e7f97d94f6575be" | |
}, | |
{ | |
"kid": "da105e6c784b753f", | |
"secret": "6e46ac69c266fee5c7f6e630ce8f6ee9" | |
}, | |
{ | |
"kid": "6ad44b8b3a7472e1", | |
"secret": "7772a80f882cfe4089f35fe7062e0d90" | |
}, | |
{ | |
"kid": "2817c957d885a716", | |
"secret": "9dcd303034bce2cabfd4e223da549f6c" | |
}, | |
{ | |
"kid": "d5463fc012ae82ae", | |
"secret": "90df68830414f0e2a44f7bc5adfd865f" | |
}, | |
{ | |
"kid": "d06deeefb69b09c2", | |
"secret": "98c56a905eba1f626c582a73df070ee3" | |
}, | |
{ | |
"kid": "1666cd41abe4c632", | |
"secret": "66b15809ab384fc8ba7f839c86512bb2" | |
}, | |
{ | |
"kid": "b624b9b977f1ce62", | |
"secret": "be05a92e01f2996691ea3214ada3ea13" | |
}, | |
{ | |
"kid": "e5b215a79cf117d7", | |
"secret": "6db1a7d359c1fb08d06d468d71162850" | |
}, | |
{ | |
"kid": "438d9de6f4d0840c", | |
"secret": "0f45109e221d20764d6da8db474c06a6" | |
}, | |
{ | |
"kid": "b4be7803745095b4", | |
"secret": "9bb38e75ebe6a1300bc5d9e8099533a4" | |
}, | |
{ | |
"kid": "50a2fcaaded04578", | |
"secret": "2d72140efbf51708909baad4584f5aed" | |
}, | |
{ | |
"kid": "a80ad063890fbbe4", | |
"secret": "646723e086b1fbfa13b4acfbf3ada903" | |
}, | |
{ | |
"kid": "e5c320cbb95fd963", | |
"secret": "196faa9534baf91250dbdbd8513a7dd1" | |
}, | |
{ | |
"kid": "94ce407ecd490736", | |
"secret": "210174214ba8ffa354abaef3a60f2ea1" | |
}, | |
{ | |
"kid": "30ba846a24fb0d80", | |
"secret": "bb14992ca86eaec42363d3a2b773552d" | |
}, | |
{ | |
"kid": "550e675f293f9ebb", | |
"secret": "fa5b51054ccfaaf2bd6fb10f9e05fb44" | |
}, | |
{ | |
"kid": "1650e439c7ee3546", | |
"secret": "8611b7948e2eb2bfe7c1526508cfc38f" | |
}, | |
{ | |
"kid": "3048a193042f8c20", | |
"secret": "670be87987df0c7169974476f4b9eae8" | |
}, | |
{ | |
"kid": "1a08e9a10e4e8e45", | |
"secret": "8b212c44946f51ac2d020c814d0d1751" | |
}, | |
{ | |
"kid": "e2f32d7883c6e791", | |
"secret": "6a196321e1f2726e3442796504485ce3" | |
}, | |
{ | |
"kid": "cf3631357a3118cc", | |
"secret": "5df060e8c91f1027f37578eafae1fd15" | |
}, | |
{ | |
"kid": "484cef9537153806", | |
"secret": "cf95bee63a0a676733e3290d5f1676d6" | |
}, | |
{ | |
"kid": "ecb61fb8c90de83f", | |
"secret": "1359eea1da9653137e7dd55c82f1725d" | |
}, | |
{ | |
"kid": "e7be376f307b8461", | |
"secret": "d8c6b628aad8ff6197dfed1247cc0ad1" | |
}, | |
{ | |
"kid": "8a949ee0eb8927e3", | |
"secret": "e1d8e0e020174917886c7ffcc41e1e97" | |
}, | |
{ | |
"kid": "a8fd872e9d57c5dc", | |
"secret": "b3dcc1467ba42a567f5c749d24bbb678" | |
}, | |
{ | |
"kid": "539c9aac9a1be259", | |
"secret": "9e8560de3f2773e736c29232ce5c4ed1" | |
}, | |
{ | |
"kid": "539c9aac9a1be259", | |
"secret": "9e8560de3f2773e736c29232ce5c4ed1" | |
} | |
]; | |
export default function () { | |
let user = data[__VU - 1]; | |
let payload = JSON.stringify(new Order()); | |
let nonce = String(Date.now); | |
let udata = nonce + user.kid; | |
let secret = user.secret; | |
let headers = { | |
"X-Auth-Apikey": user.kid, | |
"X-Auth-Nonce": nonce, | |
"X-Auth-Signature": hmac('sha256', secret, udata, 'hex') | |
}; | |
let r = http.post(`https://demo.terakube.com/api/v2/peatio/market/orders`, payload, { headers: headers }); | |
check(r, { | |
"is status 201": (r) => r.status === 201, | |
"is created": (r) => JSON.parse(r.body).hasOwnProperty('id') | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment