Skip to content

Latest commit

Β 

History

History
430 lines (321 loc) Β· 10.3 KB

File metadata and controls

430 lines (321 loc) Β· 10.3 KB

Testing Guide - MiTeddy Snipe Bot

⚠️ IMPORTANT: The RBF Bot (src/main-rbf.ts) is now the PRIMARY/PRODUCTION bot. The Original Bot (src/index.ts) is LEGACY/DEPRECATED.

πŸ§ͺ Quick Test Checklist (RBF Bot)

Step 1: Configuration Verification (2 minutes)

# 1. Check .env file exists and has required values
# 2. Verify all required variables are set
# 3. Check contract address format
# 4. Verify RBF bot configuration (BASE_MULTIPLIER=200.0, RBF_* variables)

Step 2: Dry-Run Test (5 minutes)

npm run start:rbf:dry  # RBF bot (PRODUCTION)

Step 3: Ownership & Approval Test (10 minutes)

# Run without dry-run to test actual blockchain calls
npm run start:rbf  # RBF bot (PRODUCTION)
# (Stop with Ctrl+C after approvals are set)

Step 4: Full Integration Test (Wait for window)

# Run and wait for actual window to open
npm run start:rbf  # RBF bot (PRODUCTION)

Legacy Original Bot Testing [DEPRECATED]

npm run start:rbf:dry  # RBF bot (PRODUCTION)  # LEGACY - Original bot (not recommended)
npm start               # LEGACY - Original bot (not recommended)

πŸ“‹ Detailed Testing Steps

Test 1: Configuration Validation

Purpose: Verify all config is correct before running

Steps:

  1. Copy .env.example to .env
  2. Fill in required values:
    • PRIVATE_KEY - Your hot wallet private key
    • SACRIFICE_ADDR - Contract address (validated automatically)
    • TEDDY_ID - Your Steady Teddy token ID
    • MIBERA_ID - Your Mibera token ID
  3. Set optional values:
    • UNLOCK_TIME_UNIT - seconds (default) or milliseconds

Expected Result:

  • βœ… Bot starts without errors
  • βœ… Shows wallet address
  • βœ… Shows RPC count
  • βœ… Shows token IDs
  • βœ… Network verified (Chain ID 80094)

If Errors:

  • ❌ "Missing required environment variable" β†’ Check .env file
  • ❌ "SACRIFICE_ADDR must be a valid Ethereum address" β†’ Fix address format
  • ❌ "Chain ID mismatch" β†’ Check RPC endpoints

Test 2: Dry-Run Mode (RBF Bot)

Purpose: Test bot logic without sending transactions

Command:

npm run start:rbf:dry  # RBF bot (PRODUCTION)

What to Verify:

  1. βœ… Bot initializes successfully
  2. βœ… Network verification passes
  3. βœ… Ownership check runs (should pass if you own NFTs)
  4. βœ… Approval check runs (may set approval if needed)
  5. βœ… Bot enters polling loop
  6. βœ… View function checks work
  7. βœ… Logs show unlock time (if available)
  8. βœ… Dynamic polling activates when close to unlock
  9. βœ… NO transactions sent (dry-run mode)

Expected Output:

β„Ή Initializing MiTeddy snipe bot...
β„Ή Chain: Berachain (ID: 80094)
β„Ή Wallet: 0x...
β„Ή RPCs: 3 configured
βœ“ Network verified: Chain ID 80094
β„Ή Verifying NFT ownership...
βœ“ Ownership verified - Steady Teddy #1234
βœ“ Ownership verified - Mibera #5678
β„Ή Waiting for sacrifice window to open...
β„Ή Polling every 250ms
β„Ή Still waiting... (20 checks, unlock in ~45.2s)

Stop Test: Press Ctrl+C when satisfied


Test 3: Ownership Verification

Purpose: Verify bot correctly checks NFT ownership

Setup:

  • Use a wallet that owns both NFTs
  • Or use a wallet that doesn't own one (to test error handling)

Expected Behavior:

  • βœ… If owns both: Continues to approval check
  • ❌ If missing one: Shows clear error and exits

