@5ive-tech/sdk 1.1.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.
- package/README.md +279 -0
- package/dist/FiveSDK.d.ts +336 -0
- package/dist/FiveSDK.js +395 -0
- package/dist/accounts/index.d.ts +254 -0
- package/dist/accounts/index.js +543 -0
- package/dist/assets/vm/dummy.file +0 -0
- package/dist/assets/vm/five_vm_wasm.d.ts +762 -0
- package/dist/assets/vm/five_vm_wasm.js +3754 -0
- package/dist/assets/vm/five_vm_wasm_bg.js +3307 -0
- package/dist/assets/vm/five_vm_wasm_bg.wasm +0 -0
- package/dist/assets/vm/five_vm_wasm_bg.wasm.d.ts +247 -0
- package/dist/assets/vm/package.json +11 -0
- package/dist/bin/gen-types.d.ts +2 -0
- package/dist/bin/gen-types.js +35 -0
- package/dist/compiler/BytecodeCompiler.d.ts +83 -0
- package/dist/compiler/BytecodeCompiler.js +379 -0
- package/dist/config/ConfigManager.d.ts +13 -0
- package/dist/config/ConfigManager.js +27 -0
- package/dist/config/ProgramIdResolver.d.ts +62 -0
- package/dist/config/ProgramIdResolver.js +104 -0
- package/dist/crypto/index.d.ts +211 -0
- package/dist/crypto/index.js +451 -0
- package/dist/encoding/ParameterEncoder.d.ts +31 -0
- package/dist/encoding/ParameterEncoder.js +278 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +28 -0
- package/dist/lib/bytecode-encoder.d.ts +62 -0
- package/dist/lib/bytecode-encoder.js +281 -0
- package/dist/logging/index.d.ts +9 -0
- package/dist/logging/index.js +10 -0
- package/dist/metadata/index.d.ts +213 -0
- package/dist/metadata/index.js +296 -0
- package/dist/modules/accounts.d.ts +60 -0
- package/dist/modules/accounts.js +275 -0
- package/dist/modules/deploy.d.ts +90 -0
- package/dist/modules/deploy.js +1118 -0
- package/dist/modules/execute.d.ts +90 -0
- package/dist/modules/execute.js +649 -0
- package/dist/modules/fees.d.ts +14 -0
- package/dist/modules/fees.js +112 -0
- package/dist/modules/namespaces.d.ts +39 -0
- package/dist/modules/namespaces.js +190 -0
- package/dist/modules/state-diff.d.ts +35 -0
- package/dist/modules/state-diff.js +342 -0
- package/dist/modules/vm-state.d.ts +7 -0
- package/dist/modules/vm-state.js +44 -0
- package/dist/program/AccountResolver.d.ts +67 -0
- package/dist/program/AccountResolver.js +134 -0
- package/dist/program/BorshSchemaGenerator.d.ts +8 -0
- package/dist/program/BorshSchemaGenerator.js +57 -0
- package/dist/program/FiveProgram.d.ts +144 -0
- package/dist/program/FiveProgram.js +282 -0
- package/dist/program/FunctionBuilder.d.ts +114 -0
- package/dist/program/FunctionBuilder.js +347 -0
- package/dist/program/ProgramAccount.d.ts +38 -0
- package/dist/program/ProgramAccount.js +170 -0
- package/dist/program/TypeGenerator.d.ts +90 -0
- package/dist/program/TypeGenerator.js +195 -0
- package/dist/program/index.d.ts +24 -0
- package/dist/program/index.js +21 -0
- package/dist/project/config.d.ts +5 -0
- package/dist/project/config.js +33 -0
- package/dist/project/toml.d.ts +6 -0
- package/dist/project/toml.js +43 -0
- package/dist/project/workspace.d.ts +160 -0
- package/dist/project/workspace.js +73 -0
- package/dist/testing/AccountMetaGenerator.d.ts +121 -0
- package/dist/testing/AccountMetaGenerator.js +261 -0
- package/dist/testing/AccountTestFixture.d.ts +211 -0
- package/dist/testing/AccountTestFixture.js +530 -0
- package/dist/testing/OnChainAccountManager.d.ts +81 -0
- package/dist/testing/OnChainAccountManager.js +260 -0
- package/dist/testing/StateSerializer.d.ts +65 -0
- package/dist/testing/StateSerializer.js +330 -0
- package/dist/testing/TestDiscovery.d.ts +79 -0
- package/dist/testing/TestDiscovery.js +274 -0
- package/dist/testing/TestRunner.d.ts +117 -0
- package/dist/testing/TestRunner.js +346 -0
- package/dist/testing/index.d.ts +14 -0
- package/dist/testing/index.js +13 -0
- package/dist/types.d.ts +356 -0
- package/dist/types.js +32 -0
- package/dist/utils/abi.d.ts +31 -0
- package/dist/utils/abi.js +92 -0
- package/dist/utils/transaction.d.ts +5 -0
- package/dist/utils/transaction.js +48 -0
- package/dist/validation/InputValidator.d.ts +142 -0
- package/dist/validation/InputValidator.js +332 -0
- package/dist/validation/index.d.ts +4 -0
- package/dist/validation/index.js +4 -0
- package/dist/wasm/compiler/AbiLogic.d.ts +4 -0
- package/dist/wasm/compiler/AbiLogic.js +37 -0
- package/dist/wasm/compiler/AnalysisLogic.d.ts +6 -0
- package/dist/wasm/compiler/AnalysisLogic.js +61 -0
- package/dist/wasm/compiler/CompilationLogic.d.ts +10 -0
- package/dist/wasm/compiler/CompilationLogic.js +431 -0
- package/dist/wasm/compiler/FiveCompiler.d.ts +48 -0
- package/dist/wasm/compiler/FiveCompiler.js +183 -0
- package/dist/wasm/compiler/InfoLogic.d.ts +6 -0
- package/dist/wasm/compiler/InfoLogic.js +24 -0
- package/dist/wasm/compiler/OptimizationLogic.d.ts +2 -0
- package/dist/wasm/compiler/OptimizationLogic.js +13 -0
- package/dist/wasm/compiler/ValidationLogic.d.ts +7 -0
- package/dist/wasm/compiler/ValidationLogic.js +26 -0
- package/dist/wasm/compiler/index.d.ts +2 -0
- package/dist/wasm/compiler/index.js +2 -0
- package/dist/wasm/compiler/types.d.ts +8 -0
- package/dist/wasm/compiler/types.js +1 -0
- package/dist/wasm/compiler/utils.d.ts +8 -0
- package/dist/wasm/compiler/utils.js +75 -0
- package/dist/wasm/index.d.ts +9 -0
- package/dist/wasm/index.js +12 -0
- package/dist/wasm/instance.d.ts +1 -0
- package/dist/wasm/instance.js +26 -0
- package/dist/wasm/loader.d.ts +7 -0
- package/dist/wasm/loader.js +112 -0
- package/dist/wasm/vm.d.ts +33 -0
- package/dist/wasm/vm.js +250 -0
- package/package.json +59 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Five CLI Test Discovery
|
|
3
|
+
*
|
|
4
|
+
* Enhanced test discovery for Five VM scripts supporting both .v source files
|
|
5
|
+
* and compiled .test.json test suites. Automatically detects test functions,
|
|
6
|
+
* extracts parameters from @test-params comments, and compiles source files.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Discovered test source from .v file
|
|
10
|
+
*/
|
|
11
|
+
export interface VSourceTest {
|
|
12
|
+
type: 'v-source';
|
|
13
|
+
file: string;
|
|
14
|
+
functionName: string;
|
|
15
|
+
parameters?: any[];
|
|
16
|
+
description?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Compiled test case
|
|
20
|
+
*/
|
|
21
|
+
export interface CompiledTestCase {
|
|
22
|
+
type: 'compiled';
|
|
23
|
+
file: string;
|
|
24
|
+
bytecode: Uint8Array;
|
|
25
|
+
functionIndex?: number;
|
|
26
|
+
parameters?: any[];
|
|
27
|
+
description?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Test discovery result
|
|
31
|
+
*/
|
|
32
|
+
export interface DiscoveredTest {
|
|
33
|
+
name: string;
|
|
34
|
+
path: string;
|
|
35
|
+
type: 'v-source' | 'json-suite' | 'bin-bytecode';
|
|
36
|
+
source?: VSourceTest;
|
|
37
|
+
description?: string;
|
|
38
|
+
parameters?: any[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Discover tests from directory
|
|
42
|
+
*/
|
|
43
|
+
export declare class TestDiscovery {
|
|
44
|
+
/**
|
|
45
|
+
* Discover all tests in a directory
|
|
46
|
+
*/
|
|
47
|
+
static discoverTests(testDir: string, options?: {
|
|
48
|
+
pattern?: string;
|
|
49
|
+
verbose?: boolean;
|
|
50
|
+
}): Promise<DiscoveredTest[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Discover .v source test files
|
|
53
|
+
*/
|
|
54
|
+
private static discoverVTests;
|
|
55
|
+
/**
|
|
56
|
+
* Discover .test.json test suites
|
|
57
|
+
*/
|
|
58
|
+
private static discoverJsonTests;
|
|
59
|
+
/**
|
|
60
|
+
* Discover from single file
|
|
61
|
+
*/
|
|
62
|
+
private static discoverFromFile;
|
|
63
|
+
/**
|
|
64
|
+
* Parse .v source file for test functions and parameters
|
|
65
|
+
*/
|
|
66
|
+
private static parseVFile;
|
|
67
|
+
/**
|
|
68
|
+
* Compile a .v test source file
|
|
69
|
+
*/
|
|
70
|
+
static compileVTest(file: string): Promise<{
|
|
71
|
+
success: boolean;
|
|
72
|
+
bytecode?: Uint8Array;
|
|
73
|
+
errors?: string[];
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* Find files recursively matching predicate
|
|
77
|
+
*/
|
|
78
|
+
private static findFilesRecursive;
|
|
79
|
+
}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Five CLI Test Discovery
|
|
3
|
+
*
|
|
4
|
+
* Enhanced test discovery for Five VM scripts supporting both .v source files
|
|
5
|
+
* and compiled .test.json test suites. Automatically detects test functions,
|
|
6
|
+
* extracts parameters from @test-params comments, and compiles source files.
|
|
7
|
+
*/
|
|
8
|
+
import { readFile, readdir, stat } from 'fs/promises';
|
|
9
|
+
import { join, basename } from 'path';
|
|
10
|
+
import { FiveSDK } from '../FiveSDK.js';
|
|
11
|
+
/**
|
|
12
|
+
* Discover tests from directory
|
|
13
|
+
*/
|
|
14
|
+
export class TestDiscovery {
|
|
15
|
+
/**
|
|
16
|
+
* Discover all tests in a directory
|
|
17
|
+
*/
|
|
18
|
+
static async discoverTests(testDir, options = {}) {
|
|
19
|
+
const tests = [];
|
|
20
|
+
try {
|
|
21
|
+
const stats = await stat(testDir);
|
|
22
|
+
if (stats.isFile()) {
|
|
23
|
+
// Single test file
|
|
24
|
+
const tests = await this.discoverFromFile(testDir);
|
|
25
|
+
return tests;
|
|
26
|
+
}
|
|
27
|
+
else if (stats.isDirectory()) {
|
|
28
|
+
// Discover all test files
|
|
29
|
+
const vSourceTests = await this.discoverVTests(testDir);
|
|
30
|
+
const jsonTests = await this.discoverJsonTests(testDir);
|
|
31
|
+
tests.push(...vSourceTests, ...jsonTests);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (options.verbose) {
|
|
36
|
+
console.warn(`Failed to discover tests in ${testDir}: ${error}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return tests;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Discover .v source test files
|
|
43
|
+
*/
|
|
44
|
+
static async discoverVTests(testDir) {
|
|
45
|
+
const tests = [];
|
|
46
|
+
try {
|
|
47
|
+
const files = await this.findFilesRecursive(testDir, (f) => f.endsWith('.v'));
|
|
48
|
+
for (const file of files) {
|
|
49
|
+
const sourceTests = await this.parseVFile(file);
|
|
50
|
+
tests.push(...sourceTests);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
// Silently skip if directory doesn't exist
|
|
55
|
+
}
|
|
56
|
+
return tests;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Discover .test.json test suites
|
|
60
|
+
*/
|
|
61
|
+
static async discoverJsonTests(testDir) {
|
|
62
|
+
const tests = [];
|
|
63
|
+
try {
|
|
64
|
+
const files = await this.findFilesRecursive(testDir, (f) => f.endsWith('.test.json'));
|
|
65
|
+
for (const file of files) {
|
|
66
|
+
try {
|
|
67
|
+
const content = await readFile(file, 'utf8');
|
|
68
|
+
const data = JSON.parse(content);
|
|
69
|
+
const testCases = data.tests || data.testCases || [];
|
|
70
|
+
for (const testCase of testCases) {
|
|
71
|
+
tests.push({
|
|
72
|
+
name: testCase.name,
|
|
73
|
+
path: file,
|
|
74
|
+
type: 'json-suite',
|
|
75
|
+
description: testCase.description,
|
|
76
|
+
parameters: testCase.parameters
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
console.warn(`Failed to parse test file ${file}: ${error}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
// Silently skip if directory doesn't exist
|
|
87
|
+
}
|
|
88
|
+
return tests;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Discover from single file
|
|
92
|
+
*/
|
|
93
|
+
static async discoverFromFile(file) {
|
|
94
|
+
if (file.endsWith('.v')) {
|
|
95
|
+
return this.parseVFile(file);
|
|
96
|
+
}
|
|
97
|
+
else if (file.endsWith('.test.json')) {
|
|
98
|
+
try {
|
|
99
|
+
const content = await readFile(file, 'utf8');
|
|
100
|
+
const data = JSON.parse(content);
|
|
101
|
+
const testCases = data.tests || data.testCases || [];
|
|
102
|
+
return testCases.map((testCase) => ({
|
|
103
|
+
name: testCase.name,
|
|
104
|
+
path: file,
|
|
105
|
+
type: 'json-suite',
|
|
106
|
+
description: testCase.description,
|
|
107
|
+
parameters: testCase.parameters
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
console.warn(`Failed to parse test file ${file}: ${error}`);
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Parse .v source file for test functions and parameters
|
|
119
|
+
*/
|
|
120
|
+
static async parseVFile(file) {
|
|
121
|
+
const tests = [];
|
|
122
|
+
try {
|
|
123
|
+
const content = await readFile(file, 'utf8');
|
|
124
|
+
// Find all function definitions with potential test annotations
|
|
125
|
+
// Pattern 1: pub function with #[test] annotation
|
|
126
|
+
// Pattern 2: function with specific naming convention (test_*, *_test)
|
|
127
|
+
const lines = content.split('\n');
|
|
128
|
+
let currentFunction = null;
|
|
129
|
+
let currentParams = null;
|
|
130
|
+
let currentDescription = null;
|
|
131
|
+
for (let i = 0; i < lines.length; i++) {
|
|
132
|
+
const line = lines[i].trim();
|
|
133
|
+
// Check for @test-params comment
|
|
134
|
+
const paramsMatch = line.match(/@test-params\s+(.*)/);
|
|
135
|
+
if (paramsMatch) {
|
|
136
|
+
try {
|
|
137
|
+
const paramsStr = paramsMatch[1].trim();
|
|
138
|
+
// Try to parse as JSON array first
|
|
139
|
+
if (paramsStr.startsWith('[')) {
|
|
140
|
+
currentParams = JSON.parse(paramsStr);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
// Parse space-separated values
|
|
144
|
+
currentParams = paramsStr.split(/\s+/).map(p => {
|
|
145
|
+
// Try to parse as number
|
|
146
|
+
if (!isNaN(Number(p))) {
|
|
147
|
+
return Number(p);
|
|
148
|
+
}
|
|
149
|
+
return p;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
console.warn(`Failed to parse @test-params in ${file}:${i + 1}: ${line}`);
|
|
155
|
+
}
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
// Check for test annotation
|
|
159
|
+
if (line.startsWith('#[test]') || line.includes('#[test]')) {
|
|
160
|
+
// Next non-empty line should be the function definition
|
|
161
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
162
|
+
const nextLine = lines[j].trim();
|
|
163
|
+
if (nextLine && !nextLine.startsWith('//')) {
|
|
164
|
+
const funcMatch = nextLine.match(/(?:pub\s+)?(?:fn|instruction|script)\s+(\w+)\s*\(/);
|
|
165
|
+
if (funcMatch) {
|
|
166
|
+
currentFunction = funcMatch[1];
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
// Check for pub function that matches test naming convention
|
|
174
|
+
const funcMatch = line.match(/pub\s+(?:fn|instruction|script)\s+(test_\w+|_?\w+_test)\s*\(/);
|
|
175
|
+
if (funcMatch) {
|
|
176
|
+
const functionName = funcMatch[1];
|
|
177
|
+
// Check if we have parameters from @test-params comment
|
|
178
|
+
if (currentParams || currentFunction) {
|
|
179
|
+
const name = basename(file, '.v') + '::' + functionName;
|
|
180
|
+
tests.push({
|
|
181
|
+
name,
|
|
182
|
+
path: file,
|
|
183
|
+
type: 'v-source',
|
|
184
|
+
source: {
|
|
185
|
+
type: 'v-source',
|
|
186
|
+
file,
|
|
187
|
+
functionName,
|
|
188
|
+
parameters: currentParams || undefined,
|
|
189
|
+
description: currentDescription || undefined
|
|
190
|
+
},
|
|
191
|
+
parameters: currentParams || undefined,
|
|
192
|
+
description: currentDescription || undefined
|
|
193
|
+
});
|
|
194
|
+
currentParams = null;
|
|
195
|
+
currentDescription = null;
|
|
196
|
+
currentFunction = null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
console.warn(`Failed to parse V file ${file}: ${error}`);
|
|
203
|
+
}
|
|
204
|
+
return tests;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Compile a .v test source file
|
|
208
|
+
*/
|
|
209
|
+
static async compileVTest(file) {
|
|
210
|
+
try {
|
|
211
|
+
const source = await readFile(file, 'utf8');
|
|
212
|
+
// Check if file has use statements for multi-file compilation
|
|
213
|
+
const hasUseStatements = /^\s*use\s+/m.test(source) || /^\s*import\s+/m.test(source);
|
|
214
|
+
let compilation;
|
|
215
|
+
if (hasUseStatements) {
|
|
216
|
+
// Use multi-file compilation with auto-discovery
|
|
217
|
+
// This would require access to WasmCompilerWrapper
|
|
218
|
+
// Use single-file compilation
|
|
219
|
+
compilation = await FiveSDK.compile(source, {
|
|
220
|
+
debug: false,
|
|
221
|
+
optimize: false
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
compilation = await FiveSDK.compile(source, {
|
|
226
|
+
debug: false,
|
|
227
|
+
optimize: false
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
if (!compilation.success) {
|
|
231
|
+
const errors = compilation.errors || [];
|
|
232
|
+
const errorMessages = errors.map(e => typeof e === 'string' ? e : e.message || 'Unknown error');
|
|
233
|
+
return {
|
|
234
|
+
success: false,
|
|
235
|
+
errors: errorMessages
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
success: true,
|
|
240
|
+
bytecode: compilation.bytecode
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
return {
|
|
245
|
+
success: false,
|
|
246
|
+
errors: [error instanceof Error ? error.message : 'Compilation failed']
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Find files recursively matching predicate
|
|
252
|
+
*/
|
|
253
|
+
static async findFilesRecursive(dir, predicate) {
|
|
254
|
+
const files = [];
|
|
255
|
+
try {
|
|
256
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
257
|
+
for (const entry of entries) {
|
|
258
|
+
const fullPath = join(dir, entry.name);
|
|
259
|
+
if (entry.isDirectory() && !entry.name.startsWith('.')) {
|
|
260
|
+
// Recursively search subdirectories
|
|
261
|
+
const subFiles = await this.findFilesRecursive(fullPath, predicate);
|
|
262
|
+
files.push(...subFiles);
|
|
263
|
+
}
|
|
264
|
+
else if (entry.isFile() && predicate(entry.name)) {
|
|
265
|
+
files.push(fullPath);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
// Silently skip inaccessible directories
|
|
271
|
+
}
|
|
272
|
+
return files;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Five SDK Test Runner
|
|
3
|
+
*
|
|
4
|
+
* SDK-based test utilities that replace shell script approaches with programmatic
|
|
5
|
+
* Five SDK usage. Provides comprehensive testing capabilities for Five VM scripts.
|
|
6
|
+
*/
|
|
7
|
+
import { FiveScriptSource } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Test case definition
|
|
10
|
+
*/
|
|
11
|
+
export interface TestCase {
|
|
12
|
+
name: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
bytecode?: string;
|
|
15
|
+
source?: string;
|
|
16
|
+
function?: string | number;
|
|
17
|
+
parameters?: any[];
|
|
18
|
+
expected: {
|
|
19
|
+
success: boolean;
|
|
20
|
+
result?: any;
|
|
21
|
+
error?: string;
|
|
22
|
+
maxComputeUnits?: number;
|
|
23
|
+
minComputeUnits?: number;
|
|
24
|
+
};
|
|
25
|
+
timeout?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Test suite definition
|
|
29
|
+
*/
|
|
30
|
+
export interface TestSuite {
|
|
31
|
+
name: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
setup?: () => Promise<void>;
|
|
34
|
+
teardown?: () => Promise<void>;
|
|
35
|
+
testCases: TestCase[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Test result
|
|
39
|
+
*/
|
|
40
|
+
export interface TestResult {
|
|
41
|
+
name: string;
|
|
42
|
+
passed: boolean;
|
|
43
|
+
duration: number;
|
|
44
|
+
error?: string;
|
|
45
|
+
computeUnitsUsed?: number;
|
|
46
|
+
result?: any;
|
|
47
|
+
logs?: string[];
|
|
48
|
+
trace?: any[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Test suite result
|
|
52
|
+
*/
|
|
53
|
+
export interface TestSuiteResult {
|
|
54
|
+
suite: TestSuite;
|
|
55
|
+
results: TestResult[];
|
|
56
|
+
duration: number;
|
|
57
|
+
passed: number;
|
|
58
|
+
failed: number;
|
|
59
|
+
skipped: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Test runner options
|
|
63
|
+
*/
|
|
64
|
+
export interface TestRunnerOptions {
|
|
65
|
+
timeout?: number;
|
|
66
|
+
maxComputeUnits?: number;
|
|
67
|
+
parallel?: number;
|
|
68
|
+
verbose?: boolean;
|
|
69
|
+
debug?: boolean;
|
|
70
|
+
trace?: boolean;
|
|
71
|
+
pattern?: string;
|
|
72
|
+
failFast?: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Five SDK-based test runner
|
|
76
|
+
*/
|
|
77
|
+
export declare class FiveTestRunner {
|
|
78
|
+
private options;
|
|
79
|
+
constructor(options?: TestRunnerOptions);
|
|
80
|
+
/**
|
|
81
|
+
* Run a single test case
|
|
82
|
+
*/
|
|
83
|
+
runTestCase(testCase: TestCase): Promise<TestResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Run a complete test suite
|
|
86
|
+
*/
|
|
87
|
+
runTestSuite(suite: TestSuite): Promise<TestSuiteResult>;
|
|
88
|
+
/**
|
|
89
|
+
* Run multiple test suites
|
|
90
|
+
*/
|
|
91
|
+
runTestSuites(suites: TestSuite[]): Promise<TestSuiteResult[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Discover and load test suites from directory
|
|
94
|
+
*/
|
|
95
|
+
discoverTestSuites(directory: string, pattern?: string): Promise<TestSuite[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Compile and execute test - convenience method
|
|
98
|
+
*/
|
|
99
|
+
static compileAndTest(source: FiveScriptSource, functionName?: string | number, parameters?: any[], options?: {
|
|
100
|
+
debug?: boolean;
|
|
101
|
+
trace?: boolean;
|
|
102
|
+
computeUnitLimit?: number;
|
|
103
|
+
}): Promise<{
|
|
104
|
+
compilation: any;
|
|
105
|
+
execution: any;
|
|
106
|
+
success: boolean;
|
|
107
|
+
error?: string;
|
|
108
|
+
}>;
|
|
109
|
+
private compileToBytecode;
|
|
110
|
+
private validateResult;
|
|
111
|
+
private getValidationError;
|
|
112
|
+
private matchesPattern;
|
|
113
|
+
private chunkArray;
|
|
114
|
+
private findTestFiles;
|
|
115
|
+
private formatTestResult;
|
|
116
|
+
private formatSuiteResult;
|
|
117
|
+
}
|