@cardano-sdk/e2e 0.36.5 → 0.36.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cardano-sdk/e2e",
3
- "version": "0.36.5",
3
+ "version": "0.36.6",
4
4
  "description": "End to end tests for the cardano-js-sdk packages.",
5
5
  "engines": {
6
6
  "node": ">=16.20.2"
@@ -81,20 +81,20 @@
81
81
  "dependencies": {
82
82
  "@cardano-foundation/ledgerjs-hw-app-cardano": "^7.1.2",
83
83
  "@cardano-ogmios/client": "6.3.0",
84
- "@cardano-sdk/cardano-services": "~0.28.10",
85
- "@cardano-sdk/cardano-services-client": "~0.19.10",
86
- "@cardano-sdk/core": "~0.35.0",
84
+ "@cardano-sdk/cardano-services": "~0.28.11",
85
+ "@cardano-sdk/cardano-services-client": "~0.19.11",
86
+ "@cardano-sdk/core": "~0.35.1",
87
87
  "@cardano-sdk/crypto": "~0.1.25",
88
- "@cardano-sdk/hardware-ledger": "~0.9.11",
89
- "@cardano-sdk/hardware-trezor": "~0.4.31",
90
- "@cardano-sdk/input-selection": "~0.13.4",
91
- "@cardano-sdk/key-management": "~0.20.9",
92
- "@cardano-sdk/ogmios": "~0.15.31",
93
- "@cardano-sdk/tx-construction": "~0.19.4",
88
+ "@cardano-sdk/hardware-ledger": "~0.9.12",
89
+ "@cardano-sdk/hardware-trezor": "~0.4.32",
90
+ "@cardano-sdk/input-selection": "~0.13.5",
91
+ "@cardano-sdk/key-management": "~0.20.10",
92
+ "@cardano-sdk/ogmios": "~0.15.32",
93
+ "@cardano-sdk/tx-construction": "~0.19.5",
94
94
  "@cardano-sdk/util": "~0.15.2",
95
- "@cardano-sdk/util-dev": "~0.21.4",
95
+ "@cardano-sdk/util-dev": "~0.21.5",
96
96
  "@cardano-sdk/util-rxjs": "~0.7.18",
97
- "@cardano-sdk/wallet": "~0.38.5",
97
+ "@cardano-sdk/wallet": "~0.38.6",
98
98
  "@dcspark/cardano-multiplatform-lib-nodejs": "^3.1.1",
99
99
  "@vespaiach/axios-fetch-adapter": "^0.3.0",
100
100
  "axios": "^0.28.0",
@@ -124,10 +124,10 @@
124
124
  "@babel/core": "^7.18.2",
125
125
  "@babel/preset-env": "^7.18.2",
126
126
  "@babel/preset-typescript": "^7.17.12",
127
- "@cardano-sdk/dapp-connector": "~0.12.22",
128
- "@cardano-sdk/projection": "~0.11.21",
129
- "@cardano-sdk/projection-typeorm": "~0.8.23",
130
- "@cardano-sdk/web-extension": "~0.29.5",
127
+ "@cardano-sdk/dapp-connector": "~0.12.23",
128
+ "@cardano-sdk/projection": "~0.11.22",
129
+ "@cardano-sdk/projection-typeorm": "~0.8.24",
130
+ "@cardano-sdk/web-extension": "~0.29.6",
131
131
  "@dcspark/cardano-multiplatform-lib-browser": "^3.1.1",
132
132
  "@emurgo/cardano-message-signing-asmjs": "^1.0.1",
133
133
  "@types/bunyan": "^1.8.8",
@@ -181,5 +181,5 @@
181
181
  "webpack-cli": "^4.9.2",
182
182
  "webpack-merge": "^5.8.0"
183
183
  },
184
- "gitHead": "f40478db084cb7692f95f99635ab7038eb398df3"
184
+ "gitHead": "56a83cdd04d017353fe9cfd402b293c6845fdcad"
185
185
  }