Error Example:

βœ— You do not own Steady Teddy #1234. Owner: 0x...

Test 4: Approval Setting

Purpose: Verify bot sets approvals correctly

Setup:

  • Use wallet with NFTs but no approvals set

Expected Behavior:

  1. βœ… Checks if approval needed
  2. βœ… Sends setApprovalForAll transaction
  3. βœ… Waits for confirmation
  4. βœ… Continues to polling

In Dry-Run:

  • ⚠️ Shows "DRY RUN: Would set approval"
  • βœ… Doesn't actually send transaction

Test 5: View Function Caching

Purpose: Verify caching works correctly

What to Look For:

  1. First call: Makes RPC call (slower)
  2. Subsequent calls in same block: Uses cache (faster, no RPC call)
  3. New block: Cache invalidates, fresh call

How to Verify:

  • Watch logs for RPC activity
  • Same block = no new RPC calls
  • New block = new RPC call

Test 6: Parallel Broadcasting

Purpose: Verify all RPCs receive transaction simultaneously

Setup:

  • Configure multiple RPCs in .env
  • Run in dry-run mode first

Expected Behavior:

  • βœ… All RPCs receive transaction in parallel
  • βœ… Logs show "Broadcast successful to RPC 1 (primary)", "RPC 2", etc.
  • βœ… Faster than sequential broadcasting

In Dry-Run:

  • ⚠️ Shows "DRY RUN: Would send transaction"
  • βœ… Doesn't actually broadcast

Test 7: UnlockTime Unit Handling

Purpose: Verify unlockTime unit conversion works

Test Cases:

Case A: Contract Returns Seconds (Default)

# .env
UNLOCK_TIME_UNIT=seconds  # or omit (default)

Expected:

  • βœ… Pre-warming triggers at 2 seconds (not 2000 seconds)
  • βœ… Fast polling at < 1 second
  • βœ… Logs show "Window opening in 2s" (not "2000ms")

Case B: Contract Returns Milliseconds

# .env
UNLOCK_TIME_UNIT=milliseconds

Expected:

  • βœ… Pre-warming triggers at 2000ms (2 seconds)
  • βœ… Fast polling at < 1000ms
  • βœ… Logs show "Window opening in 2000ms"

How to Verify:

  1. Check contract ABI/docs for remainingUnlockTime() return type
  2. Set UNLOCK_TIME_UNIT accordingly
  3. Watch logs when close to unlock
  4. Verify timing matches expected behavior

Test 8: Dynamic Polling

Purpose: Verify polling speed adjusts based on unlock time

Expected Behavior:

  • Normal (> 5 seconds): Polls every SIMULATE_MS (default 250ms)
  • Close (< 5 seconds): Polls every 50ms
  • Very Close (< 1 second): Polls every 10ms

How to Verify:

  • Watch log timestamps
  • Should see faster polling as unlock time approaches
  • Logs should show "fast polling" or "increased polling"

Test 9: Pre-Warming

Purpose: Verify transaction pre-warming works

Setup:

  • Set PRE_WARM_TX=true in .env
  • Wait for unlock time < 2 seconds

Expected Behavior:

  1. βœ… Pre-warming triggers when < 2 seconds to unlock
  2. βœ… Only happens once (not repeatedly)
  3. βœ… Uses fresh nonce
  4. βœ… Pre-broadcasts to mempool
  5. βœ… Logs "Transaction pre-warmed to [private/public] mempool"

In Dry-Run:

  • ⚠️ Pre-warming skipped (dry-run mode)

Test 10: RPC Health Check

Purpose: Verify RPC health monitoring works

Setup:

  • Set RPC_HEALTH_CHECK=true in .env
  • Configure multiple RPCs

Expected Behavior:

  1. βœ… Health check runs on startup
  2. βœ… RPCs sorted by latency
  3. βœ… Periodic health checks (every 100 attempts)
  4. βœ… Health checks skipped when < 10 seconds to unlock
  5. βœ… Logs show "RPCs sorted by latency: ..."

