{
  "version": 3,
  "sources": ["../../src/contract-tests.ts"],
  "sourcesContent": ["import {execSync} from 'child_process';\nimport path from 'node:path';\n\nimport type {compile} from 'dredd-transactions';\n\nimport {assert} from '@code-like-a-carpenter/assert';\n\nimport {testTransaction} from './tests.ts';\n\n/**\n * This is awful: it calls parse and compile from dredd-transactions using a\n * synchronous child process. I haven't found any other way to make a JS process\n * behave synchronously.\n * @param blueprintPath\n */\nexport function parseAndCompileSync(\n  blueprintPath: string\n): ReturnType<typeof compile> {\n  assert(path.isAbsolute(blueprintPath), 'blueprintPath must be absolute');\n\n  const script = `\n    async function fn() {\n      const {compile, parse} = await import('dredd-transactions');\n      const fs = await import('fs');\n      const blueprint = '${blueprintPath}';\n      const api = await fs.promises.readFile(blueprint, 'utf8');\n\n      return await new Promise((resolve, reject) => {\n        parse(api, (err, {mediaType, apiElements}) => {\n          if (err) {\n            reject(err);\n            return;\n          }\n          resolve(compile(mediaType, apiElements));\n        });\n      });\n    }\n\n    (async () => {\n      console.log(JSON.stringify(await fn()));\n    })();\n  `;\n\n  return JSON.parse(execSync(`node -e \"${script}\"`).toString());\n}\n\nexport interface BuildContractTestsInput {\n  blueprintPath: string;\n  baseUrl: string;\n}\n\nexport function buildContractTests({\n  baseUrl,\n  blueprintPath,\n}: BuildContractTestsInput) {\n  const {transactions} = parseAndCompileSync(blueprintPath);\n\n  transactions.forEach((transaction) => {\n    it(\n      transaction.name,\n      async () => {\n        await testTransaction(transaction, baseUrl);\n      },\n      10000\n    );\n  });\n}\n"],
  "mappings": ";AAAA,SAAQ,gBAAe;AACvB,OAAO,UAAU;AAIjB,SAAQ,cAAa;AAErB,SAAQ,uBAAsB;AAQvB,SAAS,oBACd,eAC4B;AAC5B,SAAO,KAAK,WAAW,aAAa,GAAG,gCAAgC;AAEvE,QAAM,SAAS;AAAA;AAAA;AAAA;AAAA,2BAIU,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBtC,SAAO,KAAK,MAAM,SAAS,YAAY,MAAM,GAAG,EAAE,SAAS,CAAC;AAC9D;AAOO,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AACF,GAA4B;AAC1B,QAAM,EAAC,aAAY,IAAI,oBAAoB,aAAa;AAExD,eAAa,QAAQ,CAAC,gBAAgB;AACpC;AAAA,MACE,YAAY;AAAA,MACZ,YAAY;AACV,cAAM,gBAAgB,aAAa,OAAO;AAAA,MAC5C;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACH;",
  "names": []
}