@@ -1,7 +1,9 @@
1
1
  /* eslint-disable no-console */
2
2
  /* eslint-disable func-style */
3
3
  import { Counter, Trend } from 'k6/metrics';
4
+ import { SharedArray } from 'k6/data';
4
5
  import { check, sleep } from 'k6';
6
+ import { apiVersion } from '../../../../cardano-services-client/src/version.ts';
5
7
  import http from 'k6/http';
6
8
 
7
9
  /**
@@ -34,20 +36,28 @@ const RunMode = {
34
36
  RestoreHD: 'RestoreHD'
35
37
  };
36
38
  /** Determines run mode: Restore or Onboard */
37
- const RUN_MODE = RunMode.Restore;
39
+ const RUN_MODE = __ENV.RUN_MODE || RunMode.Restore;
38
40
 
39
41
  // eslint-disable-next-line no-undef
40
42
  const PROVIDER_SERVER_URL = __ENV.PROVIDER_SERVER_URL;
41
43
 
42
- /** URL of the JSON file containing the wallets */
43
- const WALLET_ADDRESSES_URL =
44
- RUN_MODE === RunMode.Onboard
45
- ? 'https://raw.githubusercontent.com/input-output-hk/cardano-js-sdk/master/packages/e2e/test/dump/addresses/no-history-mainnet.json'
46
- : 'https://raw.githubusercontent.com/input-output-hk/cardano-js-sdk/master/packages/e2e/test/dump/addresses/mainnet.json';
44
+ /** Wallet addresses extracted from the JSON dump file */
45
+ const walletsOrig = new SharedArray('walletsData', function () {
46
+ const network = __ENV.TARGET_ENV == 'dev-mainnet' ? 'mainnet' : 'preprod';
47
+ const fileName = RUN_MODE === RunMode.Onboard ? `no-history-${network}.json` : `${network}.json`;
48
+ console.log(`Reading wallet addresses from ${fileName}`);
49
+ const walletAddresses = JSON.parse(open('../../dump/addresses/' + fileName));
50
+ return walletAddresses;
51
+ });
47
52
 
48
- /** URL of the JSON file containing the stake pool addresses */
49
- const POOL_ADDRESSES_URL =
50
- 'https://raw.githubusercontent.com/input-output-hk/cardano-js-sdk/master/packages/e2e/test/dump/pool_addresses/mainnet.json';
53
+
54
+ /** Stake pool addresses from the JSON dump file */
55
+ const poolAddresses = new SharedArray('poolsData', function () {
56
+ // There is no dump of preprod pools, but it is ok. Pool address is used only in "Restore" mode
57
+ // and it is used to do a stake pool search call, so any pool will do
58
+ const pools = JSON.parse(open('../../dump/pool_addresses/mainnet.json'));
59
+ return pools;
60
+ });
51
61
 
52
62
  /**
53
63
  * Define the maximum number of virtual users to simulate
@@ -55,12 +65,12 @@ const POOL_ADDRESSES_URL =
55
65
  * For this reason, it's a good practice to configure MAX_VUs in multiples of 100 in order to maintain the desired distribution.
56
66
  * In `RunMode.RestoreHD`, each VU will have multiple addresses.
57
67
  */
58
- const MAX_VU = 10;
68
+ const MAX_VU = __ENV.MAX_VU || 1;
59
69
 
60
70
  /** Time span during which all virtual users are started in a linear fashion */
61
- const RAMP_UP_DURATION = '10s';
71
+ const RAMP_UP_DURATION = __ENV.RAMP_UP_DURATION || '1s';
62
72
  /** Time span during which synced wallets do tip queries */
63
- const STEADY_STATE_DURATION = '20s';
73
+ const STEADY_STATE_DURATION = __ENV.STEADY_STATE_DURATION || '2s';
64
74
 
