MCPcopy Create free account
hub / github.com/d1ll0n/stack-packer / generateFoundryTest

Function generateFoundryTest

src/code-gen/test/foundry.ts:207–240  ·  view source on GitHub ↗
(
  struct: ProcessedStruct,
  functions: CodeGenFunction[],
  libraryName: string
)

Source from the content-addressed store, hash-verified

205}
206
207export function generateFoundryTest(
208 struct: ProcessedStruct,
209 functions: CodeGenFunction[],
210 libraryName: string
211) {
212 const fnTests: ArrayJoinInput<string>[] = [];
213 for (const fn of functions) {
214 const code = generateFoundryTestForFunction(struct, fn, libraryName)
215 if (code) fnTests.push(...code, '');
216 }
217 removeTrailingNewLines(fnTests)
218 // const fnTests = functions.map(fn => generateFoundryTestForFunction(fn, libraryName)).filter(Boolean);
219 const contractName = `external${libraryName}`;
220 const testFile = [
221 `import { ethers } from 'hardhat';`,
222 `import { expect } from "chai";`,
223 '',
224 `describe('${libraryName}Coder.sol', () => {`,
225 [
226 `let ${contractName}: any;`,
227 '',
228 `before(async () => {`,
229 [
230 `const Factory = await ethers.getContractFactory('External${libraryName}Coder');`,
231 `${contractName} = await Factory.deploy();`
232 ],
233 '})',
234 '',
235 ...fnTests
236 ],
237 '})'
238 ];
239 return arrJoiner(testFile);
240}

Callers

nothing calls this directly

Calls 3

removeTrailingNewLinesFunction · 0.90
arrJoinerFunction · 0.90

Tested by

no test coverage detected