Skip to content

Commit

Permalink
fix compute_digest test
Browse files Browse the repository at this point in the history
  • Loading branch information
zmezei committed Jul 6, 2023
1 parent 9bf84ac commit 069d70c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/uagents/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import hashlib
from typing import Type, Union, Dict
from typing import Type, Union, Dict, Any
import json
from pydantic import BaseModel

Expand All @@ -22,10 +22,14 @@ def remove_descriptions(schema: Dict[str, Dict[str, str]]):
Model.remove_descriptions(definition)

@classmethod
def schema_json_no_descr(cls) -> str:
def schema_no_descr(cls) -> Dict[str, Any]:
orig_schema = json.loads(cls.schema_json(indent=None, sort_keys=True))
Model.remove_descriptions(orig_schema)
return json.dumps(orig_schema)
return orig_schema

@classmethod
def schema_json_no_descr(cls) -> str:
return json.dumps(cls.schema_no_descr())

@staticmethod
def build_schema_digest(model: Union["Model", Type["Model"]]) -> str:
Expand Down
2 changes: 1 addition & 1 deletion src/uagents/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def manifest(self) -> Dict[str, Any]:

for schema_digest, model in all_models.items():
manifest["models"].append(
{"digest": schema_digest, "schema": model.schema_json_no_descr()}
{"digest": schema_digest, "schema": model.schema_no_descr()}
)

for request, responses in self._replies.items():
Expand Down
4 changes: 2 additions & 2 deletions tests/test_field_descr.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def test_compute_digest(self):
def _(_ctx, _sender, _msg):
pass

# computed_digest = Protocol.compute_digest(protocol.manifest())
# self.assertEqual(protocol.digest, computed_digest)
computed_digest = Protocol.compute_digest(protocol.manifest())
self.assertEqual(protocol.digest, computed_digest)


if __name__ == "__main__":
Expand Down

0 comments on commit 069d70c

Please sign in to comment.