const assert = require('assert');
const path = require('path');
const fs = require('fs');
function main() {
const wasmModulePath = path.resolve(__dirname, '../target/wasm-bindgen-nodejs/charms_lib.js');
assert.ok(fs.existsSync(wasmModulePath), `Wasm JS glue not found at ${wasmModulePath}`);
const wasm = require(wasmModulePath);
assert.ok(typeof wasm.extractAndVerifySpell === 'function', 'extractAndVerifySpell export not found');
const txJsonPath = path.resolve(__dirname, './bitcoin-tx.json');
assert.ok(fs.existsSync(txJsonPath), `Sample tx JSON not found at ${txJsonPath}`);
const tx = JSON.parse(fs.readFileSync(txJsonPath, 'utf8'));
const res = wasm.extractAndVerifySpell(tx, true);
console.log('[extractAndVerifySpell.test] OK');
console.log('%o', res);
}
if (require.main === module) {
try {
main();
} catch (err) {
console.error('[extractAndVerifySpell.test] FAILED');
console.error(err);
process.exit(1);
}
}