65
75
  /** Time to sleep between iterations. Simulates polling tip to keep wallet in sync */
66
76
  const ITERATION_SLEEP = 5;
@@ -68,9 +78,9 @@ const ITERATION_SLEEP = 5;
68
78
  /** HD wallet discovery. Used when RunMode is `RestoreHD` */
69
79
  const hdWalletParams = {
70
80
  /** HD wallet size. The number of addresses with transaction history per wallet. They are queried at discover time. */
71
- activeAddrCount: 10,
81
+ activeAddrCount: __ENV.HD_ACTIVE_ADDR_COUNT || 1,
72
82
  /** Use only addresses with a transaction history up to this value */
73
- maxTxHistory: 100,
83
+ maxTxHistory: __ENV.HD_MAX_TX_HISTORY || 1,
74
84
  /** number of payment addresses to search for. It will search both internal and external address, thus multiplied by 2 */
75
85
  paymentAddrSearchGap: 20 * 2,
76
86
  /** number of stake keys to search for. It will search both internal and external address, thus multiplied by 2 */
@@ -95,10 +105,7 @@ const chunkArray = (array, chunkSize) => {
95
105
  return chunked;
96
106
  };
97
107
 
98
- /**
99
- * Grab the wallets json file to be used by the scenario.
100
- * Group the addresses per wallet (single address or HD wallets).
101
- */
108
+ /** Grab the wallets json file to be used by the scenario. Group the addresses per wallet (single address or HD wallets). */
102
109
  export function setup() {
103
110
  console.log(`Running in ${RUN_MODE} mode`);
104
111
  console.log(`Ramp-up: ${RAMP_UP_DURATION}; Sustain: ${STEADY_STATE_DURATION}; Iteration sleep: ${ITERATION_SLEEP}s`);
@@ -107,12 +114,6 @@ export function setup() {
107
114
  console.log('HD wallet params are:', hdWalletParams);
108
115
  }
109
116
 
110
- // This call will be part of the statistics. There is no way around it so far: https://github.com/grafana/k6/issues/1321
111
- const res = http.batch([WALLET_ADDRESSES_URL, POOL_ADDRESSES_URL]);
112
- check(res, { 'get wallets and pools files': (r) => r.every(({ status }) => status >= 200 && status < 300) });
113
-
114
- const [{ body: resBodyWallets }, { body: resBodyPools }] = res;
115
- const walletsOrig = JSON.parse(resBodyWallets);
116
117
  const walletsOrigCount = walletsOrig ? walletsOrig.length : 0;
117
118
  check(walletsOrigCount, {
118
119
  'At least one wallet is required to run the test': (count) => count > 0
@@ -138,7 +139,6 @@ export function setup() {
138
139
  );
139
140
  }
140
141
 
141
- const poolAddresses = JSON.parse(resBodyPools);
142
142
  check(poolAddresses, {
143
143
  'At least one stake pool address is required to run the test': (p) => p && p.length > 0
144
144
  });
@@ -178,9 +178,9 @@ export const options = {
178
178
  };
179
179
 
180
180
  /** Util functions for sending the http post requests to cardano-sdk services */
181
- const cardanoHttpPost = (url, body = {}) => {
181
+ const cardanoHttpPost = (url, apiVer, body = {}) => {
182
182
  const opts = { headers: { 'content-type': 'application/json' } };
183
- return http.post(`${PROVIDER_SERVER_URL}/${url}`, JSON.stringify(body), opts);
183
+ return http.post(`${PROVIDER_SERVER_URL}/v${apiVer}/${url}`, JSON.stringify(body), opts);
184
184
  };
185
185
 
186
186
  /**
@@ -196,7 +196,7 @@ const txsByAddress = (addresses, takeOne = false, pageSize = 25) => {
196
196
  let txCount = 0;
197
197
 
198
198
  do {
199
- const resp = cardanoHttpPost('chain-history/txs/by-addresses', {
199
+ const resp = cardanoHttpPost('chain-history/txs/by-addresses', apiVersion.chainHistory, {
200
200
  addresses: chunk,
201
201
  blockRange: { lowerBound: { __type: 'undefined' } },
202
202
  pagination: { limit: pageSize, startAt }
@@ -218,13 +218,14 @@ const txsByAddress = (addresses, takeOne = false, pageSize = 25) => {
218
218
  const utxosByAddresses = (addresses) => {
219
219
  const addressChunks = chunkArray(addresses, 25);
220
220
  for (const chunk of addressChunks) {
221
- cardanoHttpPost('utxo/utxo-by-addresses', { addresses: chunk });
221
+ cardanoHttpPost('utxo/utxo-by-addresses', apiVersion.utxo, { addresses: chunk });
222
222
  }
223
223
  };
224
224
 
225
- const rewardsAccBalance = (rewardAccount) => cardanoHttpPost('rewards/account-balance', { rewardAccount });
225
+ const rewardsAccBalance = (rewardAccount) =>
226
+ cardanoHttpPost('rewards/account-balance', apiVersion.rewards, { rewardAccount });
226
227
  const stakePoolSearch = (poolAddress) =>
227
- cardanoHttpPost('stake-pool/search', {
228
+ cardanoHttpPost('stake-pool/search', apiVersion.stakePool, {
228
229
  filters: { identifier: { values: [{ id: poolAddress }] } },
229
230
  pagination: { limit: 1, startAt: 0 }
230
231
  });
@@ -240,10 +241,7 @@ const getDummyAddr = (addr, idx, suffix = 'mh') => {
240
241
  return addr.slice(0, -3) + updateChars;
241
242
  };
242
243
 
243
- /**
244
- * Simulate http requests normally done in discovery mode.
245
- * `wallet` MUST have at least 2 elements
246
- */
244
+ /** Simulate http requests normally done in discovery mode. `wallet` MUST have at least 2 elements */
247
245
  const walletDiscovery = (wallet) => {
248
246
  check(wallet, {
249
247
  'At least one address is required to run HD wallet discovery mode': (walletArray) =>
@@ -284,22 +282,22 @@ const syncWallet = ({ wallet, poolAddress }) => {
284
282
  walletDiscovery(wallet);
285
283
  }
286
284
 
287
- cardanoHttpPost('network-info/era-summaries');
288
- cardanoHttpPost(TIP_URL);
285
+ cardanoHttpPost('network-info/era-summaries', apiVersion.networkInfo);
286
+ cardanoHttpPost(TIP_URL, apiVersion.networkInfo);
289
287
  txsByAddress(addresses);
290
288
  utxosByAddresses(addresses);
291
- cardanoHttpPost('network-info/era-summaries');
292
- cardanoHttpPost('network-info/genesis-parameters');
293
- cardanoHttpPost('network-info/protocol-parameters');
289
+ cardanoHttpPost('network-info/era-summaries', apiVersion.networkInfo);
290
+ cardanoHttpPost('network-info/genesis-parameters', apiVersion.networkInfo);
291
+ cardanoHttpPost('network-info/protocol-parameters', apiVersion.networkInfo);
294
292
  // Test restoring HD wallets with a single stake key
295
293
  rewardsAccBalance(wallet[0].stake_address);
296
- cardanoHttpPost(TIP_URL);
297
- cardanoHttpPost('network-info/lovelace-supply');
298
- cardanoHttpPost('network-info/stake');
294
+ cardanoHttpPost(TIP_URL, apiVersion.networkInfo);
295
+ cardanoHttpPost('network-info/lovelace-supply', apiVersion.networkInfo);
296
+ cardanoHttpPost('network-info/stake', apiVersion.networkInfo);
299
297
  if (RUN_MODE === RunMode.Restore) {
300
298
  stakePoolSearch(poolAddress);
301
299
  }
302
- cardanoHttpPost('stake-pool/stats');
300
+ cardanoHttpPost('stake-pool/stats', apiVersion.stakePool);
303
301
 
304
302
  // Consider the wallet synced by tracking its first address
305
303
  syncedWallets.add(addresses[0]);
@@ -307,11 +305,8 @@ const syncWallet = ({ wallet, poolAddress }) => {
307
305
  walletSyncCount.add(1);
308
306
  };
309
307
 
310
- /**
311
- * Simulate keeping wallet in sync
312
- * For now, just polling the tip
313
- */
314
- const emulateIdleClient = () => cardanoHttpPost(TIP_URL);
308
+ /** Simulate keeping wallet in sync For now, just polling the tip */
309
+ const emulateIdleClient = () => cardanoHttpPost(TIP_URL, apiVersion.networkInfo);
315
310
 
316
311
  /**
317
312
  * K6 default VU action function
@@ -1,219 +0,0 @@
1
- /* eslint-disable no-console */
2
- /* eslint-disable func-style */
3
- import { Counter, Trend } from 'k6/metrics';
4
- import { check, sleep } from 'k6';
5
- import http from 'k6/http';
6
-
7
- /**
8
- * Script overall description:
9
- * One wallet == one VU
10
- * Configure RUN_MODE to have the test run with empty wallets (onboarding) or wallets with history (restoring)
11
- * Configure MAX_VU: number of wallets to be synced (e.g. 100 wallets)
12
- * Setup RAMP_UP_DURATION: ramp-up time to synced these wallets (e.g. 30s)
13
- * - During this time, wallets start evenly distributed (e.g. ~3 wallets every second)
14
- * Each wallet performs as many iterations as possible
15
- * - 1st iteration: restoration steps .
16
- * - Subsequent iterations will only query the tip
17
- * ITERATION_SLEEP: Every iteration has a sleep of to simulate Lace tip polling interval
18
- * During the STEADY_STATE_DURATION:
19
- * - Synced wallets do tip queries.
20
- * - Wallets not synced yet will wait for restoration to complete, then will also start tip queries
21
- * No ramp-down is needed. We can simply stop the test as there is no point in sending fewer and fewer tip queries during ramp-down.
22
- * wallet_sync: is a custom trend metric measuring the trend of wallet sync calls.
23
- * wallet_sync_count: is a custom count metric measuring the number of wallets that were successfully synced.
24
- */
25
-
26
- const RunMode = {
27
- Onboard: 'Onboard',
28
- Restore: 'Restore'
29
- };
30
- /** Determines run mode: Restore or Onboard */
31
- const RUN_MODE = RunMode.Onboard;
32
-
33
- /**
34
- * True: Keep spinning on the restoring part
35
- * False: Once restored, just loop over ledger tip
36
- */
37
- const SPIN_ON_NEW_WALLETS = true;
38
-
39
- // eslint-disable-next-line no-undef
40
- const PROVIDER_SERVER_URL = __ENV.PROVIDER_SERVER_URL;
41
-
42
- /** URL of the JSON file containing the wallets */
43
- const WALLET_ADDRESSES_URL =
44
- RUN_MODE === RunMode.Restore
45
- ? 'https://raw.githubusercontent.com/input-output-hk/cardano-js-sdk/master/packages/e2e/test/dump/addresses/mainnet.json'
46
- : 'https://raw.githubusercontent.com/input-output-hk/cardano-js-sdk/master/packages/e2e/test/dump/addresses/no-history-mainnet.json';
47
-
48
- /** URL of the JSON file containing the stake pool addresses */
49
- const POOL_ADDRESSES_URL =
50
- 'https://raw.githubusercontent.com/input-output-hk/cardano-js-sdk/master/packages/e2e/test/dump/pool_addresses/mainnet.json';
51
-
52
- /**
53
- * Define the maximum number of virtual users to simulate
54
- * The mainnet.json file contains wallets in chunks of 100, each chunk having the required distribution
55
- * For this reason, it's a good practice to configure MAX_VUs in multiples of 100 in order to maintain the desired distribution
56
- */
57
- const MAX_VU = 1;
58
-
59
- /** Time span during which all virtual users are started in a linear fashion */
60
- const RAMP_UP_DURATION = '10s';
61
- /** Time span during which synced wallets do tip queries */
62
- const STEADY_STATE_DURATION = '1m';
63
-
64
- /** Time to sleep between iterations. Simulates polling tip to keep wallet in sync */
65
- const ITERATION_SLEEP = 5;
66
-
67
- /** Custom trend statistic to measure trend to sync wallets */
68
- const walletSyncTrend = new Trend('wallet_sync', true);
69
- /** Custom count statistic to measure how many wallets were successfully syncd */
70
- const walletSyncCount = new Counter('wallet_sync_count');
71
-
72
- /** Repetitive entpoints */
73
- const TIP_URL = 'network-info/ledger-tip';
74
-
75
- /** Grab the wallets json file to be used by the scenario */
76
- export function setup() {
77
- console.log(`Running in ${RUN_MODE} mode`);
78
- // This call will be part of the statistics. There is no way around it so far: https://github.com/grafana/k6/issues/1321
79
- const res = http.batch([WALLET_ADDRESSES_URL, POOL_ADDRESSES_URL]);
80
- check(res, { 'get wallets and pools files': (r) => r.every(({ status }) => status >= 200 && status < 300) });
81
-
82
- const [{ body: resBodyWallets }, { body: resBodyPools }] = res;
83
- const wallets = JSON.parse(resBodyWallets);
84
- const walletCount = wallets ? wallets.length : 0;
85
- check(walletCount, {
86
- 'At least one wallet is required to run the test': (count) => count > 0
87
- });
88
- console.log(`Wallet addresses configuration file contains ${walletCount} wallets`);
89
- if (walletCount < MAX_VU) {
90
- console.warn(
91
- `Requested VU count: (${MAX_VU}), is greater than the available walled addresses: ${walletCount}. Some addresses will be reused`
92
- );
93
- }
94
-
95
- const poolAddresses = JSON.parse(resBodyPools);
96
- check(poolAddresses, {
97
- 'At least one stake pool address is required to run the test': (p) => p && p.length > 0
98
- });
99
- return { poolAddresses, wallets: wallets.slice(0, MAX_VU) };
100
- }
101
-
102
- /** Keeps track of wallets that were successfully syncd to avoid restoring twice */
103
- const syncedWallets = new Set();
104
-
105
- export const options = {
106
- ext: {
107
- loadimpact: {
108
- apm: [],
109
- distribution: { 'amazon:us:portland': { loadZone: 'amazon:us:portland', percent: 100 } }
110
- }
111
- },
112
- scenarios: {
113
- SyncDifferentSizeWallets: {
114
- executor: 'ramping-vus',
115
- gracefulRampDown: '0s',
116
- gracefulStop: '0s',
117
- stages: [
118
- { duration: RAMP_UP_DURATION, target: MAX_VU },
119
- { duration: STEADY_STATE_DURATION, target: MAX_VU }
120
- ],
121
- startVUs: 1
122
- }
123
- },
124
- thresholds: {
125
- // All wallets should have syncd
126
- // Use https://k6.io/docs/using-k6/thresholds/ to set more thresholds. E.g.:
127
- // wallet_sync: ['p(95)<5000'], // 95% of wallets should sync in under 5 seconds
128
- wallet_sync: [{ delayAbortEval: '5s', threshold: 'p(95) < 30000' }],
129
-
130
- wallet_sync_count: [`count >= ${MAX_VU}`] // We get a nice graph if we enable thresholds. See this stat on a graph
131
- }
132
- };
133
-
134
- /** Util functions for sending the http post requests to cardano-sdk services */
135
- const cardanoHttpPost = (url, body = {}) => {
136
- const opts = { headers: { 'content-type': 'application/json' } };
137
- return http.post(`${PROVIDER_SERVER_URL}/${url}`, JSON.stringify(body), opts);
138
- };
139
- const txsByAddress = (address) => {
140
- let startAt = 0;
141
- const pageSize = 25;
142
- let txCount = 0;
143
- do {
144
- const resp = cardanoHttpPost('chain-history/txs/by-addresses', {
145
- addresses: [address],
146
- blockRange: { lowerBound: { __type: 'undefined' } },
147
- pagination: { limit: pageSize, startAt }
148
- });
149
-
150
- if (resp.status !== 200) {
151
- // No point in trying to get the other pages.
152
- // Should we log this? it will show up as if the restoration was quicker since this wallet did not fetch all the pages
153
- break;
154
- }
155
-
156
- const { pageResults } = JSON.parse(resp.body);
157
- startAt += pageSize;
158
- txCount = pageResults.length;
159
- } while (txCount === pageSize);
160
- };
161
- const utxosByAddresses = (address) => cardanoHttpPost('utxo/utxo-by-addresses', { addresses: [address] });
162
- const rewardsAccBalance = (rewardAccount) => cardanoHttpPost('rewards/account-balance', { rewardAccount });
163
- const stakePoolSearch = (poolAddress) =>
164
- cardanoHttpPost('stake-pool/search', {
165
- filters: { identifier: { values: [{ id: poolAddress }] } },
166
- pagination: { limit: 1, startAt: 0 }
167
- });
168
-
169
- /** Simulation of requests performed by a wallet while restoring */
170
- const syncWallet = ({ wallet, poolAddress }) => {
171
- const startTime = Date.now();
172
- const { address, stake_address: rewardAccount } = wallet;
173
- cardanoHttpPost('network-info/era-summaries');
174
- cardanoHttpPost(TIP_URL);
175
- txsByAddress(address);
176
- utxosByAddresses(address);
177
- cardanoHttpPost('network-info/era-summaries');
178
- cardanoHttpPost('network-info/genesis-parameters');
179
- cardanoHttpPost('network-info/protocol-parameters');
180
- rewardsAccBalance(rewardAccount);
181
- cardanoHttpPost(TIP_URL);
182
- cardanoHttpPost('network-info/lovelace-supply');
183
- cardanoHttpPost('network-info/stake');
184
- if (RUN_MODE === RunMode.Restore) {
185
- stakePoolSearch(poolAddress);
186
- }
187
- cardanoHttpPost('stake-pool/stats');
188
-
189
- syncedWallets.add(address);
190
- walletSyncTrend.add(Date.now() - startTime);
191
- walletSyncCount.add(1);
192
- };
193
-
194
- function getRandomInt(max) {
195
- return Math.floor(Math.random() * max);
196
- }
197
-
198
- /**
199
- * Simulate keeping wallet in sync
200
- * For now, just polling the tip
201
- */
202
- const emulateIdleClient = () => cardanoHttpPost(TIP_URL);
203
-
204
- export default function ({ wallets, poolAddresses }) {
205
- // Pick a new wallet or reuse the same one?
206
- // eslint-disable-next-line no-undef
207
- const walletIdx = SPIN_ON_NEW_WALLETS ? getRandomInt(wallets.length) : __VU;
208
-
209
- // Get the wallet for the current virtual user
210
- const wallet = wallets[walletIdx % wallets.length];
211
- const poolAddress = poolAddresses[walletIdx % poolAddresses.length];
212
-
213
- if (SPIN_ON_NEW_WALLETS || !syncedWallets.has(wallet.address)) {
214
- syncWallet({ poolAddress, wallet });
215
- } else {
216
- emulateIdleClient();
217
- sleep(ITERATION_SLEEP);
218
- }
219
- }