make_post_sell/test_monero_client.py
Russell Ballestrini 800b7965b5 Fix crypto watcher stuck payments and improve cart deactivation
- Exclude already-swept payments from watcher queue to prevent endless processing
- Mark swept payments as "swept" status to remove from future cycles
- Fix cart deactivation by ensuring shop/user objects are attached to session
- Add debug logging for cart deactivation to track behavior
- Resolves issue where confirmed payments were processed every 20 seconds indefinitely

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-23 12:35:56 -04:00

78 lines
2.3 KiB
Python

#!/usr/bin/env python3
"""
Test the actual MoneroClient class to identify the authentication issue.
"""
import sys
import os
# Add the current directory to path so we can import the module
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from make_post_sell.lib.crypto_clients import MoneroClient
def test_monero_client():
"""Test the MoneroClient with the production credentials"""
print("=== Testing MoneroClient ===")
# Production credentials from the remote server
rpc_url = "http://127.0.0.1:18083/json_rpc"
rpc_user = "mps_xmr_user_5a4c3592d2b4b52d"
rpc_pass = "jLOnImOKWT1Vomeje3HvKBzsDjT6VPcxvf7FMtEpjvY4"
print(f"URL: {rpc_url}")
print(f"User: {rpc_user}")
print(f"Pass: {'*' * len(rpc_pass)}")
print()
client = MoneroClient(rpc_url, rpc_user, rpc_pass)
# Test basic connection
try:
print("Testing get_height()...")
height = client.get_height()
print(f"✓ SUCCESS: Current height = {height}")
return True
except Exception as e:
print(f"✗ FAILED: {e}")
print(f"Error type: {type(e).__name__}")
# Try to get more detailed error info
if hasattr(e, "__cause__") and e.__cause__:
print(f"Caused by: {e.__cause__}")
return False
def test_monero_client_localhost():
"""Test with localhost connection - might not work but useful for debugging"""
print("=== Testing MoneroClient with localhost (fallback) ===")
# This won't work since we're not running the RPC locally, but good for testing
rpc_url = "http://127.0.0.1:18083/json_rpc"
rpc_user = "test_user"
rpc_pass = "test_pass"
client = MoneroClient(rpc_url, rpc_user, rpc_pass)
try:
print("Testing get_height() on localhost...")
height = client.get_height()
print(f"✓ SUCCESS: Current height = {height}")
return True
except Exception as e:
print(f"✗ EXPECTED FAILURE (no local RPC): {e}")
return False
if __name__ == "__main__":
print("Monero Client Test")
print("=" * 40)
print()
# Test with production creds (won't work locally but shows the code path)
test_monero_client()
print()
# Test with localhost (also won't work but different error pattern)
test_monero_client_localhost()