#!/usr/bin/env bare
// test-storage.cjs - Test Hyperbee transaction storage
require('bare-node-runtime/global')
const { storeTx, getTxHistory } = require('./lib/wallet-context.cjs')
async function test() {
console.log('🧪 Testing Hyperbee Transaction Storage')
console.log('')
// Store a test Bitcoin transaction
console.log('1. Storing Bitcoin transaction...')
await storeTx({
hash: 'test-btc-hash-123',
chain: 'bitcoin',
to: 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx',
amount: '100000',
fee: '226',
timestamp: Date.now() - 3600000, // 1 hour ago
status: 'confirmed'
})
console.log(' ✅ Stored')
console.log('')
// Store a test Ethereum transaction
console.log('2. Storing Ethereum transaction...')
await storeTx({
hash: '0xtest-eth-hash-456',
chain: 'ethereum',
to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
amount: '10000000000000000',
fee: '20000000000000',
timestamp: Date.now(), // now
status: 'pending'
})
console.log(' ✅ Stored')
console.log('')
// Retrieve all transactions
console.log('3. Retrieving all transactions...')
const allTx = await getTxHistory()
console.log(` ✅ Found ${allTx.length} transactions`)
for (const tx of allTx) {
console.log(` - ${tx.chain}: ${tx.hash}`)
}
console.log('')
// Retrieve Bitcoin only
console.log('4. Retrieving Bitcoin transactions...')
const btcTx = await getTxHistory('bitcoin')
console.log(` ✅ Found ${btcTx.length} Bitcoin transactions`)
console.log('')
// Retrieve Ethereum only
console.log('5. Retrieving Ethereum transactions...')
const ethTx = await getTxHistory('ethereum')
console.log(` ✅ Found ${ethTx.length} Ethereum transactions`)
console.log('')
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
console.log('✅ All tests passed!')
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
console.log('')
console.log('Now run: bare hyper-wallet-bare.cjs history')
console.log('')
}
test().catch(err => {
console.error('❌ Test failed:', err.message)
if (process.env.DEBUG) console.error(err.stack)
process.exit(1)
})