Test 11: Gas Bumping

Purpose: Verify gas bumping works (requires actual transaction)

Setup:

  • Run without dry-run
  • Use low gas price to force bumping

Expected Behavior:

  1. βœ… Sends transaction with initial gas
  2. βœ… If not included, bumps gas after BUMP_INTERVAL_MS
  3. βœ… Re-broadcasts with higher gas
  4. βœ… Continues up to MAX_BUMPS
  5. βœ… Logs show gas increases

Note: This test requires actual BERA for gas fees


Test 12: Error Handling

Purpose: Verify bot handles errors gracefully

Test Cases:

Case A: RPC Failure

  • Temporarily break one RPC URL
  • βœ… Bot should continue with other RPCs
  • βœ… Logs should show warnings

Case B: Network Issues

  • Disconnect internet briefly
  • βœ… Bot should retry
  • βœ… Logs should show errors

Case C: Invalid Configuration

  • Set invalid SACRIFICE_ADDR
  • βœ… Should error clearly on startup
  • βœ… Should not crash silently

πŸš€ Quick Start Testing

Minimal Test (2 minutes)

# 1. Set up .env with your values
# 2. Run dry-run
npm run start:rbf:dry  # RBF bot (PRODUCTION)

# 3. Verify:
# - Bot starts
# - Shows wallet
# - Enters polling loop
# - No errors

Full Test (10 minutes)

# 1. Set up .env
# 2. Run without dry-run
npm start

# 3. Verify:
# - Ownership check passes
# - Approvals set (if needed)
# - Polling works
# - View functions work
# - No crashes

# 4. Stop with Ctrl+C

πŸ” What to Watch For

βœ… Good Signs

  • Bot starts without errors
  • Network verification passes
  • Ownership verified
  • Polling loop runs smoothly
  • View function checks work
  • Logs show unlock time
  • Dynamic polling activates
  • No crashes or hangs

⚠️ Warning Signs

  • Errors in logs (check messages)
  • Bot hangs (check RPC connectivity)
  • Wrong unlock time (check UNLOCK_TIME_UNIT)
  • Memory usage growing (check cache limits)
  • Transactions not sending (check dry-run mode)

❌ Critical Issues

  • Bot crashes on startup β†’ Check config
  • "Chain ID mismatch" β†’ Check RPC endpoints
  • "You do not own..." β†’ Check token IDs
  • "Invalid address" β†’ Check SACRIFICE_ADDR format

πŸ“Š Testing Checklist

Pre-Production Checklist

  • Configuration validated
  • Dry-run test passed
  • Ownership verified
  • Approvals set (if needed)
  • UnlockTime unit verified (seconds vs milliseconds)
  • View function caching works
  • Parallel broadcasting works
  • Dynamic polling activates
  • Pre-warming works (if enabled)
  • RPC health check works
  • Error handling verified
  • Memory usage stable
  • No crashes in extended run

πŸ› Troubleshooting

Bot Won't Start

  1. Check .env file exists and has all required variables
  2. Check PRIVATE_KEY format (0x + 64 hex chars)
  3. Check SACRIFICE_ADDR format (valid Ethereum address)
  4. Check RPC URLs are accessible

Wrong Unlock Time

  1. Verify contract's remainingUnlockTime() return type
  2. Set UNLOCK_TIME_UNIT accordingly
  3. Check logs for unlock time display

RPC Errors

  1. Check RPC URLs are correct
  2. Check network connectivity
  3. Try different RPC providers
  4. Check rate limits

Memory Issues

  1. Check cache size limits (should be 1000 max)
  2. Monitor memory usage over time
  3. Restart bot periodically if needed

🎯 Recommended Test Sequence

  1. Dry-Run (5 min) - Verify basic functionality
  2. Ownership Test (2 min) - Verify NFT ownership check
  3. Approval Test (5 min) - Verify approval setting
  4. Extended Dry-Run (30 min) - Verify polling and caching
  5. Full Test (Wait for window) - Verify complete flow

Ready to test! Start with dry-run mode for safest testing. πŸš€