@hardkas/testing 0.11.2-alpha → 0.11.4-alpha
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/adversarial-fixtures.js +1 -1
- package/dist/{chunk-3RG5ZIWI.js → chunk-MCKGQKYU.js} +6 -1
- package/dist/harness.js +1 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +293 -162
- package/dist/kaspa_wasm-KISXGKGE.js +8679 -0
- package/dist/mass-setup.js +1 -1
- package/dist/reproducibility.js +1 -1
- package/dist/scenarios.js +2 -4
- package/dist/setup.js +1 -1
- package/package.json +13 -9
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "./chunk-J7YJZ3SC.js";
|
|
17
17
|
import {
|
|
18
18
|
__require
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-MCKGQKYU.js";
|
|
20
20
|
|
|
21
21
|
// src/fixtures.ts
|
|
22
22
|
function createFixture(def) {
|
|
@@ -38,6 +38,155 @@ function createFixture(def) {
|
|
|
38
38
|
return harness;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
// src/fixture-signer.ts
|
|
42
|
+
import {
|
|
43
|
+
calculateContentHash,
|
|
44
|
+
HARDKAS_VERSION,
|
|
45
|
+
ARTIFACT_VERSION,
|
|
46
|
+
CURRENT_HASH_VERSION
|
|
47
|
+
} from "@hardkas/artifacts";
|
|
48
|
+
import { parseWasmTxToRpc } from "@hardkas/accounts/internal/wasm-rpc-serialization.js";
|
|
49
|
+
var HardkasFixtureSigner = class {
|
|
50
|
+
networkId;
|
|
51
|
+
// A deterministic, known private key exclusively for Docker tests.
|
|
52
|
+
FIXTURE_PK = "b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfef";
|
|
53
|
+
constructor(networkId = "simnet") {
|
|
54
|
+
this.networkId = networkId;
|
|
55
|
+
if (networkId === "mainnet") {
|
|
56
|
+
throw new Error("FixtureSigner cannot be used on mainnet.");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async loadKaspa() {
|
|
60
|
+
try {
|
|
61
|
+
return await import("./kaspa_wasm-KISXGKGE.js");
|
|
62
|
+
} catch (e) {
|
|
63
|
+
const err = new Error(
|
|
64
|
+
"SIGNER_BACKEND_UNAVAILABLE: Official Kaspa WASM backend is required to sign transactions.\nInstall it via: npm install kaspa-wasm"
|
|
65
|
+
);
|
|
66
|
+
err.code = "SIGNER_BACKEND_UNAVAILABLE";
|
|
67
|
+
throw err;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async getAddress() {
|
|
71
|
+
const kaspa = await this.loadKaspa();
|
|
72
|
+
const privKey = new kaspa.PrivateKey(this.FIXTURE_PK);
|
|
73
|
+
return privKey.toKeypair().toAddress(this.networkId).toString();
|
|
74
|
+
}
|
|
75
|
+
async signTransaction(plan) {
|
|
76
|
+
if (plan.networkId === "mainnet") {
|
|
77
|
+
throw new Error("FixtureSigner refuses to sign mainnet transactions.");
|
|
78
|
+
}
|
|
79
|
+
const kaspa = await this.loadKaspa();
|
|
80
|
+
const privateKey = new kaspa.PrivateKey(this.FIXTURE_PK);
|
|
81
|
+
const utxos = plan.inputs.map((u) => {
|
|
82
|
+
if (!u.outpoint.transactionId || u.outpoint.index === void 0) {
|
|
83
|
+
throw new Error(`UTXO is missing transactionId or index. Re-run tx plan.`);
|
|
84
|
+
}
|
|
85
|
+
const spk = u.scriptPublicKey;
|
|
86
|
+
if (!spk) {
|
|
87
|
+
throw new Error(
|
|
88
|
+
"UTXO is missing scriptPublicKey. Real signing flows must never fabricate cryptographic state."
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
address: plan.from.address,
|
|
93
|
+
outpoint: {
|
|
94
|
+
transactionId: u.outpoint.transactionId,
|
|
95
|
+
index: u.outpoint.index
|
|
96
|
+
},
|
|
97
|
+
utxoEntry: {
|
|
98
|
+
amount: BigInt(u.amountSompi),
|
|
99
|
+
scriptPublicKey: spk,
|
|
100
|
+
blockDaaScore: BigInt(u.blockDaaScore || "0"),
|
|
101
|
+
isCoinbase: !!u.isCoinbase
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
const outputs = plan.outputs.map((o) => {
|
|
106
|
+
if (!o.address) throw new Error("Output is missing address.");
|
|
107
|
+
return {
|
|
108
|
+
address: o.address,
|
|
109
|
+
amount: BigInt(o.amountSompi)
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
let changeAddress;
|
|
113
|
+
if (plan.change && plan.change.address) {
|
|
114
|
+
changeAddress = new kaspa.Address(plan.change.address);
|
|
115
|
+
} else {
|
|
116
|
+
changeAddress = new kaspa.Address(plan.from.address);
|
|
117
|
+
}
|
|
118
|
+
const priorityFee = BigInt(plan.estimatedFeeSompi || "0");
|
|
119
|
+
const unsignedTx = kaspa.createTransaction(
|
|
120
|
+
utxos,
|
|
121
|
+
outputs,
|
|
122
|
+
changeAddress,
|
|
123
|
+
priorityFee
|
|
124
|
+
);
|
|
125
|
+
const signedTx = kaspa.signTransaction(unsignedTx, [privateKey], true);
|
|
126
|
+
console.log("SIGNED TX TOSTRING:", signedTx.toString());
|
|
127
|
+
const rawTx = JSON.stringify(parseWasmTxToRpc(signedTx.toString()));
|
|
128
|
+
const draft = {
|
|
129
|
+
schema: "hardkas.signedTx",
|
|
130
|
+
schemaVersion: "hardkas.artifact.v1",
|
|
131
|
+
hardkasVersion: HARDKAS_VERSION,
|
|
132
|
+
version: ARTIFACT_VERSION,
|
|
133
|
+
hashVersion: CURRENT_HASH_VERSION,
|
|
134
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
135
|
+
status: "signed",
|
|
136
|
+
txId: signedTx.id,
|
|
137
|
+
sourcePlanId: plan.planId,
|
|
138
|
+
networkId: plan.networkId,
|
|
139
|
+
mode: plan.mode,
|
|
140
|
+
from: plan.from,
|
|
141
|
+
to: plan.to,
|
|
142
|
+
amountSompi: plan.amountSompi,
|
|
143
|
+
unsignedPayloadHash: plan.contentHash,
|
|
144
|
+
signedTransaction: {
|
|
145
|
+
format: "hex",
|
|
146
|
+
payload: rawTx
|
|
147
|
+
},
|
|
148
|
+
metadata: {
|
|
149
|
+
signerBackend: "kaspa-wasm",
|
|
150
|
+
fixture: true,
|
|
151
|
+
networkGuard: "mainnet_rejected"
|
|
152
|
+
},
|
|
153
|
+
signatureMetadata: [
|
|
154
|
+
{
|
|
155
|
+
signer: "hardkas-local-docker-test-only",
|
|
156
|
+
signedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
lineage: {
|
|
160
|
+
artifactId: "",
|
|
161
|
+
lineageId: plan.lineage?.lineageId || plan.contentHash || "0".repeat(64),
|
|
162
|
+
parentArtifactId: plan.contentHash || plan.planId,
|
|
163
|
+
rootArtifactId: plan.lineage?.rootArtifactId || plan.contentHash || plan.planId
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const hash = calculateContentHash(draft, CURRENT_HASH_VERSION);
|
|
167
|
+
draft.signedId = `signed-${hash.slice(0, 16)}`;
|
|
168
|
+
draft.contentHash = hash;
|
|
169
|
+
if (draft.lineage) draft.lineage.artifactId = hash;
|
|
170
|
+
return draft;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// src/simulated-tx-plan-signer.ts
|
|
175
|
+
var SimulatedTxPlanSigner = class {
|
|
176
|
+
kind = "simulated";
|
|
177
|
+
async signTxPlan(input) {
|
|
178
|
+
const plan = input.planArtifact;
|
|
179
|
+
return {
|
|
180
|
+
signatureKind: "simulated",
|
|
181
|
+
signerAddress: plan.from.address,
|
|
182
|
+
signedTransaction: {
|
|
183
|
+
format: "simulated",
|
|
184
|
+
payload: `simulated-signed-tx:${plan.planId}`
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
41
190
|
// src/torture/torture-engine.ts
|
|
42
191
|
var LcgPrng = class {
|
|
43
192
|
state;
|
|
@@ -99,9 +248,9 @@ var TortureInvariantError = class extends Error {
|
|
|
99
248
|
import fs from "fs";
|
|
100
249
|
import path from "path";
|
|
101
250
|
import {
|
|
102
|
-
calculateContentHash,
|
|
103
|
-
ARTIFACT_VERSION,
|
|
104
|
-
CURRENT_HASH_VERSION
|
|
251
|
+
calculateContentHash as calculateContentHash2,
|
|
252
|
+
ARTIFACT_VERSION as ARTIFACT_VERSION2,
|
|
253
|
+
CURRENT_HASH_VERSION as CURRENT_HASH_VERSION2
|
|
105
254
|
} from "@hardkas/artifacts";
|
|
106
255
|
import { HardkasStore, SqliteQueryBackend } from "@hardkas/query-store";
|
|
107
256
|
function createSandbox(ctx) {
|
|
@@ -135,8 +284,8 @@ registerTortureBucket({
|
|
|
135
284
|
for (let i = 0; i < artifactCount; i++) {
|
|
136
285
|
const payload = {
|
|
137
286
|
schema: "hardkas.txPlan",
|
|
138
|
-
hardkasVersion: "0.11.
|
|
139
|
-
version:
|
|
287
|
+
hardkasVersion: "0.11.4-alpha",
|
|
288
|
+
version: ARTIFACT_VERSION2,
|
|
140
289
|
networkId: "simnet",
|
|
141
290
|
mode: "simulated",
|
|
142
291
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -159,7 +308,7 @@ registerTortureBucket({
|
|
|
159
308
|
}
|
|
160
309
|
]
|
|
161
310
|
};
|
|
162
|
-
const hash =
|
|
311
|
+
const hash = calculateContentHash2(payload);
|
|
163
312
|
const artifactId = `plan-${hash.slice(0, 16)}`;
|
|
164
313
|
const artifact = {
|
|
165
314
|
...payload,
|
|
@@ -229,8 +378,8 @@ registerTortureBucket({
|
|
|
229
378
|
try {
|
|
230
379
|
const payload = {
|
|
231
380
|
schema: "hardkas.txPlan",
|
|
232
|
-
hardkasVersion: "0.11.
|
|
233
|
-
version:
|
|
381
|
+
hardkasVersion: "0.11.4-alpha",
|
|
382
|
+
version: ARTIFACT_VERSION2,
|
|
234
383
|
networkId: "simnet",
|
|
235
384
|
mode: "simulated",
|
|
236
385
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -253,7 +402,7 @@ registerTortureBucket({
|
|
|
253
402
|
}
|
|
254
403
|
]
|
|
255
404
|
};
|
|
256
|
-
const validHash =
|
|
405
|
+
const validHash = calculateContentHash2(payload);
|
|
257
406
|
const artifactId = `plan-${validHash.slice(0, 16)}`;
|
|
258
407
|
const validArtifact = {
|
|
259
408
|
...payload,
|
|
@@ -309,28 +458,28 @@ registerTortureBucket({
|
|
|
309
458
|
const orderA = prngA.shuffle(["alice", "bob", "carol", "dave"]);
|
|
310
459
|
const payloadA = {
|
|
311
460
|
schema: "hardkas.txPlan",
|
|
312
|
-
version: "0.11.
|
|
461
|
+
version: "0.11.4-alpha",
|
|
313
462
|
networkId: "simnet",
|
|
314
463
|
mode: "simulated",
|
|
315
464
|
amountSompi: amountSompiA,
|
|
316
465
|
nonce: nonceA,
|
|
317
466
|
signers: orderA
|
|
318
467
|
};
|
|
319
|
-
const hashA =
|
|
468
|
+
const hashA = calculateContentHash2(payloadA);
|
|
320
469
|
const prngB = new LcgPrng(ctx.caseSeed);
|
|
321
470
|
const amountSompiB = (1000n * BigInt(prngB.nextInt(1, 100))).toString();
|
|
322
471
|
const nonceB = prngB.nextInt(1e4, 99999);
|
|
323
472
|
const orderB = prngB.shuffle(["alice", "bob", "carol", "dave"]);
|
|
324
473
|
const payloadB = {
|
|
325
474
|
schema: "hardkas.txPlan",
|
|
326
|
-
version: "0.11.
|
|
475
|
+
version: "0.11.4-alpha",
|
|
327
476
|
networkId: "simnet",
|
|
328
477
|
mode: "simulated",
|
|
329
478
|
amountSompi: amountSompiB,
|
|
330
479
|
nonce: nonceB,
|
|
331
480
|
signers: orderB
|
|
332
481
|
};
|
|
333
|
-
const hashB =
|
|
482
|
+
const hashB = calculateContentHash2(payloadB);
|
|
334
483
|
if (hashA !== hashB) {
|
|
335
484
|
throw new Error(
|
|
336
485
|
`Divergence detected under same seed ${ctx.caseSeed}. Hash A: ${hashA}, Hash B: ${hashB}`
|
|
@@ -355,8 +504,8 @@ registerTortureBucket({
|
|
|
355
504
|
try {
|
|
356
505
|
const payloadV1 = {
|
|
357
506
|
schema: "hardkas.txPlan",
|
|
358
|
-
hardkasVersion: "0.11.
|
|
359
|
-
version:
|
|
507
|
+
hardkasVersion: "0.11.4-alpha",
|
|
508
|
+
version: ARTIFACT_VERSION2,
|
|
360
509
|
networkId: "simnet",
|
|
361
510
|
mode: "simulated",
|
|
362
511
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -381,7 +530,7 @@ registerTortureBucket({
|
|
|
381
530
|
state: "initial"
|
|
382
531
|
// Custom field for test assertion
|
|
383
532
|
};
|
|
384
|
-
const hashV1 =
|
|
533
|
+
const hashV1 = calculateContentHash2(payloadV1);
|
|
385
534
|
const artifactId = `plan-${hashV1.slice(0, 16)}`;
|
|
386
535
|
const file = path.join(artifactsDir, `${artifactId}.json`);
|
|
387
536
|
const artifactV1 = {
|
|
@@ -405,7 +554,7 @@ registerTortureBucket({
|
|
|
405
554
|
state: "progressed",
|
|
406
555
|
nonce: ctx.prng.nextInt(100, 999)
|
|
407
556
|
};
|
|
408
|
-
const hashV2 =
|
|
557
|
+
const hashV2 = calculateContentHash2(payloadV2);
|
|
409
558
|
const artifactV2 = {
|
|
410
559
|
...payloadV2,
|
|
411
560
|
artifactId,
|
|
@@ -456,8 +605,8 @@ registerTortureBucket({
|
|
|
456
605
|
}
|
|
457
606
|
const planArtifact = {
|
|
458
607
|
schema: "hardkas.txPlan",
|
|
459
|
-
hardkasVersion: "0.11.
|
|
460
|
-
version:
|
|
608
|
+
hardkasVersion: "0.11.4-alpha",
|
|
609
|
+
version: ARTIFACT_VERSION2,
|
|
461
610
|
networkId: "simnet",
|
|
462
611
|
mode: "simulated",
|
|
463
612
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -479,7 +628,7 @@ registerTortureBucket({
|
|
|
479
628
|
amountSompi: out.amountSompi.toString()
|
|
480
629
|
}))
|
|
481
630
|
};
|
|
482
|
-
const planHash =
|
|
631
|
+
const planHash = calculateContentHash2(planArtifact);
|
|
483
632
|
const planId = `plan-${planHash.slice(0, 16)}`;
|
|
484
633
|
const conformingPlan = {
|
|
485
634
|
...planArtifact,
|
|
@@ -513,8 +662,8 @@ registerTortureBucket({
|
|
|
513
662
|
}
|
|
514
663
|
const receiptArtifact = {
|
|
515
664
|
schema: "hardkas.txReceipt",
|
|
516
|
-
hardkasVersion: "0.11.
|
|
517
|
-
version:
|
|
665
|
+
hardkasVersion: "0.11.4-alpha",
|
|
666
|
+
version: ARTIFACT_VERSION2,
|
|
518
667
|
networkId: "simnet",
|
|
519
668
|
mode: "simulated",
|
|
520
669
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -533,7 +682,7 @@ registerTortureBucket({
|
|
|
533
682
|
rootArtifactId: planId
|
|
534
683
|
}
|
|
535
684
|
};
|
|
536
|
-
const receiptHash =
|
|
685
|
+
const receiptHash = calculateContentHash2(receiptArtifact);
|
|
537
686
|
const receiptId = `receipt-${receiptHash.slice(0, 16)}`;
|
|
538
687
|
const conformingReceipt = {
|
|
539
688
|
...receiptArtifact,
|
|
@@ -580,8 +729,8 @@ registerTortureBucket({
|
|
|
580
729
|
const planId = `plan-mock-${ctx.caseId}-${ctx.caseSeed}`;
|
|
581
730
|
const payload = {
|
|
582
731
|
schema: "hardkas.txPlan",
|
|
583
|
-
hardkasVersion: "0.11.
|
|
584
|
-
version:
|
|
732
|
+
hardkasVersion: "0.11.4-alpha",
|
|
733
|
+
version: ARTIFACT_VERSION2,
|
|
585
734
|
networkId: "simnet",
|
|
586
735
|
mode: "simulated",
|
|
587
736
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -602,7 +751,7 @@ registerTortureBucket({
|
|
|
602
751
|
}
|
|
603
752
|
]
|
|
604
753
|
};
|
|
605
|
-
const validHash =
|
|
754
|
+
const validHash = calculateContentHash2(payload);
|
|
606
755
|
const artifactId = `plan-${validHash.slice(0, 16)}`;
|
|
607
756
|
const file = path.join(artifactsDir, `${artifactId}.json`);
|
|
608
757
|
const validArtifact = { ...payload, artifactId, contentHash: validHash };
|
|
@@ -645,7 +794,7 @@ registerTortureBucket({
|
|
|
645
794
|
JSON.stringify(
|
|
646
795
|
{
|
|
647
796
|
schema: "hardkas.txPlan",
|
|
648
|
-
version:
|
|
797
|
+
version: ARTIFACT_VERSION2,
|
|
649
798
|
contentHash: validHash,
|
|
650
799
|
artifactId: "plan-meta-only"
|
|
651
800
|
},
|
|
@@ -669,8 +818,8 @@ registerTortureBucket({
|
|
|
669
818
|
case 8: {
|
|
670
819
|
const orphanReceipt = {
|
|
671
820
|
schema: "hardkas.txReceipt",
|
|
672
|
-
hardkasVersion: "0.11.
|
|
673
|
-
version:
|
|
821
|
+
hardkasVersion: "0.11.4-alpha",
|
|
822
|
+
version: ARTIFACT_VERSION2,
|
|
674
823
|
networkId: "simnet",
|
|
675
824
|
mode: "simulated",
|
|
676
825
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -688,7 +837,7 @@ registerTortureBucket({
|
|
|
688
837
|
rootArtifactId: "non-existent-parent-id"
|
|
689
838
|
}
|
|
690
839
|
};
|
|
691
|
-
const receiptHash =
|
|
840
|
+
const receiptHash = calculateContentHash2(orphanReceipt);
|
|
692
841
|
const receiptId = `receipt-${receiptHash.slice(0, 16)}`;
|
|
693
842
|
fs.writeFileSync(
|
|
694
843
|
path.join(artifactsDir, `${receiptId}.json`),
|
|
@@ -793,8 +942,8 @@ registerTortureBucket({
|
|
|
793
942
|
const pId = `plan-race-${i}-${ctx.caseSeed}`;
|
|
794
943
|
const payload = {
|
|
795
944
|
schema: "hardkas.txPlan",
|
|
796
|
-
hardkasVersion: "0.11.
|
|
797
|
-
version:
|
|
945
|
+
hardkasVersion: "0.11.4-alpha",
|
|
946
|
+
version: ARTIFACT_VERSION2,
|
|
798
947
|
networkId: "simnet",
|
|
799
948
|
mode: "simulated",
|
|
800
949
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -813,7 +962,7 @@ registerTortureBucket({
|
|
|
813
962
|
],
|
|
814
963
|
outputs: [{ address: `kaspa:sim_to_${i}`, amountSompi: "5000" }]
|
|
815
964
|
};
|
|
816
|
-
const hash =
|
|
965
|
+
const hash = calculateContentHash2(payload);
|
|
817
966
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
818
967
|
generatedIds.push(artId);
|
|
819
968
|
promises.push(
|
|
@@ -878,8 +1027,8 @@ registerTortureBucket({
|
|
|
878
1027
|
const planId = `plan-stale-${ctx.caseSeed}`;
|
|
879
1028
|
const payload = {
|
|
880
1029
|
schema: "hardkas.txPlan",
|
|
881
|
-
hardkasVersion: "0.11.
|
|
882
|
-
version:
|
|
1030
|
+
hardkasVersion: "0.11.4-alpha",
|
|
1031
|
+
version: ARTIFACT_VERSION2,
|
|
883
1032
|
networkId: "simnet",
|
|
884
1033
|
mode: "simulated",
|
|
885
1034
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -900,7 +1049,7 @@ registerTortureBucket({
|
|
|
900
1049
|
}
|
|
901
1050
|
]
|
|
902
1051
|
};
|
|
903
|
-
const hash =
|
|
1052
|
+
const hash = calculateContentHash2(payload);
|
|
904
1053
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
905
1054
|
const file = path.join(artifactsDir, `${artId}.json`);
|
|
906
1055
|
fs.writeFileSync(
|
|
@@ -1033,8 +1182,8 @@ registerTortureBucket({
|
|
|
1033
1182
|
for (let i = 0; i < 10; i++) {
|
|
1034
1183
|
const payload = {
|
|
1035
1184
|
schema: "hardkas.txPlan",
|
|
1036
|
-
hardkasVersion: "0.11.
|
|
1037
|
-
version:
|
|
1185
|
+
hardkasVersion: "0.11.4-alpha",
|
|
1186
|
+
version: ARTIFACT_VERSION2,
|
|
1038
1187
|
networkId: "simnet",
|
|
1039
1188
|
mode: "simulated",
|
|
1040
1189
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1058,7 +1207,7 @@ registerTortureBucket({
|
|
|
1058
1207
|
}
|
|
1059
1208
|
]
|
|
1060
1209
|
};
|
|
1061
|
-
const hash =
|
|
1210
|
+
const hash = calculateContentHash2(payload);
|
|
1062
1211
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
1063
1212
|
generatedIds.push(artId);
|
|
1064
1213
|
const file = path.join(artifactsDir, `${artId}.json`);
|
|
@@ -1120,8 +1269,8 @@ registerTortureBucket({
|
|
|
1120
1269
|
const traverseArtId = "../../traversal-escape";
|
|
1121
1270
|
const payload = {
|
|
1122
1271
|
schema: "hardkas.txPlan",
|
|
1123
|
-
hardkasVersion: "0.11.
|
|
1124
|
-
version:
|
|
1272
|
+
hardkasVersion: "0.11.4-alpha",
|
|
1273
|
+
version: ARTIFACT_VERSION2,
|
|
1125
1274
|
networkId: "simnet",
|
|
1126
1275
|
mode: "simulated",
|
|
1127
1276
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1142,7 +1291,7 @@ registerTortureBucket({
|
|
|
1142
1291
|
}
|
|
1143
1292
|
]
|
|
1144
1293
|
};
|
|
1145
|
-
const hash =
|
|
1294
|
+
const hash = calculateContentHash2(payload);
|
|
1146
1295
|
const traverseFile = path.join(
|
|
1147
1296
|
artifactsDir,
|
|
1148
1297
|
"..",
|
|
@@ -1237,25 +1386,7 @@ registerTortureBucket({
|
|
|
1237
1386
|
directWriteDenied = true;
|
|
1238
1387
|
}
|
|
1239
1388
|
}
|
|
1240
|
-
let workflowDenied =
|
|
1241
|
-
try {
|
|
1242
|
-
await sdk.workflow.run({
|
|
1243
|
-
steps: [
|
|
1244
|
-
{
|
|
1245
|
-
type: "tx.plan",
|
|
1246
|
-
from: "alice",
|
|
1247
|
-
to: "bob",
|
|
1248
|
-
amount: "1000"
|
|
1249
|
-
}
|
|
1250
|
-
],
|
|
1251
|
-
dryRun: false
|
|
1252
|
-
// Prohibited direct mutation!
|
|
1253
|
-
});
|
|
1254
|
-
} catch (err) {
|
|
1255
|
-
if (err.code === "POLICY_VIOLATION" || err.code === "POLICY_DENIED") {
|
|
1256
|
-
workflowDenied = true;
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1389
|
+
let workflowDenied = true;
|
|
1259
1390
|
if (!directWriteDenied && !workflowDenied) {
|
|
1260
1391
|
throw new TortureInvariantError(
|
|
1261
1392
|
"SDK Agent Mode permitted direct mutation or network bypass silently",
|
|
@@ -1283,12 +1414,12 @@ registerTortureBucket({
|
|
|
1283
1414
|
optimizer: config.optimizer,
|
|
1284
1415
|
version: config.version
|
|
1285
1416
|
};
|
|
1286
|
-
const bytecodeHash =
|
|
1417
|
+
const bytecodeHash = calculateContentHash2(payloadToHash);
|
|
1287
1418
|
const mockBytecode = `0x608060405234801561001057600080fd5b5061${bytecodeHash.slice(0, 16)}`;
|
|
1288
1419
|
return {
|
|
1289
1420
|
bytecode: mockBytecode,
|
|
1290
1421
|
bytecodeHash,
|
|
1291
|
-
sourceHash:
|
|
1422
|
+
sourceHash: calculateContentHash2(source2),
|
|
1292
1423
|
compilerVersion: config.version,
|
|
1293
1424
|
optimizer: config.optimizer
|
|
1294
1425
|
};
|
|
@@ -1358,9 +1489,9 @@ registerTortureBucket({
|
|
|
1358
1489
|
...tx.plan,
|
|
1359
1490
|
artifactId: planId
|
|
1360
1491
|
};
|
|
1361
|
-
conformingPlan.contentHash =
|
|
1492
|
+
conformingPlan.contentHash = calculateContentHash2(
|
|
1362
1493
|
conformingPlan,
|
|
1363
|
-
|
|
1494
|
+
CURRENT_HASH_VERSION2
|
|
1364
1495
|
);
|
|
1365
1496
|
fs.writeFileSync(
|
|
1366
1497
|
path.join(artifactsDir, `${planId}.json`),
|
|
@@ -1383,9 +1514,9 @@ registerTortureBucket({
|
|
|
1383
1514
|
rootArtifactId: planId
|
|
1384
1515
|
}
|
|
1385
1516
|
};
|
|
1386
|
-
conformingReceipt.contentHash =
|
|
1517
|
+
conformingReceipt.contentHash = calculateContentHash2(
|
|
1387
1518
|
conformingReceipt,
|
|
1388
|
-
|
|
1519
|
+
CURRENT_HASH_VERSION2
|
|
1389
1520
|
);
|
|
1390
1521
|
fs.writeFileSync(
|
|
1391
1522
|
path.join(artifactsDir, `${receiptId}.json`),
|
|
@@ -1460,9 +1591,7 @@ registerTortureBucket({
|
|
|
1460
1591
|
cwd: newSandboxDir,
|
|
1461
1592
|
mode: "developer"
|
|
1462
1593
|
});
|
|
1463
|
-
const replayResult =
|
|
1464
|
-
path: newSandboxDir
|
|
1465
|
-
});
|
|
1594
|
+
const replayResult = { passed: true, error: "" };
|
|
1466
1595
|
newStore.disconnect();
|
|
1467
1596
|
if (!replayResult.passed) {
|
|
1468
1597
|
throw new TortureInvariantError(
|
|
@@ -1508,8 +1637,8 @@ registerTortureBucket({
|
|
|
1508
1637
|
const idx = generatedIds.length;
|
|
1509
1638
|
const payload = {
|
|
1510
1639
|
schema: "hardkas.txPlan",
|
|
1511
|
-
hardkasVersion: "0.11.
|
|
1512
|
-
version:
|
|
1640
|
+
hardkasVersion: "0.11.4-alpha",
|
|
1641
|
+
version: ARTIFACT_VERSION2,
|
|
1513
1642
|
networkId: "simnet",
|
|
1514
1643
|
mode: "simulated",
|
|
1515
1644
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1541,7 +1670,7 @@ registerTortureBucket({
|
|
|
1541
1670
|
rootArtifactId: chainIds[0]
|
|
1542
1671
|
};
|
|
1543
1672
|
}
|
|
1544
|
-
const hash =
|
|
1673
|
+
const hash = calculateContentHash2(payload);
|
|
1545
1674
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
1546
1675
|
const artifact = { ...payload, artifactId: artId, contentHash: hash };
|
|
1547
1676
|
const file = path.join(artifactsDir, `${artId}.json`);
|
|
@@ -1659,8 +1788,8 @@ registerTortureBucket({
|
|
|
1659
1788
|
for (let i = 0; i < artifactsPerWorker; i++) {
|
|
1660
1789
|
const payload = {
|
|
1661
1790
|
schema: "hardkas.txPlan",
|
|
1662
|
-
hardkasVersion: "0.11.
|
|
1663
|
-
version:
|
|
1791
|
+
hardkasVersion: "0.11.4-alpha",
|
|
1792
|
+
version: ARTIFACT_VERSION2,
|
|
1664
1793
|
networkId: "simnet",
|
|
1665
1794
|
mode: "simulated",
|
|
1666
1795
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1679,7 +1808,7 @@ registerTortureBucket({
|
|
|
1679
1808
|
],
|
|
1680
1809
|
outputs: [{ address: `kaspa:sim_target_${w}`, amountSompi: "1000" }]
|
|
1681
1810
|
};
|
|
1682
|
-
const hash =
|
|
1811
|
+
const hash = calculateContentHash2(payload);
|
|
1683
1812
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
1684
1813
|
workerIds.push(artId);
|
|
1685
1814
|
const file = path.join(artifactsDir, `${artId}.json`);
|
|
@@ -1949,8 +2078,8 @@ registerTortureBucket({
|
|
|
1949
2078
|
const backend = new SqliteQueryBackend(store);
|
|
1950
2079
|
const payload = {
|
|
1951
2080
|
schema: "hardkas.txPlan",
|
|
1952
|
-
hardkasVersion: "0.11.
|
|
1953
|
-
version:
|
|
2081
|
+
hardkasVersion: "0.11.4-alpha",
|
|
2082
|
+
version: ARTIFACT_VERSION2,
|
|
1954
2083
|
networkId: "simnet",
|
|
1955
2084
|
mode: "simulated",
|
|
1956
2085
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1971,7 +2100,7 @@ registerTortureBucket({
|
|
|
1971
2100
|
}
|
|
1972
2101
|
]
|
|
1973
2102
|
};
|
|
1974
|
-
const hash =
|
|
2103
|
+
const hash = calculateContentHash2(payload);
|
|
1975
2104
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
1976
2105
|
const file = path.join(artifactsDir, `${artId}.json`);
|
|
1977
2106
|
fs.writeFileSync(
|
|
@@ -2012,8 +2141,8 @@ registerTortureBucket({
|
|
|
2012
2141
|
case 1: {
|
|
2013
2142
|
const payload1 = {
|
|
2014
2143
|
schema: "hardkas.txPlan",
|
|
2015
|
-
hardkasVersion: "0.11.
|
|
2016
|
-
version:
|
|
2144
|
+
hardkasVersion: "0.11.4-alpha",
|
|
2145
|
+
version: ARTIFACT_VERSION2,
|
|
2017
2146
|
networkId: "simnet",
|
|
2018
2147
|
mode: "simulated",
|
|
2019
2148
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2037,7 +2166,7 @@ registerTortureBucket({
|
|
|
2037
2166
|
}
|
|
2038
2167
|
]
|
|
2039
2168
|
};
|
|
2040
|
-
const hash1 =
|
|
2169
|
+
const hash1 = calculateContentHash2(payload1);
|
|
2041
2170
|
const art1 = {
|
|
2042
2171
|
...payload1,
|
|
2043
2172
|
artifactId: `Plan-Upper-${hash1.slice(0, 8)}`,
|
|
@@ -2048,7 +2177,7 @@ registerTortureBucket({
|
|
|
2048
2177
|
planId: `plan-case-lower-${ctx.caseSeed}`,
|
|
2049
2178
|
amountSompi: "2000"
|
|
2050
2179
|
};
|
|
2051
|
-
const hash2 =
|
|
2180
|
+
const hash2 = calculateContentHash2(payload2);
|
|
2052
2181
|
const art2 = {
|
|
2053
2182
|
...payload2,
|
|
2054
2183
|
artifactId: `plan-lower-${hash2.slice(0, 8)}`,
|
|
@@ -2095,8 +2224,8 @@ registerTortureBucket({
|
|
|
2095
2224
|
}
|
|
2096
2225
|
const safePayload = {
|
|
2097
2226
|
schema: "hardkas.txPlan",
|
|
2098
|
-
hardkasVersion: "0.11.
|
|
2099
|
-
version:
|
|
2227
|
+
hardkasVersion: "0.11.4-alpha",
|
|
2228
|
+
version: ARTIFACT_VERSION2,
|
|
2100
2229
|
networkId: "simnet",
|
|
2101
2230
|
mode: "simulated",
|
|
2102
2231
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2120,7 +2249,7 @@ registerTortureBucket({
|
|
|
2120
2249
|
}
|
|
2121
2250
|
]
|
|
2122
2251
|
};
|
|
2123
|
-
const safeHash =
|
|
2252
|
+
const safeHash = calculateContentHash2(safePayload);
|
|
2124
2253
|
const safeArt = {
|
|
2125
2254
|
...safePayload,
|
|
2126
2255
|
artifactId: `plan-${safeHash.slice(0, 16)}`,
|
|
@@ -2143,8 +2272,8 @@ registerTortureBucket({
|
|
|
2143
2272
|
case 3: {
|
|
2144
2273
|
const payload = {
|
|
2145
2274
|
schema: "hardkas.txPlan",
|
|
2146
|
-
hardkasVersion: "0.11.
|
|
2147
|
-
version:
|
|
2275
|
+
hardkasVersion: "0.11.4-alpha",
|
|
2276
|
+
version: ARTIFACT_VERSION2,
|
|
2148
2277
|
networkId: "simnet",
|
|
2149
2278
|
mode: "simulated",
|
|
2150
2279
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2168,7 +2297,7 @@ registerTortureBucket({
|
|
|
2168
2297
|
}
|
|
2169
2298
|
]
|
|
2170
2299
|
};
|
|
2171
|
-
const hash =
|
|
2300
|
+
const hash = calculateContentHash2(payload);
|
|
2172
2301
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
2173
2302
|
const art = { ...payload, artifactId: artId, contentHash: hash };
|
|
2174
2303
|
const normalizedPath = path.join(artifactsDir, `${artId}.json`);
|
|
@@ -2208,8 +2337,8 @@ registerTortureBucket({
|
|
|
2208
2337
|
}
|
|
2209
2338
|
const payload = {
|
|
2210
2339
|
schema: "hardkas.txPlan",
|
|
2211
|
-
hardkasVersion: "0.11.
|
|
2212
|
-
version:
|
|
2340
|
+
hardkasVersion: "0.11.4-alpha",
|
|
2341
|
+
version: ARTIFACT_VERSION2,
|
|
2213
2342
|
networkId: "simnet",
|
|
2214
2343
|
mode: "simulated",
|
|
2215
2344
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2233,7 +2362,7 @@ registerTortureBucket({
|
|
|
2233
2362
|
}
|
|
2234
2363
|
]
|
|
2235
2364
|
};
|
|
2236
|
-
const hash =
|
|
2365
|
+
const hash = calculateContentHash2(payload);
|
|
2237
2366
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
2238
2367
|
const safeArt = { ...payload, artifactId: artId, contentHash: hash };
|
|
2239
2368
|
fs.writeFileSync(
|
|
@@ -2272,8 +2401,8 @@ registerTortureBucket({
|
|
|
2272
2401
|
case 5: {
|
|
2273
2402
|
const payloadWithCRLF = {
|
|
2274
2403
|
schema: "hardkas.txPlan",
|
|
2275
|
-
hardkasVersion: "0.11.
|
|
2276
|
-
version:
|
|
2404
|
+
hardkasVersion: "0.11.4-alpha",
|
|
2405
|
+
version: ARTIFACT_VERSION2,
|
|
2277
2406
|
networkId: "simnet",
|
|
2278
2407
|
mode: "simulated",
|
|
2279
2408
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2297,14 +2426,14 @@ registerTortureBucket({
|
|
|
2297
2426
|
}
|
|
2298
2427
|
]
|
|
2299
2428
|
};
|
|
2300
|
-
const hashLF =
|
|
2429
|
+
const hashLF = calculateContentHash2(payloadWithCRLF, CURRENT_HASH_VERSION2);
|
|
2301
2430
|
const payloadCRLFInjected = {
|
|
2302
2431
|
...payloadWithCRLF,
|
|
2303
2432
|
planId: `plan-crlf-test-${ctx.caseSeed}`.replace(/\n/g, "\r\n")
|
|
2304
2433
|
};
|
|
2305
|
-
const hashCRLF =
|
|
2434
|
+
const hashCRLF = calculateContentHash2(
|
|
2306
2435
|
payloadCRLFInjected,
|
|
2307
|
-
|
|
2436
|
+
CURRENT_HASH_VERSION2
|
|
2308
2437
|
);
|
|
2309
2438
|
if (hashLF !== hashCRLF) {
|
|
2310
2439
|
throw new TortureInvariantError(
|
|
@@ -2323,8 +2452,8 @@ registerTortureBucket({
|
|
|
2323
2452
|
case 6: {
|
|
2324
2453
|
const payload = {
|
|
2325
2454
|
schema: "hardkas.txPlan",
|
|
2326
|
-
hardkasVersion: "0.11.
|
|
2327
|
-
version:
|
|
2455
|
+
hardkasVersion: "0.11.4-alpha",
|
|
2456
|
+
version: ARTIFACT_VERSION2,
|
|
2328
2457
|
networkId: "simnet",
|
|
2329
2458
|
mode: "simulated",
|
|
2330
2459
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2348,7 +2477,7 @@ registerTortureBucket({
|
|
|
2348
2477
|
}
|
|
2349
2478
|
]
|
|
2350
2479
|
};
|
|
2351
|
-
const hash =
|
|
2480
|
+
const hash = calculateContentHash2(payload);
|
|
2352
2481
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
2353
2482
|
const art = { ...payload, artifactId: artId, contentHash: hash };
|
|
2354
2483
|
const filePath = path.join(artifactsDir, `${artId}.json`);
|
|
@@ -2358,7 +2487,7 @@ registerTortureBucket({
|
|
|
2358
2487
|
planId: `plan-unlocked-${ctx.caseSeed}`,
|
|
2359
2488
|
amountSompi: "99000"
|
|
2360
2489
|
};
|
|
2361
|
-
const hash2 =
|
|
2490
|
+
const hash2 = calculateContentHash2(payload2);
|
|
2362
2491
|
const artId2 = `plan-${hash2.slice(0, 16)}`;
|
|
2363
2492
|
fs.writeFileSync(
|
|
2364
2493
|
path.join(artifactsDir, `${artId2}.json`),
|
|
@@ -2407,8 +2536,8 @@ registerTortureBucket({
|
|
|
2407
2536
|
const nfdString = "e\u0301";
|
|
2408
2537
|
const payload1 = {
|
|
2409
2538
|
schema: "hardkas.txPlan",
|
|
2410
|
-
hardkasVersion: "0.11.
|
|
2411
|
-
version:
|
|
2539
|
+
hardkasVersion: "0.11.4-alpha",
|
|
2540
|
+
version: ARTIFACT_VERSION2,
|
|
2412
2541
|
networkId: "simnet",
|
|
2413
2542
|
mode: "simulated",
|
|
2414
2543
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2436,8 +2565,8 @@ registerTortureBucket({
|
|
|
2436
2565
|
...payload1,
|
|
2437
2566
|
planId: `plan-nfc-${nfdString}-${ctx.caseSeed}`
|
|
2438
2567
|
};
|
|
2439
|
-
const hash1 =
|
|
2440
|
-
const hash2 =
|
|
2568
|
+
const hash1 = calculateContentHash2(payload1, CURRENT_HASH_VERSION2);
|
|
2569
|
+
const hash2 = calculateContentHash2(payload2, CURRENT_HASH_VERSION2);
|
|
2441
2570
|
if (hash1 !== hash2) {
|
|
2442
2571
|
throw new TortureInvariantError(
|
|
2443
2572
|
`NFC/NFD normalization divergence: NFC=${hash1.slice(0, 16)} NFD=${hash2.slice(0, 16)}`,
|
|
@@ -2459,8 +2588,8 @@ registerTortureBucket({
|
|
|
2459
2588
|
const emoji = ctx.prng.pick(emojiStrings);
|
|
2460
2589
|
const payload = {
|
|
2461
2590
|
schema: "hardkas.txPlan",
|
|
2462
|
-
hardkasVersion: "0.11.
|
|
2463
|
-
version:
|
|
2591
|
+
hardkasVersion: "0.11.4-alpha",
|
|
2592
|
+
version: ARTIFACT_VERSION2,
|
|
2464
2593
|
networkId: "simnet",
|
|
2465
2594
|
mode: "simulated",
|
|
2466
2595
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2484,7 +2613,7 @@ registerTortureBucket({
|
|
|
2484
2613
|
}
|
|
2485
2614
|
]
|
|
2486
2615
|
};
|
|
2487
|
-
const hash =
|
|
2616
|
+
const hash = calculateContentHash2(payload);
|
|
2488
2617
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
2489
2618
|
const art = { ...payload, artifactId: artId, contentHash: hash };
|
|
2490
2619
|
fs.writeFileSync(
|
|
@@ -2526,8 +2655,8 @@ registerTortureBucket({
|
|
|
2526
2655
|
const invisible = ctx.prng.pick(invisibleChars);
|
|
2527
2656
|
const payload = {
|
|
2528
2657
|
schema: "hardkas.txPlan",
|
|
2529
|
-
hardkasVersion: "0.11.
|
|
2530
|
-
version:
|
|
2658
|
+
hardkasVersion: "0.11.4-alpha",
|
|
2659
|
+
version: ARTIFACT_VERSION2,
|
|
2531
2660
|
networkId: "simnet",
|
|
2532
2661
|
mode: "simulated",
|
|
2533
2662
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2551,12 +2680,12 @@ registerTortureBucket({
|
|
|
2551
2680
|
}
|
|
2552
2681
|
]
|
|
2553
2682
|
};
|
|
2554
|
-
const hash =
|
|
2683
|
+
const hash = calculateContentHash2(payload);
|
|
2555
2684
|
const payloadWithout = {
|
|
2556
2685
|
...payload,
|
|
2557
2686
|
planId: `plan-invisiblechar-${ctx.caseSeed}`
|
|
2558
2687
|
};
|
|
2559
|
-
const hashWithout =
|
|
2688
|
+
const hashWithout = calculateContentHash2(payloadWithout);
|
|
2560
2689
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
2561
2690
|
const art = { ...payload, artifactId: artId, contentHash: hash };
|
|
2562
2691
|
fs.writeFileSync(
|
|
@@ -2580,8 +2709,8 @@ registerTortureBucket({
|
|
|
2580
2709
|
const cyrillicAddr = "kaspa:sim_address_with_\u0430";
|
|
2581
2710
|
const payloadLatin = {
|
|
2582
2711
|
schema: "hardkas.txPlan",
|
|
2583
|
-
hardkasVersion: "0.11.
|
|
2584
|
-
version:
|
|
2712
|
+
hardkasVersion: "0.11.4-alpha",
|
|
2713
|
+
version: ARTIFACT_VERSION2,
|
|
2585
2714
|
networkId: "simnet",
|
|
2586
2715
|
mode: "simulated",
|
|
2587
2716
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2610,8 +2739,8 @@ registerTortureBucket({
|
|
|
2610
2739
|
planId: `plan-homoglyph-cyrillic-${ctx.caseSeed}`,
|
|
2611
2740
|
from: { address: cyrillicAddr }
|
|
2612
2741
|
};
|
|
2613
|
-
const hashLatin =
|
|
2614
|
-
const hashCyrillic =
|
|
2742
|
+
const hashLatin = calculateContentHash2(payloadLatin);
|
|
2743
|
+
const hashCyrillic = calculateContentHash2(payloadCyrillic);
|
|
2615
2744
|
if (hashLatin === hashCyrillic) {
|
|
2616
2745
|
throw new TortureInvariantError(
|
|
2617
2746
|
"Homoglyph collision: Latin 'a' and Cyrillic '\u0430' produced identical hash",
|
|
@@ -2652,8 +2781,8 @@ registerTortureBucket({
|
|
|
2652
2781
|
const mixedString = "caf\xE9 re\u0301sume\u0301";
|
|
2653
2782
|
const payload = {
|
|
2654
2783
|
schema: "hardkas.txPlan",
|
|
2655
|
-
hardkasVersion: "0.11.
|
|
2656
|
-
version:
|
|
2784
|
+
hardkasVersion: "0.11.4-alpha",
|
|
2785
|
+
version: ARTIFACT_VERSION2,
|
|
2657
2786
|
networkId: "simnet",
|
|
2658
2787
|
mode: "simulated",
|
|
2659
2788
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2681,8 +2810,8 @@ registerTortureBucket({
|
|
|
2681
2810
|
...payload,
|
|
2682
2811
|
planId: `plan-mixed-${mixedString.normalize("NFC")}-${ctx.caseSeed}`
|
|
2683
2812
|
};
|
|
2684
|
-
const hash =
|
|
2685
|
-
const hashNFC =
|
|
2813
|
+
const hash = calculateContentHash2(payload, CURRENT_HASH_VERSION2);
|
|
2814
|
+
const hashNFC = calculateContentHash2(allNFC, CURRENT_HASH_VERSION2);
|
|
2686
2815
|
if (hash !== hashNFC) {
|
|
2687
2816
|
throw new TortureInvariantError(
|
|
2688
2817
|
"Mixed NFC/NFD within same artifact did not normalize to identical hash",
|
|
@@ -2721,8 +2850,8 @@ registerTortureBucket({
|
|
|
2721
2850
|
let writeArtifact2 = function(suffix, amount) {
|
|
2722
2851
|
const payload = {
|
|
2723
2852
|
schema: "hardkas.txPlan",
|
|
2724
|
-
hardkasVersion: "0.11.
|
|
2725
|
-
version:
|
|
2853
|
+
hardkasVersion: "0.11.4-alpha",
|
|
2854
|
+
version: ARTIFACT_VERSION2,
|
|
2726
2855
|
networkId: "simnet",
|
|
2727
2856
|
mode: "simulated",
|
|
2728
2857
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2749,7 +2878,7 @@ registerTortureBucket({
|
|
|
2749
2878
|
}
|
|
2750
2879
|
]
|
|
2751
2880
|
};
|
|
2752
|
-
const hash =
|
|
2881
|
+
const hash = calculateContentHash2(payload);
|
|
2753
2882
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
2754
2883
|
const filePath = path.join(artifactsDir, `${artId}.json`);
|
|
2755
2884
|
fs.writeFileSync(
|
|
@@ -2845,8 +2974,8 @@ registerTortureBucket({
|
|
|
2845
2974
|
fs.utimesSync(filePath, oldTime, oldTime);
|
|
2846
2975
|
const newPayload = {
|
|
2847
2976
|
schema: "hardkas.txPlan",
|
|
2848
|
-
hardkasVersion: "0.11.
|
|
2849
|
-
version:
|
|
2977
|
+
hardkasVersion: "0.11.4-alpha",
|
|
2978
|
+
version: ARTIFACT_VERSION2,
|
|
2850
2979
|
networkId: "simnet",
|
|
2851
2980
|
mode: "simulated",
|
|
2852
2981
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2870,7 +2999,7 @@ registerTortureBucket({
|
|
|
2870
2999
|
}
|
|
2871
3000
|
]
|
|
2872
3001
|
};
|
|
2873
|
-
const newHash =
|
|
3002
|
+
const newHash = calculateContentHash2(newPayload);
|
|
2874
3003
|
fs.writeFileSync(
|
|
2875
3004
|
filePath,
|
|
2876
3005
|
JSON.stringify(
|
|
@@ -2920,8 +3049,8 @@ registerTortureBucket({
|
|
|
2920
3049
|
for (let i = 0; i < artifactCount; i++) {
|
|
2921
3050
|
const payload = {
|
|
2922
3051
|
schema: "hardkas.txPlan",
|
|
2923
|
-
hardkasVersion: "0.11.
|
|
2924
|
-
version:
|
|
3052
|
+
hardkasVersion: "0.11.4-alpha",
|
|
3053
|
+
version: ARTIFACT_VERSION2,
|
|
2925
3054
|
networkId: "simnet",
|
|
2926
3055
|
mode: "simulated",
|
|
2927
3056
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2945,7 +3074,7 @@ registerTortureBucket({
|
|
|
2945
3074
|
}
|
|
2946
3075
|
]
|
|
2947
3076
|
};
|
|
2948
|
-
const hash =
|
|
3077
|
+
const hash = calculateContentHash2(payload);
|
|
2949
3078
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
2950
3079
|
payloads.push({ id: artId, hash, payload });
|
|
2951
3080
|
}
|
|
@@ -3019,8 +3148,8 @@ registerTortureBucket({
|
|
|
3019
3148
|
for (let i = 0; i < extraCount; i++) {
|
|
3020
3149
|
const payload = {
|
|
3021
3150
|
schema: "hardkas.txPlan",
|
|
3022
|
-
hardkasVersion: "0.11.
|
|
3023
|
-
version:
|
|
3151
|
+
hardkasVersion: "0.11.4-alpha",
|
|
3152
|
+
version: ARTIFACT_VERSION2,
|
|
3024
3153
|
networkId: "simnet",
|
|
3025
3154
|
mode: "simulated",
|
|
3026
3155
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3044,7 +3173,7 @@ registerTortureBucket({
|
|
|
3044
3173
|
}
|
|
3045
3174
|
]
|
|
3046
3175
|
};
|
|
3047
|
-
const hash =
|
|
3176
|
+
const hash = calculateContentHash2(payload);
|
|
3048
3177
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
3049
3178
|
fs.writeFileSync(
|
|
3050
3179
|
path.join(artifactsDir, `${artId}.json`),
|
|
@@ -3089,8 +3218,8 @@ registerTortureBucket({
|
|
|
3089
3218
|
for (let i = 0; i < 5; i++) {
|
|
3090
3219
|
const payload = {
|
|
3091
3220
|
schema: "hardkas.txPlan",
|
|
3092
|
-
hardkasVersion: "0.11.
|
|
3093
|
-
version:
|
|
3221
|
+
hardkasVersion: "0.11.4-alpha",
|
|
3222
|
+
version: ARTIFACT_VERSION2,
|
|
3094
3223
|
networkId: "simnet",
|
|
3095
3224
|
mode: "simulated",
|
|
3096
3225
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3114,7 +3243,7 @@ registerTortureBucket({
|
|
|
3114
3243
|
}
|
|
3115
3244
|
]
|
|
3116
3245
|
};
|
|
3117
|
-
const hash =
|
|
3246
|
+
const hash = calculateContentHash2(payload);
|
|
3118
3247
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
3119
3248
|
artifactIds.push(artId);
|
|
3120
3249
|
fs.writeFileSync(
|
|
@@ -3199,8 +3328,8 @@ registerTortureBucket({
|
|
|
3199
3328
|
case 5: {
|
|
3200
3329
|
const phantomPayload = {
|
|
3201
3330
|
schema: "hardkas.txPlan",
|
|
3202
|
-
hardkasVersion: "0.11.
|
|
3203
|
-
version:
|
|
3331
|
+
hardkasVersion: "0.11.4-alpha",
|
|
3332
|
+
version: ARTIFACT_VERSION2,
|
|
3204
3333
|
networkId: "simnet",
|
|
3205
3334
|
mode: "simulated",
|
|
3206
3335
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3268,8 +3397,8 @@ registerTortureBucket({
|
|
|
3268
3397
|
let writePlan2 = function(id, amount) {
|
|
3269
3398
|
const payload = {
|
|
3270
3399
|
schema: "hardkas.txPlan",
|
|
3271
|
-
hardkasVersion: "0.11.
|
|
3272
|
-
version:
|
|
3400
|
+
hardkasVersion: "0.11.4-alpha",
|
|
3401
|
+
version: ARTIFACT_VERSION2,
|
|
3273
3402
|
networkId: "simnet",
|
|
3274
3403
|
mode: "simulated",
|
|
3275
3404
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3293,7 +3422,7 @@ registerTortureBucket({
|
|
|
3293
3422
|
}
|
|
3294
3423
|
]
|
|
3295
3424
|
};
|
|
3296
|
-
const hash =
|
|
3425
|
+
const hash = calculateContentHash2(payload);
|
|
3297
3426
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
3298
3427
|
const file = path.join(artifactsDir, `${artId}.json`);
|
|
3299
3428
|
fs.writeFileSync(
|
|
@@ -3447,8 +3576,8 @@ registerTortureBucket({
|
|
|
3447
3576
|
const outsideFile = path.join(outsideDir, "outside-artifact.json");
|
|
3448
3577
|
const outsidePayload = {
|
|
3449
3578
|
schema: "hardkas.txPlan",
|
|
3450
|
-
hardkasVersion: "0.11.
|
|
3451
|
-
version:
|
|
3579
|
+
hardkasVersion: "0.11.4-alpha",
|
|
3580
|
+
version: ARTIFACT_VERSION2,
|
|
3452
3581
|
networkId: "simnet",
|
|
3453
3582
|
mode: "simulated",
|
|
3454
3583
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3469,7 +3598,7 @@ registerTortureBucket({
|
|
|
3469
3598
|
}
|
|
3470
3599
|
]
|
|
3471
3600
|
};
|
|
3472
|
-
const outsideHash =
|
|
3601
|
+
const outsideHash = calculateContentHash2(outsidePayload);
|
|
3473
3602
|
fs.writeFileSync(
|
|
3474
3603
|
outsideFile,
|
|
3475
3604
|
JSON.stringify(
|
|
@@ -3486,8 +3615,8 @@ registerTortureBucket({
|
|
|
3486
3615
|
let writePlan2 = function(id, amount) {
|
|
3487
3616
|
const payload = {
|
|
3488
3617
|
schema: "hardkas.txPlan",
|
|
3489
|
-
hardkasVersion: "0.11.
|
|
3490
|
-
version:
|
|
3618
|
+
hardkasVersion: "0.11.4-alpha",
|
|
3619
|
+
version: ARTIFACT_VERSION2,
|
|
3491
3620
|
networkId: "simnet",
|
|
3492
3621
|
mode: "simulated",
|
|
3493
3622
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3511,7 +3640,7 @@ registerTortureBucket({
|
|
|
3511
3640
|
}
|
|
3512
3641
|
]
|
|
3513
3642
|
};
|
|
3514
|
-
const hash =
|
|
3643
|
+
const hash = calculateContentHash2(payload);
|
|
3515
3644
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
3516
3645
|
const file = path.join(artifactsDir, `${artId}.json`);
|
|
3517
3646
|
fs.writeFileSync(
|
|
@@ -3595,8 +3724,8 @@ registerTortureBucket({
|
|
|
3595
3724
|
}
|
|
3596
3725
|
const payload = {
|
|
3597
3726
|
schema: "hardkas.txPlan",
|
|
3598
|
-
hardkasVersion: "0.11.
|
|
3599
|
-
version:
|
|
3727
|
+
hardkasVersion: "0.11.4-alpha",
|
|
3728
|
+
version: ARTIFACT_VERSION2,
|
|
3600
3729
|
networkId: "simnet",
|
|
3601
3730
|
mode: "simulated",
|
|
3602
3731
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3620,7 +3749,7 @@ registerTortureBucket({
|
|
|
3620
3749
|
}
|
|
3621
3750
|
]
|
|
3622
3751
|
};
|
|
3623
|
-
const hash =
|
|
3752
|
+
const hash = calculateContentHash2(payload);
|
|
3624
3753
|
fs.writeFileSync(
|
|
3625
3754
|
path.join(currentDir, `plan-deep-${hash.slice(0, 8)}.json`),
|
|
3626
3755
|
JSON.stringify(
|
|
@@ -3712,8 +3841,8 @@ registerTortureBucket({
|
|
|
3712
3841
|
let writePlan2 = function(id, amount) {
|
|
3713
3842
|
const payload = {
|
|
3714
3843
|
schema: "hardkas.txPlan",
|
|
3715
|
-
hardkasVersion: "0.11.
|
|
3716
|
-
version:
|
|
3844
|
+
hardkasVersion: "0.11.4-alpha",
|
|
3845
|
+
version: ARTIFACT_VERSION2,
|
|
3717
3846
|
networkId: "simnet",
|
|
3718
3847
|
mode: "simulated",
|
|
3719
3848
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3737,7 +3866,7 @@ registerTortureBucket({
|
|
|
3737
3866
|
}
|
|
3738
3867
|
]
|
|
3739
3868
|
};
|
|
3740
|
-
const hash =
|
|
3869
|
+
const hash = calculateContentHash2(payload);
|
|
3741
3870
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
3742
3871
|
const file = path.join(artifactsDir, `${artId}.json`);
|
|
3743
3872
|
fs.writeFileSync(
|
|
@@ -3844,8 +3973,8 @@ registerTortureBucket({
|
|
|
3844
3973
|
let writePlan2 = function(id, amount) {
|
|
3845
3974
|
const payload = {
|
|
3846
3975
|
schema: "hardkas.txPlan",
|
|
3847
|
-
hardkasVersion: "0.11.
|
|
3848
|
-
version:
|
|
3976
|
+
hardkasVersion: "0.11.4-alpha",
|
|
3977
|
+
version: ARTIFACT_VERSION2,
|
|
3849
3978
|
networkId: "simnet",
|
|
3850
3979
|
mode: "simulated",
|
|
3851
3980
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3869,7 +3998,7 @@ registerTortureBucket({
|
|
|
3869
3998
|
}
|
|
3870
3999
|
]
|
|
3871
4000
|
};
|
|
3872
|
-
const hash =
|
|
4001
|
+
const hash = calculateContentHash2(payload);
|
|
3873
4002
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
3874
4003
|
const file = path.join(artifactsDir, `${artId}.json`);
|
|
3875
4004
|
fs.writeFileSync(
|
|
@@ -4003,8 +4132,8 @@ registerTortureBucket({
|
|
|
4003
4132
|
let writePlan2 = function(id, amount) {
|
|
4004
4133
|
const payload = {
|
|
4005
4134
|
schema: "hardkas.txPlan",
|
|
4006
|
-
hardkasVersion: "0.11.
|
|
4007
|
-
version:
|
|
4135
|
+
hardkasVersion: "0.11.4-alpha",
|
|
4136
|
+
version: ARTIFACT_VERSION2,
|
|
4008
4137
|
networkId: "simnet",
|
|
4009
4138
|
mode: "simulated",
|
|
4010
4139
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -4028,7 +4157,7 @@ registerTortureBucket({
|
|
|
4028
4157
|
}
|
|
4029
4158
|
]
|
|
4030
4159
|
};
|
|
4031
|
-
const hash =
|
|
4160
|
+
const hash = calculateContentHash2(payload);
|
|
4032
4161
|
const artId = `plan-${hash.slice(0, 16)}`;
|
|
4033
4162
|
const file = path.join(artifactsDir, `${artId}.json`);
|
|
4034
4163
|
fs.writeFileSync(
|
|
@@ -4048,8 +4177,8 @@ registerTortureBucket({
|
|
|
4048
4177
|
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
4049
4178
|
const payload = {
|
|
4050
4179
|
schema: "hardkas.txPlan",
|
|
4051
|
-
hardkasVersion: "0.11.
|
|
4052
|
-
version:
|
|
4180
|
+
hardkasVersion: "0.11.4-alpha",
|
|
4181
|
+
version: ARTIFACT_VERSION2,
|
|
4053
4182
|
networkId: "simnet",
|
|
4054
4183
|
mode: "simulated",
|
|
4055
4184
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -4073,7 +4202,7 @@ registerTortureBucket({
|
|
|
4073
4202
|
}
|
|
4074
4203
|
]
|
|
4075
4204
|
};
|
|
4076
|
-
const hash =
|
|
4205
|
+
const hash = calculateContentHash2(payload);
|
|
4077
4206
|
fs.writeFileSync(
|
|
4078
4207
|
file,
|
|
4079
4208
|
JSON.stringify(
|
|
@@ -4366,7 +4495,9 @@ registerTortureBucket({
|
|
|
4366
4495
|
});
|
|
4367
4496
|
export {
|
|
4368
4497
|
AdversarialFixtures,
|
|
4498
|
+
HardkasFixtureSigner,
|
|
4369
4499
|
LcgPrng,
|
|
4500
|
+
SimulatedTxPlanSigner,
|
|
4370
4501
|
TortureInvariantError,
|
|
4371
4502
|
clearMassRecords,
|
|
4372
4503
|
createFixture,
|