Files
Matt Hess 733ecd2681 Migrate all JS tests to Rust: 9-crate workspace, 703 tests, 0 JS remaining
Add root Cargo workspace with 9 crates: salvium-crypto (extended),
  salvium-types, salvium-consensus, salvium-wallet, salvium-tx,
  salvium-rpc, salvium-miner (extended), salvium-cli, salvium-multisig.

  New modules: chain_state, block_weight, alt_chain, validation,
  offline signing, stake lifecycle, wallet sync/query/encryption/utxo,
  randomx utilities, and full multisig crate with CARROT support.

  Delete 188 JS test/helper/debug files; archive integration test
  scripts to test/legacy-js/ for live testnet use. Testnet integration
  tests (transfer, stake, burn, convert, sweep) remain as #[ignore]-
  gated Rust tests runnable with --ignored against a live daemon.
2026-02-17 23:09:35 +00:00

29 lines
943 B
JavaScript

import { randomx_init_cache, randomx_superscalarhash } from '../src/randomx/vendor/index.js';
const cache = randomx_init_cache('test');
// Try to find the correct VM memory size by trial and error
// Start with a reasonable minimum and increase until it works
const testPages = [33, 34, 35, 36, 50, 64, 100, 128];
for (const pages of testPages) {
try {
const memory = new WebAssembly.Memory({ initial: pages, maximum: pages });
const vmImports = { env: { memory } };
const vmInstance = new WebAssembly.Instance(cache.vm, vmImports);
console.log('SUCCESS: VM instantiated with', pages, 'pages');
// Check exports
const exports = vmInstance.exports;
console.log(' Exports:', Object.keys(exports));
// Try to initialize
const scratchPtr = exports.i(3);
console.log(' Scratch ptr:', scratchPtr);
break;
} catch (e) {
console.log('FAILED with', pages, 'pages:', e.message);
}
}