verify-fixtures.py 932 B

1234567891011121314151617
  1. #!/usr/bin/env python3
  2. """Verify that TypeScript, Swift and Kotlin exercise the same v2 wire contract."""
  3. import hashlib
  4. import json
  5. from pathlib import Path
  6. import re
  7. root = Path(__file__).resolve().parents[3]
  8. source = json.loads((root / 'tests/fixtures/ordinary-chat-v2/protocol.json').read_text())
  9. android = json.loads((root.parent / 'yaoyao-android/core/network/src/test/resources/ordinary-chat-v2/protocol.json').read_text())
  10. ios_test = (root.parent / 'yaoyao-mobile/YaoYaoAITests/HermesHTTPRealtimeTests.swift').read_text()
  11. match = re.search(r'fixtureJSON = #"""\s*(.*?)\s*"""#', ios_test, re.S)
  12. assert match, 'iOS wire fixture is missing'
  13. ios = json.loads(match.group(1))
  14. assert source == android == ios, 'The three client fixtures have diverged'
  15. canonical = json.dumps(source, sort_keys=True, ensure_ascii=False, separators=(',', ':')).encode()
  16. print('Three-client fixture SHA-256:', hashlib.sha256(canonical).hexdigest())