733ecd2681
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.
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
/**
|
|
* Test the AssemblyScript-compiled VM
|
|
*/
|
|
|
|
import { createFullVM } from '../src/randomx/vm-full.js';
|
|
|
|
async function main() {
|
|
console.log('=== Full Mode VM Test ===\n');
|
|
|
|
// Create a small test dataset (just for testing)
|
|
const testDataset = new BigInt64Array(1000 * 8);
|
|
for (let i = 0; i < testDataset.length; i++) {
|
|
testDataset[i] = BigInt(i * 12345);
|
|
}
|
|
|
|
console.log('Creating VM...');
|
|
const vm = await createFullVM(testDataset);
|
|
console.log('VM created\n');
|
|
|
|
// Test hashing
|
|
const testInput = Buffer.from('test input for randomx hashing');
|
|
|
|
console.log('Computing hashes...');
|
|
const start = performance.now();
|
|
const numHashes = 5;
|
|
|
|
for (let i = 0; i < numHashes; i++) {
|
|
const input = Buffer.concat([testInput, Buffer.from([i])]);
|
|
const hash = vm.calculateHash(input);
|
|
console.log(`Hash ${i + 1}: ${Buffer.from(hash).toString('hex').substring(0, 32)}...`);
|
|
}
|
|
|
|
const elapsed = performance.now() - start;
|
|
console.log(`\n${numHashes} hashes in ${elapsed.toFixed(2)}ms`);
|
|
console.log(`Per hash: ${(elapsed / numHashes).toFixed(2)}ms`);
|
|
console.log(`Hashrate: ${(numHashes / (elapsed / 1000)).toFixed(2)} H/s`);
|
|
}
|
|
|
|
main().catch(console.error);
|