()
| 16 | |
| 17 | |
| 18 | async def main(): # noqa: D103 |
| 19 | print("=== Python SDK Output Test ===") |
| 20 | |
| 21 | try: |
| 22 | # Test client get_key |
| 23 | client = DstackClient() |
| 24 | print("\n1. Testing DstackClient.get_key()") |
| 25 | |
| 26 | test_paths = [ |
| 27 | {"path": "test/wallet", "purpose": "ethereum"}, |
| 28 | {"path": "test/signing", "purpose": "solana"}, |
| 29 | {"path": "user/alice", "purpose": "mainnet"}, |
| 30 | ] |
| 31 | |
| 32 | for test_case in test_paths: |
| 33 | path, purpose = test_case["path"], test_case["purpose"] |
| 34 | key_result = client.get_key(path, purpose) |
| 35 | print(f"get_key('{path}', '{purpose}'):") |
| 36 | print(f" key: {key_result.decode_key().hex()}") |
| 37 | print(f" signature_chain length: {len(key_result.signature_chain)}") |
| 38 | print( |
| 39 | f" signature_chain[0]: {key_result.decode_signature_chain()[0].hex()}" |
| 40 | ) |
| 41 | |
| 42 | # Test viem integration (if available) |
| 43 | print("\n2. Testing Viem Integration") |
| 44 | eth_key = client.get_key("eth/test", "wallet") |
| 45 | |
| 46 | print("\n2.1 to_account (legacy):") |
| 47 | try: |
| 48 | from dstack_sdk.ethereum import to_account |
| 49 | |
| 50 | account = to_account(eth_key) |
| 51 | print(f" address: {account.address}") |
| 52 | print(" type: ethereum account") |
| 53 | except ImportError: |
| 54 | print( |
| 55 | " error: Ethereum integration not available (install with pip install 'dstack-sdk[eth]')" |
| 56 | ) |
| 57 | except Exception as error: |
| 58 | print(f" error: {error}") |
| 59 | |
| 60 | print("\n2.2 to_account_secure:") |
| 61 | try: |
| 62 | from dstack_sdk.ethereum import to_account_secure |
| 63 | |
| 64 | account_secure = to_account_secure(eth_key) |
| 65 | print(f" address: {account_secure.address}") |
| 66 | print(" type: ethereum account") |
| 67 | except ImportError: |
| 68 | print( |
| 69 | " error: Ethereum integration not available (install with pip install 'dstack-sdk[eth]')" |
| 70 | ) |
| 71 | except Exception as error: |
| 72 | print(f" error: {error}") |
| 73 | |
| 74 | # Test solana integration (if available) |
| 75 | print("\n3. Testing Solana Integration") |
no test coverage detected