|
1 | 1 | from pathlib import Path |
2 | 2 | from tempfile import NamedTemporaryFile |
| 3 | +from typing import List |
3 | 4 |
|
4 | 5 | import pytest as pytest |
| 6 | +from aleph_message.models import AggregateMessage, AlephMessage, PostMessage |
5 | 7 |
|
6 | 8 | import aleph.sdk.chains.ethereum as ethereum |
7 | 9 | import aleph.sdk.chains.sol as solana |
@@ -34,3 +36,71 @@ def tezos_account() -> tezos.TezosAccount: |
34 | 36 | with NamedTemporaryFile(delete=False) as private_key_file: |
35 | 37 | private_key_file.close() |
36 | 38 | yield tezos.get_fallback_account(path=Path(private_key_file.name)) |
| 39 | + |
| 40 | + |
| 41 | +@pytest.fixture |
| 42 | +def messages() -> List[AlephMessage]: |
| 43 | + return [ |
| 44 | + AggregateMessage.parse_obj( |
| 45 | + { |
| 46 | + "item_hash": "5b26d949fe05e38f535ef990a89da0473f9d700077cced228f2d36e73fca1fd6", |
| 47 | + "type": "AGGREGATE", |
| 48 | + "chain": "ETH", |
| 49 | + "sender": "0x51A58800b26AA1451aaA803d1746687cB88E0501", |
| 50 | + "signature": "0xca5825b6b93390482b436cb7f28b4628f8c9f56dc6af08260c869b79dd6017c94248839bd9fd0ffa1230dc3b1f4f7572a8d1f6fed6c6e1fb4d70ccda0ab5d4f21b", |
| 51 | + "item_type": "inline", |
| 52 | + "item_content": '{"address":"0x51A58800b26AA1451aaA803d1746687cB88E0501","key":"0xce844d79e5c0c325490c530aa41e8f602f0b5999binance","content":{"1692026263168":{"version":"x25519-xsalsa20-poly1305","nonce":"RT4Lbqs7Xzk+op2XC+VpXgwOgg21BotN","ephemPublicKey":"CVW8ECE3m8BepytHMTLan6/jgIfCxGdnKmX47YirF08=","ciphertext":"VuGJ9vMkJSbaYZCCv6Zemx4ixeb+9IW8H1vFB9vLtz1a8d87R4BfYUisLoCQxRkeUXqfW0/KIGQ5idVjr8Yj7QnKglW5AJ8UX7wEWMhiRFLatpWP8P9FI2n8Z7Rblu7Oz/OeKnuljKL3KsalcUQSsFa/1qACsIoycPZ6Wq6t1mXxVxxJWzClLyKRihv1pokZGT9UWxh7+tpoMGlRdYainyAt0/RygFw+r8iCMOilHnyv4ndLkKQJXyttb0tdNr/gr57+9761+trioGSysLQKZQWW6Ih6aE8V9t3BenfzYwiCnfFw3YAAKBPMdm9QdIETyrOi7YhD/w==","sha256":"bbeb499f681aed2bc18b6f3b6a30d25254bd30fbfde43444e9085f3bcd075c3c"}},"time":1692026263.662}', |
| 53 | + "content": { |
| 54 | + "key": "0xce844d79e5c0c325490c530aa41e8f602f0b5999binance", |
| 55 | + "time": 1692026263.662, |
| 56 | + "address": "0x51A58800b26AA1451aaA803d1746687cB88E0501", |
| 57 | + "content": { |
| 58 | + "hello": "world", |
| 59 | + }, |
| 60 | + }, |
| 61 | + "time": 1692026263.662, |
| 62 | + "channel": "UNSLASHED", |
| 63 | + "size": 734, |
| 64 | + "confirmations": [], |
| 65 | + "confirmed": False, |
| 66 | + } |
| 67 | + ), |
| 68 | + PostMessage.parse_obj( |
| 69 | + { |
| 70 | + "item_hash": "70f3798fdc68ce0ee03715a5547ee24e2c3e259bf02e3f5d1e4bf5a6f6a5e99f", |
| 71 | + "type": "POST", |
| 72 | + "chain": "SOL", |
| 73 | + "sender": "0x4D52380D3191274a04846c89c069E6C3F2Ed94e4", |
| 74 | + "signature": "0x91616ee45cfba55742954ff87ebf86db4988bcc5e3334b49a4caa6436e28e28d4ab38667cbd4bfb8903abf8d71f70d9ceb2c0a8d0a15c04fc1af5657f0050c101b", |
| 75 | + "item_type": "storage", |
| 76 | + "item_content": None, |
| 77 | + "content": { |
| 78 | + "time": 1692026021.1257718, |
| 79 | + "type": "aleph-network-metrics", |
| 80 | + "address": "0x4D52380D3191274a04846c89c069E6C3F2Ed94e4", |
| 81 | + "ref": "0123456789abcdef", |
| 82 | + "content": { |
| 83 | + "tags": ["mainnet"], |
| 84 | + "hello": "world", |
| 85 | + "version": "1.0", |
| 86 | + }, |
| 87 | + }, |
| 88 | + "time": 1692026021.132849, |
| 89 | + "channel": "aleph-scoring", |
| 90 | + "size": 122537, |
| 91 | + "confirmations": [], |
| 92 | + "confirmed": False, |
| 93 | + } |
| 94 | + ), |
| 95 | + ] |
| 96 | + |
| 97 | + |
| 98 | +@pytest.fixture |
| 99 | +def raw_messages_response(messages): |
| 100 | + return { |
| 101 | + "messages": [message.dict() for message in messages], |
| 102 | + "pagination_item": "messages", |
| 103 | + "pagination_page": 1, |
| 104 | + "pagination_per_page": 20, |
| 105 | + "pagination_total": 2, |
| 106 | + } |
0 commit comments