substra-tests
substra-tests copied to clipboard
cp.list_traintuple doesn't return tuple in their creation order
In test_execution_compute_plan.py
, multiple tuples specs are generated (e.g. tuple_spec_1 and tuple_spec_2) and once created, the matching tuples are retrieved using:
tuple_1, tuple_2 = cp.list_tuple()
However there is no guarantee that tuple_1 matches tuple_spec_1 here. Our tests work because the tuple are chained and therefore have ever-increasing ranks and because the list_tuple methods all sort the tuple by rank. Without that, our checks would fail.
This issue cannot be solved in tests because the solution would rely on the ID to KEY mapping, which is our only way of linking a spec with an asset.
Unfortunately the mapping is only returned after create or update calls, not for get and list calls. And the SDK always does a get right after a create or update to avoid having to deal with multiple return formats. Which means the mapping is lost forever.
At this point it would be a good think to know how we want to interact with the ID to Key mapping and open a companion issue the chaincode to implement it. Of course it can include a much larger discussion about using user generated ID to retrieve all kind of asset.