@cardano-sdk/e2e 0.14.0 → 0.14.2

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.
Files changed (119) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/factories.d.ts +3 -2
  3. package/dist/cjs/factories.d.ts.map +1 -1
  4. package/dist/cjs/factories.js +0 -1
  5. package/dist/cjs/factories.js.map +1 -1
  6. package/dist/cjs/scripts/mnemonic.js +2 -2
  7. package/dist/cjs/scripts/mnemonic.js.map +1 -1
  8. package/dist/cjs/tools/multi-delegation-data-gen/index.d.ts +2 -0
  9. package/dist/cjs/tools/multi-delegation-data-gen/index.d.ts.map +1 -0
  10. package/dist/cjs/tools/multi-delegation-data-gen/index.js +64 -0
  11. package/dist/cjs/tools/multi-delegation-data-gen/index.js.map +1 -0
  12. package/dist/cjs/tools/multi-delegation-data-gen/utils/config.d.ts +40 -0
  13. package/dist/cjs/tools/multi-delegation-data-gen/utils/config.d.ts.map +1 -0
  14. package/dist/cjs/tools/multi-delegation-data-gen/utils/config.js +110 -0
  15. package/dist/cjs/tools/multi-delegation-data-gen/utils/config.js.map +1 -0
  16. package/dist/cjs/tools/multi-delegation-data-gen/utils/files.d.ts +12 -0
  17. package/dist/cjs/tools/multi-delegation-data-gen/utils/files.d.ts.map +1 -0
  18. package/dist/cjs/tools/multi-delegation-data-gen/utils/files.js +66 -0
  19. package/dist/cjs/tools/multi-delegation-data-gen/utils/files.js.map +1 -0
  20. package/dist/cjs/tools/multi-delegation-data-gen/utils/index.d.ts +5 -0
  21. package/dist/cjs/tools/multi-delegation-data-gen/utils/index.d.ts.map +1 -0
  22. package/dist/cjs/tools/multi-delegation-data-gen/utils/index.js +21 -0
  23. package/dist/cjs/tools/multi-delegation-data-gen/utils/index.js.map +1 -0
  24. package/dist/cjs/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.d.ts +19 -0
  25. package/dist/cjs/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.d.ts.map +1 -0
  26. package/dist/cjs/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.js +107 -0
  27. package/dist/cjs/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.js.map +1 -0
  28. package/dist/cjs/tools/multi-delegation-data-gen/utils/utils.d.ts +46 -0
  29. package/dist/cjs/tools/multi-delegation-data-gen/utils/utils.d.ts.map +1 -0
  30. package/dist/cjs/tools/multi-delegation-data-gen/utils/utils.js +172 -0
  31. package/dist/cjs/tools/multi-delegation-data-gen/utils/utils.js.map +1 -0
  32. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  33. package/dist/cjs/util/index.d.ts +1 -0
  34. package/dist/cjs/util/index.d.ts.map +1 -1
  35. package/dist/cjs/util/index.js +1 -0
  36. package/dist/cjs/util/index.js.map +1 -1
  37. package/dist/cjs/util/util.d.ts +40 -0
  38. package/dist/cjs/util/util.d.ts.map +1 -0
  39. package/dist/cjs/util/util.js +171 -0
  40. package/dist/cjs/util/util.js.map +1 -0
  41. package/dist/esm/factories.d.ts +3 -2
  42. package/dist/esm/factories.d.ts.map +1 -1
  43. package/dist/esm/factories.js +0 -1
  44. package/dist/esm/factories.js.map +1 -1
  45. package/dist/esm/scripts/mnemonic.js +1 -1
  46. package/dist/esm/scripts/mnemonic.js.map +1 -1
  47. package/dist/esm/tools/multi-delegation-data-gen/index.d.ts +2 -0
  48. package/dist/esm/tools/multi-delegation-data-gen/index.d.ts.map +1 -0
  49. package/dist/esm/tools/multi-delegation-data-gen/index.js +59 -0
  50. package/dist/esm/tools/multi-delegation-data-gen/index.js.map +1 -0
  51. package/dist/esm/tools/multi-delegation-data-gen/utils/config.d.ts +40 -0
  52. package/dist/esm/tools/multi-delegation-data-gen/utils/config.d.ts.map +1 -0
  53. package/dist/esm/tools/multi-delegation-data-gen/utils/config.js +104 -0
  54. package/dist/esm/tools/multi-delegation-data-gen/utils/config.js.map +1 -0
  55. package/dist/esm/tools/multi-delegation-data-gen/utils/files.d.ts +12 -0
  56. package/dist/esm/tools/multi-delegation-data-gen/utils/files.d.ts.map +1 -0
  57. package/dist/esm/tools/multi-delegation-data-gen/utils/files.js +37 -0
  58. package/dist/esm/tools/multi-delegation-data-gen/utils/files.js.map +1 -0
  59. package/dist/esm/tools/multi-delegation-data-gen/utils/index.d.ts +5 -0
  60. package/dist/esm/tools/multi-delegation-data-gen/utils/index.d.ts.map +1 -0
  61. package/dist/esm/tools/multi-delegation-data-gen/utils/index.js +5 -0
  62. package/dist/esm/tools/multi-delegation-data-gen/utils/index.js.map +1 -0
  63. package/dist/esm/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.d.ts +19 -0
  64. package/dist/esm/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.d.ts.map +1 -0
  65. package/dist/esm/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.js +100 -0
  66. package/dist/esm/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.js.map +1 -0
  67. package/dist/esm/tools/multi-delegation-data-gen/utils/utils.d.ts +46 -0
  68. package/dist/esm/tools/multi-delegation-data-gen/utils/utils.d.ts.map +1 -0
  69. package/dist/esm/tools/multi-delegation-data-gen/utils/utils.js +153 -0
  70. package/dist/esm/tools/multi-delegation-data-gen/utils/utils.js.map +1 -0
  71. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  72. package/dist/esm/util/index.d.ts +1 -0
  73. package/dist/esm/util/index.d.ts.map +1 -1
  74. package/dist/esm/util/index.js +1 -0
  75. package/dist/esm/util/index.js.map +1 -1
  76. package/dist/esm/util/util.d.ts +40 -0
  77. package/dist/esm/util/util.d.ts.map +1 -0
  78. package/dist/esm/util/util.js +127 -0
  79. package/dist/esm/util/util.js.map +1 -0
  80. package/docker-compose.yml +3 -0
  81. package/local-network/README.md +1 -1
  82. package/local-network/scripts/make-babbage.sh +3 -1
  83. package/local-network/scripts/mint-handles.sh +52 -0
  84. package/local-network/scripts/mint-tokens.sh +1 -1
  85. package/local-network/scripts/start.sh +2 -0
  86. package/package.json +27 -18
  87. package/src/factories.ts +2 -3
  88. package/src/scripts/mnemonic.ts +1 -1
  89. package/src/tools/multi-delegation-data-gen/example.json +31 -0
  90. package/src/tools/multi-delegation-data-gen/index.ts +110 -0
  91. package/src/tools/multi-delegation-data-gen/utils/config.ts +112 -0
  92. package/src/tools/multi-delegation-data-gen/utils/files.ts +73 -0
  93. package/src/tools/multi-delegation-data-gen/utils/index.ts +4 -0
  94. package/src/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.ts +147 -0
  95. package/src/tools/multi-delegation-data-gen/utils/utils.ts +416 -0
  96. package/src/util/index.ts +1 -0
  97. package/{test → src/util}/util.ts +4 -20
  98. package/test/artillery/wallet-restoration/WalletRestoration.ts +11 -3
  99. package/test/load-test-custom/wallet-init/wallet-init.test.ts +1 -1
  100. package/test/load-test-custom/wallet-restoration/wallet-restoration.test.ts +3 -3
  101. package/test/load-testing/tx-submit-load.test.ts +1 -2
  102. package/test/local-network/register-pool.test.ts +10 -2
  103. package/test/long-running/cache-invalidation.test.ts +7 -3
  104. package/test/long-running/delegation-rewards.test.ts +7 -4
  105. package/test/util.test.ts +1 -1
  106. package/test/wallet/PersonalWallet/byron.test.ts +1 -2
  107. package/test/wallet/PersonalWallet/delegation.test.ts +10 -2
  108. package/test/wallet/PersonalWallet/delegationDistribution.test.ts +3 -15
  109. package/test/wallet/PersonalWallet/handle.test.ts +10 -2
  110. package/test/wallet/PersonalWallet/metadata.test.ts +1 -2
  111. package/test/wallet/PersonalWallet/mint.test.ts +9 -2
  112. package/test/wallet/PersonalWallet/multiAddress.test.ts +16 -2
  113. package/test/wallet/PersonalWallet/multisignature.test.ts +9 -2
  114. package/test/wallet/PersonalWallet/nft.test.ts +10 -2
  115. package/test/wallet/PersonalWallet/phase2validation.test.ts +1 -2
  116. package/test/wallet/PersonalWallet/pouchDbWalletStores.test.ts +1 -2
  117. package/test/wallet/PersonalWallet/txChainHistory.test.ts +1 -2
  118. package/test/wallet/PersonalWallet/txChaining.test.ts +1 -2
  119. package/test/wallet/PersonalWallet/unspendableUtxos.test.ts +1 -2
