cashscript icon indicating copy to clipboard operation
cashscript copied to clipboard

Improvements testing-suite

Open mr-zwets opened this issue 1 year ago • 1 comments

We probably want to have a stand-alone repo for the testing suite

There's some issues with the current setup:

  • ~~The initial lockfile is using a currently invalid cashscript version~~
  • ~~Missing url-join dependency~~
  • ~~uses ts-node-esm in some places instead of tsx~~
  • The compilation fails with the latest node versions (needed to add cross-env)
  • The testing-suite is also missing a README.md and a .gitignore
  • Seems to crash on failing tests

mr-zwets avatar May 24 '24 07:05 mr-zwets

the testing suite also uses compileString so it cannot output a contract.artifact.ts file which would be better for type-saftey in development.

instead we could use cashc as a child_process like this:

  // Compile each contract file using the CLI
  contractFiles.forEach((contractFile) => {
    const outputFileName = path.basename(contractFile.pathname).replace('.cash', '.ts');
    const outputPath = path.join(artifactsDir.pathname, outputFileName).slice(1)

    // Build the CLI command
    const command = `cashc "${contractFile.pathname.slice(1)}" -o "${outputPath}" --format ts`;

    try {
      // Execute the CLI command
      execSync(command, { stdio: 'inherit' });
      console.log(`\nCompiled ${path.basename(contractFile.pathname)}`);
    } catch (error) {
      console.error(`Failed to compile ${path.basename(contractFile.pathname)}:`, error);
    }
  });

mr-zwets avatar Feb 28 '25 12:02 mr-zwets