-
Notifications
You must be signed in to change notification settings - Fork 2
/
bp-stress-stage-1-random.js
60 lines (57 loc) · 1.71 KB
/
bp-stress-stage-1-random.js
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
59
60
import http from "k6/http";
import { check, sleep } from "k6";
export const options = {
scenarios: {
contacts: {
executor: "ramping-vus",
startVUs: 0,
stages: [
{ duration: "5m", target: 500 },
{ duration: "5m", target: 1000 },
{ duration: "5m", target: 2000 },
],
gracefulRampDown: "0s",
},
},
};
export default function () {
let response;
const url = "https://klaytn.testnet.blockpi.net/v1/rpc/<YOUR API KEY>";
const data = [
{
jsonrpc: "2.0",
method: "klay_blockNumber",
params: [],
id: 1,
},
{
jsonrpc: "2.0",
method: "klay_getTransactionReceipt",
params: [
"0x6ae45925355d3c0a589000579571de0c471900748f8344accb51a66211e6cc0f",
],
id: 1,
},
{
jsonrpc: "2.0",
method: "klay_getTransactionByBlockNumberAndIndex",
params: ["latest", "0x0"],
id: 1,
},
];
const randMethod = data[Math.floor(Math.random() * data.length)];
const headers = { headers: { "Content-Type": "application/json" },};
response = http.post(url, JSON.stringify(randMethod), headers);
check(response, { 'Is status = 200': (r) => r.status == 200 });
check(response, { 'Is status != 200': (r) => r.status != 200 });
check(response, {
'Is error = hypernode not found': (r) =>
r.body.includes('hypernode not found'),
});
check(response, {
'Is error = timeout': (r) =>
r.body.includes('timeout'),
});
//console.log(response);
sleep(1);
}