@@ -0,0 +1,112 @@
1
+ import convict from 'convict';
2
+ import dotenv from 'dotenv';
3
+ import path from 'path';
4
+
5
+ dotenv.config({ path: path.join(__dirname, '../../../../.env') });
6
+
7
+ convict.addFormat({
8
+ coerce: (val) => Number.parseInt(val, 10),
9
+ name: 'number',
10
+ validate(val) {
11
+ if (Number.isNaN(Number.parseInt(val)) || !Number.isInteger(val) || val < 0) {
12
+ throw new TypeError('Must be a positive integer value');
13
+ }
14
+ }
15
+ });
16
+
17
+ convict.addFormat({
18
+ name: 'weights',
19
+ validate(values) {
20
+ for (const val of values) {
21
+ if (Number.isNaN(Number.parseFloat(val)) || val < 0) throw new TypeError('Weights must be positive numbers');
22
+ }
23
+ }
24
+ });
25
+
26
+ export type ValueTransferConfig = {
27
+ amount: { max: number; min: number };
28
+ count: { max: number; min: number };
29
+ period: number;
30
+ };
31
+
32
+ export const configLoader = convict({
33
+ iterations: {
34
+ default: 10,
35
+ doc: 'How many iterations will be executed before stopping the test.',
36
+ format: 'number'
37
+ },
38
+ stakeDistribution: {
39
+ default: [1], // 100 % to the first stake index.
40
+ doc: 'The distribution of stake between stake indices. This distribution is expressed in weights',
41
+ format: 'weights',
42
+ nullable: false
43
+ },
44
+ startingFunds: {
45
+ default: 1_000_000_000, // 1000 ADA
46
+ doc: 'Starting funds of the newly created wallet.',
47
+ format: 'number',
48
+ nullable: false
49
+ },
50
+ utxoIn: {
51
+ amount: {
52
+ max: {
53
+ default: 1_000_000, // 1 ADA
54
+ doc: 'The maximum amount of the input (inclusive)',
55
+ format: 'number'
56
+ },
57
+ min: {
58
+ default: 1_000_000, // 1 ADA
59
+ doc: 'The minimum amount of the input (inclusive)',
60
+ format: 'number'
61
+ }
62
+ },
63
+ count: {
64
+ max: {
65
+ default: 1,
66
+ doc: 'The maximum number of inputs to be generated at each transaction',
67
+ format: 'number'
68
+ },
69
+ min: {
70
+ default: 1,
71
+ doc: 'The minimum number of inputs to be generated at each transaction',
72
+ format: 'number'
73
+ }
74
+ },
75
+ period: {
76
+ default: 0,
77
+ doc: 'How frequently the wallet will receive inputs.',
78
+ format: 'number'
79
+ }
80
+ },
81
+ utxoOut: {
82
+ amount: {
83
+ max: {
84
+ default: 1_000_000, // 1 ADA
85
+ doc: 'The maximum amount of the output (inclusive)',
86
+ format: 'number'
87
+ },
88
+ min: {
89
+ default: 1_000_000, // 1 ADA
90
+ doc: 'The minimum amount of the output (inclusive)',
91
+ format: 'number'
92
+ }
93
+ },
94
+ count: {
95
+ max: {
96
+ default: 1,
97
+ doc: 'The maximum number of outputs to be generated at each transaction',
98
+ format: 'number'
99
+ },
100
+ min: {
101
+ default: 1,
102
+ doc: 'The minimum number of outputs to be generated at each transaction',
103
+ format: 'number'
104
+ }
105
+ },
106
+ period: {
107
+ default: 0,
108
+ doc: 'How frequently the wallet will generate outputs.',
109
+ format: 'number'
110
+ }
111
+ }
112
+ });
@@ -0,0 +1,73 @@
1
+ import * as fs from 'fs';
2
+ import path from 'path';
3
+
4
+ export enum Paths {
5
+ StakeDistribution = 'stake-distribution.csv',
6
+ WalletUtxos = 'utxos'
7
+ }
8
+
9
+ /**
10
+ * Functions to create/delete and read/write files and folders.
11
+ */
12
+ export const Files = {
13
+ /**
14
+ * This method is intended to concatenate individual strings into a single string that represents a file path.
15
+ *
16
+ * @param paths An array of parts of the path.
17
+ */
18
+ combine(paths: Array<string>): string {
19
+ return path.join(...paths);
20
+ },
21
+ /**
22
+ * Creates a new folder if it doesn't exist.
23
+ *
24
+ * @param dir The directory to be created.
25
+ * @param recursive set to true if more than one nested directory is present in the path.
26
+ */
27
+ createFolder(dir: string, recursive?: boolean) {
28
+ if (!fs.existsSync(dir)) {
29
+ fs.mkdirSync(dir, { recursive });
30
+ }
31
+ },
32
+ /**
33
+ * Deletes a file or directory.
34
+ *
35
+ * @param filePath the path of a file or folder.
36
+ * @param recursive set to true if you want to perform a recursive delete.
37
+ */
38
+ delete(filePath: string, recursive?: boolean) {
39
+ if (!fs.existsSync(filePath)) {
40
+ return;
41
+ }
42
+
43
+ fs.rmSync(filePath, { recursive });
44
+ },
45
+ /**
46
+ * Writes content to a file.
47
+ *
48
+ * @param filePath The path of the file.
49
+ */
50
+ readFile(filePath: string): Uint8Array {
51
+ if (!fs.existsSync(filePath)) {
52
+ throw new Error('File not found.');
53
+ }
54
+
55
+ return fs.readFileSync(filePath);
56
+ },
57
+
58
+ /**
59
+ * Writes content to a file.
60
+ *
61
+ * @param filePath The path of the file.
62
+ * @param content The content to be written.
63
+ * @param append true if the content must be appended; otherwise; the original contents will be erased.
64
+ */
65
+ writeFile(filePath: string, content: string | Uint8Array, append?: boolean) {
66
+ const dir = path.dirname(filePath);
67
+ if (!fs.existsSync(dir)) {
68
+ this.createFolder(dir, true);
69
+ }
70
+
71
+ return append ? fs.appendFileSync(filePath, content) : fs.writeFileSync(filePath, content);
72
+ }
73
+ };
@@ -0,0 +1,4 @@
1
+ export * from './config';
2
+ export * from './files';
3
+ export * from './utils';
4
+ export * from './terminal-progress-monitor';
@@ -0,0 +1,147 @@
1
+ import chalk from 'chalk';
2
+ import cliSpinners from 'cli-spinners';
3
+ import ora from 'ora';
4
+
5
+ /**
6
+ * The task result.
7
+ */
8
+ export enum TaskResult {
9
+ Success = 0,
10
+ Fail = 1,
11
+ Warning = 2,
12
+ Info = 3,
13
+ None = 4
14
+ }
15
+
16
+ /**
17
+ * Tracks progress of tasks in the terminal.
18
+ */
19
+ export class TerminalProgressMonitor {
20
+ #currentTask: ora.Ora | null = null;
21
+
22
+ /**
23
+ * Starts tracking a new task. it will display a spinner while the ask is being tracked.
24
+ *
25
+ * Only one task can be tracked at a time. If you have a current track task, this
26
+ * method will throw.
27
+ *
28
+ * @param message The message of the task.
29
+ */
30
+ startTask(message: string) {
31
+ if (this.#currentTask) throw new Error('Only one task can be tracked at a time');
32
+
33
+ this.#currentTask = ora({
34
+ spinner: cliSpinners.dots,
35
+ text: message
36
+ });
37
+
38
+ this.#currentTask.start();
39
+ }
40
+
41
+ /**
42
+ * Ends the tracking of the current task.
43
+ *
44
+ * @param message The result message to be displayed.
45
+ * @param result The task result.
46
+ */
47
+ endTask(message: string, result: TaskResult) {
48
+ if (!this.#currentTask) return;
49
+
50
+ switch (result) {
51
+ case TaskResult.Fail:
52
+ this.#currentTask.fail(chalk.red(message));
53
+ break;
54
+ case TaskResult.Info:
55
+ this.#currentTask.info(message);
56
+ break;
57
+ case TaskResult.Success:
58
+ this.#currentTask.succeed(message);
59
+ break;
60
+ case TaskResult.Warning:
61
+ this.#currentTask.warn(chalk.yellow(message));
62
+ break;
63
+ default:
64
+ case TaskResult.None:
65
+ this.#currentTask.stop();
66
+ }
67
+
68
+ this.#currentTask = null;
69
+ }
70
+
71
+ /**
72
+ * Gets whether the monitor is currently tracking a task.
73
+ *
74
+ * @returns true if it is tracking a task; otherwise; false.
75
+ */
76
+ isTrackingTask(): boolean {
77
+ return !!this.#currentTask;
78
+ }
79
+
80
+ /**
81
+ * Adds a info log entry to the monitor.
82
+ *
83
+ * @param message The result message to be displayed.
84
+ */
85
+ logInfo(message: string) {
86
+ this.log(message, TaskResult.Info);
87
+ }
88
+
89
+ /**
90
+ * Adds a warning log entry to the monitor.
91
+ *
92
+ * @param message The result message to be displayed.
93
+ */
94
+ logWarning(message: string) {
95
+ this.log(message, TaskResult.Warning);
96
+ }
97
+
98
+ /**
99
+ * Adds a warning log entry to the monitor.
100
+ *
101
+ * @param message The result message to be displayed.
102
+ */
103
+ logFailure(message: string) {
104
+ this.log(message, TaskResult.Fail);
105
+ }
106
+
107
+ /**
108
+ * Adds a success log entry to the monitor.
109
+ *
110
+ * @param message The result message to be displayed.
111
+ */
112
+ logSuccess(message: string) {
113
+ this.log(message, TaskResult.Success);
114
+ }
115
+
116
+ /**
117
+ * Logs a message into the monitor.
118
+ *
119
+ * @param message The result message to be displayed.
120
+ * @param result The task result.
121
+ */
122
+ private log(message: string, result: TaskResult) {
123
+ if (this.#currentTask) throw new Error('Cant log in the monitor while a task is being tracked');
124
+
125
+ const task = ora({
126
+ spinner: cliSpinners.dots,
127
+ text: message
128
+ });
129
+
130
+ switch (result) {
131
+ case TaskResult.Fail:
132
+ task.fail(chalk.red(message));
133
+ break;
134
+ case TaskResult.Info:
135
+ task.info(message);
136
+ break;
137
+ case TaskResult.Success:
138
+ task.succeed(message);
139
+ break;
140
+ case TaskResult.Warning:
141
+ task.warn(chalk.yellow(message));
142
+ break;
143
+ default:
144
+ case TaskResult.None:
145
+ }
146
+ }
147
+ }