()
| 67 | } |
| 68 | |
| 69 | async def test_nonce_generation(): |
| 70 | async with OTTSProvider(config) as provider: |
| 71 | # Mock time sync to avoid actual API calls |
| 72 | provider.time_offset = 0 |
| 73 | provider.last_sync_time = 9999999999 |
| 74 | |
| 75 | # Generate multiple signatures and extract nonces |
| 76 | signatures = [] |
| 77 | for _ in range(10): |
| 78 | sig = await provider._generate_signature() |
| 79 | signatures.append(sig) |
| 80 | |
| 81 | # Extract nonces (second field in signature format: timestamp-nonce-0-hash) |
| 82 | nonces = [sig.split("-")[1] for sig in signatures] |
| 83 | |
| 84 | # All nonces should be 10 characters long |
| 85 | assert all(len(n) == 10 for n in nonces) |
| 86 | |
| 87 | # All nonces should be alphanumeric (lowercase letters and digits) |
| 88 | for n in nonces: |
| 89 | assert all(c in "abcdefghijklmnopqrstuvwxyz0123456789" for c in n) |
| 90 | |
| 91 | # All nonces should be different (cryptographic random ensures uniqueness) |
| 92 | assert len(set(nonces)) == 10 |
| 93 | |
| 94 | asyncio.run(test_nonce_generation()) |
| 95 |
no test coverage detected