OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-wallet / tests / test-multi-device.sh

78 lines · bash ref:
#!/bin/bash
set -e

echo "🧪 Multi-Device Testing Script"
echo "================================"
echo ""

# 1. Create invite on tabertron
echo "Step 1: Creating invite on tabertron..."
cd /home/fleeky/projects/code/hypercore-kb/hyper-fleeky/hyper-wallet

# Run device add but extract invite immediately
bare ./hyper-wallet-autobase.cjs device add 2>&1 | tee /tmp/device-add.log &
ADD_PID=$!

# Wait for invite to be generated (appears in first few lines)
sleep 4

# Extract invite code
INVITE=$(grep -A 2 "━━━" /tmp/device-add.log | grep -v "━━━" | grep -v "Share this" | head -1 | xargs)

if [ -z "$INVITE" ]; then
  echo "❌ Failed to extract invite code"
  cat /tmp/device-add.log
  kill $ADD_PID 2>/dev/null || true
  exit 1
fi

echo "✅ Invite extracted:"
echo "$INVITE"
echo ""

# 2. Join from ashatron
echo "Step 2: Joining from ashatron..."
ssh fleeky@ashatron.local "cd ~/projects/code/hypercore-kb/hyper-fleeky/hyper-wallet && bare ./hyper-wallet-autobase.cjs device join '$INVITE' 'Ashatron'" 2>&1 | tee /tmp/device-join.log

echo ""
echo "Step 3: Waiting for device add to detect connection..."
sleep 10

# Check device add output
echo ""
echo "=== Device Add Output ==="
cat /tmp/device-add.log | tail -30
echo ""

# Kill device add if still running
kill $ADD_PID 2>/dev/null || true

# 3. Approve on tabertron
echo ""
echo "Step 4: Listing pending writers..."
bare ./hyper-wallet-autobase.cjs device approve | tee /tmp/device-approve-list.log

# Extract writer key
WRITER_KEY=$(grep "📝" /tmp/device-approve-list.log | head -1 | awk '{print $2}' | cut -d'.' -f1)

if [ -n "$WRITER_KEY" ]; then
  echo ""
  echo "Step 5: Approving writer: $WRITER_KEY"
  bare ./hyper-wallet-autobase.cjs device approve "$WRITER_KEY" "Ashatron"

  echo ""
  echo "Step 6: Verifying device list..."
  bare ./hyper-wallet-autobase.cjs device list

  echo ""
  echo "Step 7: Checking connection status..."
  bare ./hyper-wallet-autobase.cjs device status

  echo ""
  echo "✅ Multi-device test complete!"
else
  echo "⚠️  No pending writers found"
  echo "Device add output:"
  cat /tmp/device-add.log
fi