- Move fixture-provider.test.ts up to test/ (test:unit's glob is packages/*/test/*.test.ts, deliberately shallow, so a nested test/fixtures/ file was silently never run). The fixture module itself (fixture-provider.ts, the capture script, the JSON fixture) stays in test/fixtures/; only the *.test.ts file moved, importing it via ./fixtures/fixture-provider.ts. - Harden capture-protocol-params.mjs: refuse to write a fixture whose costModels/coinsPerUtxoByte/keyDeposit could have come from OgmiosProvider's own `??` fallback defaults instead of a genuine response. The brief's sanity numbers (minFeeA 45, minFeeB 156253, ...) are literally those same fallback literals, so matching them proves nothing; costModels has no populated fallback, so a well-formed, appropriately-sized cost model per Plutus version is the one signal a schema-mismatched response cannot fake. - packages/builder/tsconfig.json: include test/**/* so `npm run typecheck` actually checks builder's test files (it previously covered src/**/* only, unlike packages/shared). Needed allowImportingTsExtensions for the now-in-scope relative .ts-suffixed imports across every existing test file. Surfaced one real pre-existing gap: auth.test.ts calls loadAuthConfig with deliberately minimal env objects, but the exported signature demanded the full env.d.ts-augmented NodeJS.ProcessEnv (7 required custom fields) even though the function only ever reads MCP_AUTH_TOKENS. Narrowed the parameter to Record<string, string | undefined> - the function's real contract - which is a type-only change with a single production call site (index.ts's parameterless loadAuthConfig()) that already relies on the default. Verified: test:unit 117/117 (was 113 - the 4 fixture tests were never counted before), typecheck 0 errors, test:smoke 28/28, build unaffected. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
41 lines
2.0 KiB
TypeScript
41 lines
2.0 KiB
TypeScript
// packages/builder/test/fixture-provider.test.ts
|
|
import { describe, test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { Lucid } from '@lucid-evolution/lucid';
|
|
import { FixtureProvider, fixtureProtocolParameters, FIXTURE_UTXOS, OWN_ADDRESS, FOREIGN_ADDRESS } from './fixtures/fixture-provider.ts';
|
|
|
|
describe('FixtureProvider', () => {
|
|
test('serves the captured protocol parameters with bigints revived', () => {
|
|
const p = fixtureProtocolParameters();
|
|
assert.equal(p.minFeeA, 45);
|
|
assert.equal(p.minFeeB, 156253);
|
|
assert.equal(typeof p.coinsPerUtxoByte, 'bigint');
|
|
assert.ok(p.costModels.PlutusV2, 'PlutusV2 cost model missing from fixture');
|
|
});
|
|
|
|
test('getUtxos filters by address and returns nothing for a foreign address', async () => {
|
|
const provider = new FixtureProvider(FIXTURE_UTXOS);
|
|
assert.equal((await provider.getUtxos(OWN_ADDRESS)).length, 3);
|
|
assert.equal((await provider.getUtxos(FOREIGN_ADDRESS)).length, 0);
|
|
});
|
|
|
|
test('network-only methods throw loudly instead of hanging', async () => {
|
|
const provider = new FixtureProvider(FIXTURE_UTXOS);
|
|
await assert.rejects(() => provider.submitTx('84'), /offline/);
|
|
await assert.rejects(() => provider.getDelegation('stake1xyz'), /offline/);
|
|
});
|
|
|
|
// The offline replication of the PR-4 spike: a REAL unsigned transaction,
|
|
// built with no key and no network. If this test passes, every later build
|
|
// test has a working foundation.
|
|
test('Lucid + FixtureProvider builds a real unsigned tx via fromAddress', async () => {
|
|
const lucid = await Lucid(new FixtureProvider(FIXTURE_UTXOS), 'Mainnet');
|
|
const utxos = await lucid.utxosAt(OWN_ADDRESS);
|
|
lucid.selectWallet.fromAddress(OWN_ADDRESS, utxos);
|
|
const tx = await lucid.newTx().pay.ToAddress(FOREIGN_ADDRESS, { lovelace: 3_000_000n }).complete();
|
|
const cbor = tx.toCBOR();
|
|
assert.ok(cbor.length > 200, `unsigned tx CBOR suspiciously short: ${cbor.length} hex chars`);
|
|
assert.match(cbor, /^84/, 'Conway-era tx CBOR must start with array header 0x84');
|
|
});
|
|
});
|