-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmutliple-clients.py
116 lines (96 loc) · 4.45 KB
/
mutliple-clients.py
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import time
import json
from locust import HttpUser, task, between
get_slot = {"jsonrpc":"2.0","id":1, "method":"getSlot"}
get_slot_leader = {"jsonrpc":"2.0","id":1, "method":"getSlotLeader"}
get_balance = {"jsonrpc":"2.0", "id":1, "method":"getBalance", "params":[]}
get_leader_schedule = {"jsonrpc":"2.0","id":1, "method":"getLeaderSchedule"}
get_vote_accounts = {"jsonrpc":"2.0","id":1, "method":"getVoteAccounts"}
get_stake_activation = {"jsonrpc":"2.0","id":1, "method":"getStakeActivation", "params": []}
get_cluster_nodes = {"jsonrpc":"2.0", "id":1, "method":"getClusterNodes"}
get_epoch_schedule = {"jsonrpc":"2.0","id":1, "method":"getEpochSchedule"}
get_epoch_info = {"jsonrpc":"2.0","id":1, "method":"getEpochInfo"}
get_largest_accounts = {"jsonrpc":"2.0","id":1, "method":"getLargestAccounts"}
get_confirmed_blocks = {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlocks","params":[]}
minimum_ledger_slot = {"jsonrpc":"2.0","id":1, "method":"minimumLedgerSlot"}
# A user of wallets
class WalletUser(HttpUser):
weight = 5 # wallet user 10x
wait_time = between(0.1,1)
@task(10)
def get_balance(self):
req = get_balance
req["params"] = [self.pubkey]
self.client.post('/', data=json.dumps(req), headers={'content-type': 'application/json'}, name='getBalance')
def on_start(self):
# @TODO randomise the wallet pubkey
self.pubkey = "83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri"
self.stake_account = "CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT"
# A validator
class ValidatorUser(HttpUser):
weight = 3
wait_time = between(0.1,1)
@task(10) #this is a really common task so give it higher weight
def get_slot(self):
req = get_slot
self.client.post('/', data=json.dumps(req), headers={'content-type': 'application/json'}, name='getSlot')
@task
def get_balance(self):
req = get_balance
req["params"] = [self.pubkey]
self.client.post('/', data=json.dumps(req), headers={'content-type': 'application/json'}, name='getBalance')
@task
def get_vote_accounts(self):
req = get_vote_accounts
self.client.post('/', data=json.dumps(req), headers={'content-type': 'application/json'}, name='getVoteAccounts')
@task
def get_stake_activation(self):
req = get_stake_activation
req["params"] = self.stake_account
self.client.post('/', data=json.dumps(req), headers={'content-type': 'application/json'}, name='getStakeActivation')
def on_start(self):
# @TODO we should randomise these from a list of options
self.pubkey = "7cVfgArCheMR6Cs4t6vz5rfnqd56vZq4ndaBrY5xkxXy"
self.vote_account = "7cVfgArCheMR6Cs4t6vz5rfnqd56vZq4ndaBrY5xkxXy"
self.stake_account = "CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT"
# An explorer a la solanabeach.io
class ExplorerUser(HttpUser):
weight = 1
wait_time = between(0.1,1)
@task
def get_slot(self):
req = get_slot
self.client.post('/', data=json.dumps(req), headers={'content-type': 'application/json'}, name='getSlot')
@task
def get_slot_leader(self):
req = get_slot_leader
self.client.post('/', data=json.dumps(req), headers={'content-type': 'application/json'}, name='getSlotLeader')
@task
def get_leader_schedule(self):
req = get_leader_schedule
self.client.post('/', data=json.dumps(req), headers={'content-type': 'application/json'}, name='getLeaderSchedule')
@task
def get_cluster_nodes(self):
req = get_cluster_nodes
self.client.post('/', data=json.dumps(req), headers={'content-type': 'application/json'}, name='getLeaderSchedule')
@task
def get_epoch_schedule(self):
req = get_epoch_schedule
self.client.post('/', data=json.dumps(req), headers={'content-type': 'application/json'}, name='getEpochSchedule')
@task
def get_epoch_info(self):
req = get_epoch_info
self.client.post('/', data=json.dumps(req), headers={'content-type': 'application/json'}, name='getEpochInfo')
@task
def get_largest_accounts(self):
req = get_largest_accounts
self.client.post('/', data=json.dumps(req), headers={'content-type': 'application/json'}, name='getLargestAccounts')
# @ todo load start slot end slot
def get_confirmed_blocks(self):
req = get_confirmed_blocks
req["params"] = [5,10]
self.client.post('/', data=json.dumps(req), headers={'content-type': 'application/json'}, name='getConfirmedBlocks')
@task
def minimum_ledger_slot(self):
req = minimum_ledger_slot
self.client.post('/', data=json.dumps(req), headers={'content-type': 'application/json'}, name='minimumLedgerSlot')