@stacks/rendezvous 0.4.0 → 0.4.1

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/citizen.js CHANGED
@@ -18,6 +18,7 @@ const fs_1 = require("fs");
18
18
  const path_1 = require("path");
19
19
  const yaml_1 = __importDefault(require("yaml"));
20
20
  const clarinet_sdk_1 = require("@hirosystems/clarinet-sdk");
21
+ const transactions_1 = require("@stacks/transactions");
21
22
  /**
22
23
  * Prepares the simnet instance and assures the target contract's corresponding
23
24
  * test contract is treated as a first-class citizen, relying on their
@@ -41,7 +42,15 @@ const issueFirstClassCitizenship = (manifestDir, manifestPath, sutContractName)
41
42
  encoding: "utf-8",
42
43
  }));
43
44
  const sortedContractsByEpoch = (0, exports.groupContractsByEpochFromSimnetPlan)(simnetPlan);
45
+ const simnetAddresses = [...simnet.getAccounts().values()];
46
+ const balancesMap = new Map(Array.from(simnetAddresses, (address) => {
47
+ const balanceHex = simnet.runSnippet(`(stx-get-balance '${address})`);
48
+ return [address, (0, transactions_1.cvToValue)((0, transactions_1.hexToCV)(balanceHex))];
49
+ }));
44
50
  yield simnet.initEmptySession();
51
+ simnetAddresses.forEach((address) => {
52
+ simnet.mintSTX(address, balancesMap.get(address));
53
+ });
45
54
  // Combine the target contract with its tests into a single contract. The
46
55
  // resulting contract will replace the target contract in the simnet.
47
56
  /** The contract names mapped to the concatenated source code. */
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stacks/rendezvous",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Meet your contract's vulnerabilities head-on.",
5
5
  "main": "app.js",
6
6
  "bin": {
package/dist/property.js CHANGED
@@ -171,10 +171,21 @@ const checkProperties = (simnet, targetContractName, rendezvousList, rendezvousA
171
171
  }
172
172
  }
173
173
  else {
174
- throw new Error(`Test failed for ${targetContractName} contract: "${r.selectedTestFunction.name}" returned ${testFunctionCallResultJson.value.value}`);
174
+ // The function call did not result in (ok true) or (ok false).
175
+ // Either the test failed or the test function returned an
176
+ // unexpected value i.e. `(ok 1)`.
177
+ const displayedError = (0, transactions_1.cvToString)(testFunctionCallResult);
178
+ throw new PropertyTestError(`Test failed for ${targetContractName} contract: "${r.selectedTestFunction.name}" returned ${displayedError}`, displayedError);
175
179
  }
176
180
  }
177
181
  catch (error) {
182
+ const displayedError = error instanceof PropertyTestError
183
+ ? error.clarityError
184
+ : error &&
185
+ typeof error === "string" &&
186
+ error.toLowerCase().includes("runtime")
187
+ ? "(runtime)"
188
+ : "(unknown)";
178
189
  // Capture the error and log the test failure.
179
190
  radio.emit("logMessage", (0, ansicolor_1.red)(`₿ ${simnet.burnBlockHeight.toString().padStart(8)} ` +
180
191
  `Ӿ ${simnet.blockHeight.toString().padStart(8)} ` +
@@ -182,7 +193,8 @@ const checkProperties = (simnet, targetContractName, rendezvousList, rendezvousA
182
193
  `[FAIL] ` +
183
194
  `${targetContractName} ` +
184
195
  `${(0, ansicolor_1.underline)(r.selectedTestFunction.name)} ` +
185
- printedTestFunctionArgs));
196
+ `${printedTestFunctionArgs} ` +
197
+ displayedError));
186
198
  // Re-throw the error for fast-check to catch and process.
187
199
  throw error;
188
200
  }
@@ -269,3 +281,9 @@ exports.isParamsMatch = isParamsMatch;
269
281
  */
270
282
  const isReturnTypeBoolean = (discardFunctionInterface) => discardFunctionInterface.outputs.type === "bool";
271
283
  exports.isReturnTypeBoolean = isReturnTypeBoolean;
284
+ class PropertyTestError extends Error {
285
+ constructor(message, clarityError) {
286
+ super(message);
287
+ this.clarityError = clarityError;
288
+ }
289
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stacks/rendezvous",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Meet your contract's vulnerabilities head-on.",
5
5
  "main": "app.js",
6
6
  "bin": {