cashscript
cashscript copied to clipboard
Improvements testing-suite
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-joindependency~~ - ~~uses
ts-node-esmin some places instead oftsx~~ - The compilation fails with the latest
nodeversions (needed to addcross-env) - The
testing-suiteis also missing aREADME.mdand a.gitignore - Seems to crash on failing tests
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);
}
});