@clarigen/test 1.0.0-next.19 → 1.0.0-next.24
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/dist/index.d.ts +2 -1
- package/dist/index.js +30 -2
- package/dist/index.mjs +30 -2
- package/package.json +19 -17
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CoreNodeEvent, ResultAssets, Contracts, ContractCall, Response, ContractCalls, ContractInstances } from '@clarigen/core';
|
|
1
|
+
import { CoreNodeEvent, ResultAssets, Contracts, ContractFactory, AllContracts, ContractCall, Response, ContractCalls, ContractInstances } from '@clarigen/core';
|
|
2
2
|
import { Costs, NativeClarityBinProvider, ClarinetAccounts } from '@clarigen/native-bin';
|
|
3
3
|
export { Allocation, createClarityBin, evalJson, executeJson } from '@clarigen/native-bin';
|
|
4
4
|
import { ClarityValue, ResponseCV } from 'micro-stacks/clarity';
|
|
@@ -57,6 +57,7 @@ declare class TestProvider {
|
|
|
57
57
|
coverageFolder?: string;
|
|
58
58
|
constructor(clarityBin: NativeClarityBinProvider);
|
|
59
59
|
static fromContracts<T extends Contracts<any>>(contracts: T, options?: FromContractsOptions): Promise<FromContracts<T>>;
|
|
60
|
+
static fromFactory(contracts: ContractFactory<AllContracts>, options?: FromContractsOptions): Promise<TestProvider>;
|
|
60
61
|
ro<T>(tx: ContractCall<T>): Promise<ReadOnlyResult<T>>;
|
|
61
62
|
rov<T>(tx: ContractCall<T>): Promise<T>;
|
|
62
63
|
roOk<Ok, Err>(tx: ContractCall<Response<Ok, Err>>): Promise<ReadOnlyResult<Ok>>;
|
package/dist/index.js
CHANGED
|
@@ -286,6 +286,34 @@ var TestProvider = class {
|
|
|
286
286
|
provider
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
|
+
static async fromFactory(contracts, options = {}) {
|
|
290
|
+
const clarityBin = options.clarityBin || await _nativebin.createClarityBin.call(void 0, {
|
|
291
|
+
allocations: options.accounts
|
|
292
|
+
});
|
|
293
|
+
let coverageFolder = options.coverageFolder;
|
|
294
|
+
if (process.env.CLARIGEN_COVERAGE) {
|
|
295
|
+
coverageFolder = _path.resolve.call(void 0, process.cwd(), "coverage");
|
|
296
|
+
}
|
|
297
|
+
await deployUtilContract(clarityBin);
|
|
298
|
+
for (const k in contracts) {
|
|
299
|
+
if (Object.prototype.hasOwnProperty.call(contracts, k)) {
|
|
300
|
+
const contract = contracts[k];
|
|
301
|
+
const contractFilePath = contract.contractFile;
|
|
302
|
+
if (typeof contractFilePath === "undefined") {
|
|
303
|
+
throw new Error("Cannot setup @clarigen/test - missing contract file.");
|
|
304
|
+
}
|
|
305
|
+
await _nativebin.deployContract.call(void 0, {
|
|
306
|
+
contractIdentifier: contract.identifier,
|
|
307
|
+
contractFilePath,
|
|
308
|
+
provider: clarityBin,
|
|
309
|
+
coverageFolder
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const provider = new this(clarityBin);
|
|
314
|
+
provider.coverageFolder = coverageFolder;
|
|
315
|
+
return provider;
|
|
316
|
+
}
|
|
289
317
|
ro(tx2) {
|
|
290
318
|
return ro({ tx: tx2, bin: this.clarityBin, coverageFolder: this.coverageFolder });
|
|
291
319
|
}
|
|
@@ -324,13 +352,13 @@ var TestProvider = class {
|
|
|
324
352
|
async txOk(tx2, senderAddress) {
|
|
325
353
|
const result = await this.tx(tx2, senderAddress);
|
|
326
354
|
if (!result.isOk)
|
|
327
|
-
throw new Error(`Expected OK, received error: ${result.value}`);
|
|
355
|
+
throw new Error(`Expected OK, received error: ${String(result.value)}`);
|
|
328
356
|
return result;
|
|
329
357
|
}
|
|
330
358
|
async txErr(tx2, senderAddress) {
|
|
331
359
|
const result = await this.tx(tx2, senderAddress);
|
|
332
360
|
if (result.isOk)
|
|
333
|
-
throw new Error(`Expected Err, received ok: ${result.value}`);
|
|
361
|
+
throw new Error(`Expected Err, received ok: ${String(result.value)}`);
|
|
334
362
|
return result;
|
|
335
363
|
}
|
|
336
364
|
evalCode(code, contractAddress = UTIL_CONTRACT_ID) {
|
package/dist/index.mjs
CHANGED
|
@@ -286,6 +286,34 @@ var TestProvider = class {
|
|
|
286
286
|
provider
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
|
+
static async fromFactory(contracts, options = {}) {
|
|
290
|
+
const clarityBin = options.clarityBin || await createClarityBin({
|
|
291
|
+
allocations: options.accounts
|
|
292
|
+
});
|
|
293
|
+
let coverageFolder = options.coverageFolder;
|
|
294
|
+
if (process.env.CLARIGEN_COVERAGE) {
|
|
295
|
+
coverageFolder = resolve2(process.cwd(), "coverage");
|
|
296
|
+
}
|
|
297
|
+
await deployUtilContract(clarityBin);
|
|
298
|
+
for (const k in contracts) {
|
|
299
|
+
if (Object.prototype.hasOwnProperty.call(contracts, k)) {
|
|
300
|
+
const contract = contracts[k];
|
|
301
|
+
const contractFilePath = contract.contractFile;
|
|
302
|
+
if (typeof contractFilePath === "undefined") {
|
|
303
|
+
throw new Error("Cannot setup @clarigen/test - missing contract file.");
|
|
304
|
+
}
|
|
305
|
+
await deployContract2({
|
|
306
|
+
contractIdentifier: contract.identifier,
|
|
307
|
+
contractFilePath,
|
|
308
|
+
provider: clarityBin,
|
|
309
|
+
coverageFolder
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const provider = new this(clarityBin);
|
|
314
|
+
provider.coverageFolder = coverageFolder;
|
|
315
|
+
return provider;
|
|
316
|
+
}
|
|
289
317
|
ro(tx2) {
|
|
290
318
|
return ro({ tx: tx2, bin: this.clarityBin, coverageFolder: this.coverageFolder });
|
|
291
319
|
}
|
|
@@ -324,13 +352,13 @@ var TestProvider = class {
|
|
|
324
352
|
async txOk(tx2, senderAddress) {
|
|
325
353
|
const result = await this.tx(tx2, senderAddress);
|
|
326
354
|
if (!result.isOk)
|
|
327
|
-
throw new Error(`Expected OK, received error: ${result.value}`);
|
|
355
|
+
throw new Error(`Expected OK, received error: ${String(result.value)}`);
|
|
328
356
|
return result;
|
|
329
357
|
}
|
|
330
358
|
async txErr(tx2, senderAddress) {
|
|
331
359
|
const result = await this.tx(tx2, senderAddress);
|
|
332
360
|
if (result.isOk)
|
|
333
|
-
throw new Error(`Expected Err, received ok: ${result.value}`);
|
|
361
|
+
throw new Error(`Expected Err, received ok: ${String(result.value)}`);
|
|
334
362
|
return result;
|
|
335
363
|
}
|
|
336
364
|
evalCode(code, contractAddress = UTIL_CONTRACT_ID) {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0-next.
|
|
2
|
+
"version": "1.0.0-next.24",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"types": "./dist/index.d.ts",
|
|
5
5
|
"main": "./dist/index.js",
|
|
@@ -12,27 +12,29 @@
|
|
|
12
12
|
"engines": {
|
|
13
13
|
"node": ">=10"
|
|
14
14
|
},
|
|
15
|
-
"scripts": {
|
|
16
|
-
"start": "tsup --watch",
|
|
17
|
-
"dev": "tsup --watch",
|
|
18
|
-
"build": "shx rm -rf ./dist && tsup-node",
|
|
19
|
-
"test": "yarn build-test-types && jest",
|
|
20
|
-
"lint": "eslint \"src/**/*.{ts,tsx}\" && prettier --check src/**/*.ts",
|
|
21
|
-
"prepublishOnly": "yarn build",
|
|
22
|
-
"typecheck": "tsc --noEmit",
|
|
23
|
-
"build-test-types": "cd test && yarn clarigen && cd ..",
|
|
24
|
-
"publish:dev": "yalc publish --push"
|
|
25
|
-
},
|
|
26
15
|
"prettier": "@stacks/prettier-config",
|
|
27
16
|
"name": "@clarigen/test",
|
|
28
17
|
"author": "Hank Stoever",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"jest-environment-node": "28.1.1",
|
|
20
|
+
"@clarigen/cli": "1.0.0-next.24"
|
|
21
|
+
},
|
|
29
22
|
"dependencies": {
|
|
30
|
-
"@clarigen/core": "1.0.0-next.
|
|
31
|
-
"@clarigen/native-bin": "1.0.0-next.
|
|
32
|
-
"micro-stacks": "^0.2
|
|
23
|
+
"@clarigen/core": "1.0.0-next.24",
|
|
24
|
+
"@clarigen/native-bin": "1.0.0-next.24",
|
|
25
|
+
"micro-stacks": "^0.5.2"
|
|
33
26
|
},
|
|
34
27
|
"publishConfig": {
|
|
35
28
|
"access": "public"
|
|
36
29
|
},
|
|
37
|
-
"
|
|
38
|
-
|
|
30
|
+
"scripts": {
|
|
31
|
+
"start": "tsup-node --watch",
|
|
32
|
+
"dev": "tsup-node --watch",
|
|
33
|
+
"build": "shx rm -rf ./dist && tsup-node",
|
|
34
|
+
"test": "pnpm build-test-types && jest",
|
|
35
|
+
"lint": "eslint \"src/**/*.{ts,tsx}\" && prettier --check src/**/*.ts",
|
|
36
|
+
"typecheck": "tsc --noEmit",
|
|
37
|
+
"build-test-types": "cd test/clarinet-project && pnpm clarigen && cd ../..",
|
|
38
|
+
"publish:dev": "yalc publish --push"
|
|
39
|
+
}
|
|
40
|
+
}
|