aleph-im/pyaleph

No error is raised when sending a Store message containing an IPFS hash and a storage type non IPFS

Closed this issue · 1 comments

hoh commented

The message stays in the pending queue.

Example:

{
  "status": "pending",
  "item_hash": ...,
  "reception_time": ...,
  "messages": [
    {
      "sender": ...,
      "chain": "ETH",
      "signature": ...,
      "type": "STORE",
      "item_type": "inline",
      "item_hash": ...,
      "time": ...,
      "channel": ...,
      "content": {
        "time": ...,
        "address": ...,
        "item_hash": "QmRTV3h1jLcACW4FRfdisokkQAk4E4qDhUzGpgdrd4JAFy",
        "item_type": "storage"
      },
      "reception_time": ...
    }
  ]
}

Fixed on v0.5.0-rc2:

def send_message():
    message = {
        "item_hash": "QmUfofj46FdTRzEhhjPLCbbshtuvWdxM2TPnvgz4z1AS83",
        "type": "AGGREGATE",
        "chain": "ETH",
        "sender": "0x840F386ACcf7b0283b4c4AE8dDE3750CCc47D2E6",
        "signature": "e9895262580a40d39cd498266ba5b7f7ef00361ada8e094ec9857187ba2f6baa31331b58c78d7798273ca3c963b3a1336cb0f6d5b118af84c8b08e5e3b5622351b",
        "item_type": "storage",
        "time": 1682349167.737107,
    }

    r = requests.post("http://46.255.204.195:4024/api/v0/messages", json={"sync": True, "message": message})
    print(r.status_code)
    print(r.text)


if __name__ == "__main__":
    send_message()

422
[{'loc': ('root',), 'msg': 'Expected ItemType.ipfs based on hash but item type is ItemType.storage.', 'type': 'value_error'}]