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

Function generateHardhatTest

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

Source from the content-addressed store, hash-verified

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

Callers 1

createLibraryMethod · 0.90

Calls 3

removeTrailingNewLinesFunction · 0.90
arrJoinerFunction · 0.90

Tested by

no test coverage detected