Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions archivist/confirmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,32 @@ def __on_giveup_confirmation(details: "Details"):
def _wait_for_confirmation(
self: "_AssetsRestricted",
identity: str,
) -> "Asset": ... # pragma: no cover
) -> "Asset":
... # pragma: no cover


@overload
def _wait_for_confirmation(
self: "_AssetsPublic",
identity: str,
) -> "Asset": ... # pragma: no cover
) -> "Asset":
... # pragma: no cover


@overload
def _wait_for_confirmation(
self: "_EventsRestricted",
identity: str,
) -> "Event": ... # pragma: no cover
) -> "Event":
... # pragma: no cover


@overload
def _wait_for_confirmation(
self: "_EventsPublic",
identity: str,
) -> "Event": ... # pragma: no cover
) -> "Event":
... # pragma: no cover


@backoff.on_predicate(
Expand Down
8 changes: 4 additions & 4 deletions functests/execassets.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ def setUp(self):
self.traffic_light = deepcopy(ATTRS)
self.traffic_light["arc_display_type"] = "Traffic light with violation camera"
self.traffic_light_merkle_log = deepcopy(ATTRS)
self.traffic_light_merkle_log["arc_display_type"] = (
"Traffic light with violation camera (merkle_log)"
)
self.traffic_light_merkle_log[
"arc_display_type"
] = "Traffic light with violation camera (merkle_log)"

def tearDown(self):
self.arch.close()
Expand All @@ -143,10 +143,10 @@ def test_asset_create_simple_hash(self):
"""
Test asset creation uses simple hash proof mechanism
"""
# default is simple hash so it is unspecified
asset = self.arch.assets.create(
attrs=self.traffic_light,
confirm=True,
props={"proof_mechanism": ProofMechanism.SIMPLE_HASH.name},
)
LOGGER.debug("asset %s", json_dumps(asset, sort_keys=True, indent=4))
self.assertEqual(
Expand Down
34 changes: 33 additions & 1 deletion functests/execpublicassets.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ def tearDown(self):

def test_public_asset_create_simple_hash(self):
"""
Test asset creation uses simple hash proof mechanism
Test public asset creation with the simple hash proof mechanism
"""
asset = self.arch.assets.create(
attrs=self.traffic_light,
props={
"public": True,
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
},
confirm=True,
)
Expand All @@ -126,6 +127,37 @@ def test_public_asset_create_simple_hash(self):
events = public.events.list(asset_id=asset_publicurl)
LOGGER.debug("events %s", json_dumps(list(events), sort_keys=True, indent=4))

def test_public_asset_create_merkle_log(self):
"""
Test public asset creation with the merkle log proof mechanism
"""
asset = self.arch.assets.create(
attrs=self.traffic_light,
props={
"public": True,
"proof_mechanism": ProofMechanism.MERKLE_LOG.name,
},
confirm=True,
)
LOGGER.debug("asset %s", json_dumps(asset, sort_keys=True, indent=4))
self.assertEqual(
asset["proof_mechanism"],
ProofMechanism.MERKLE_LOG.name,
msg="Incorrect asset proof mechanism",
)
self.assertEqual(
asset["public"],
True,
msg="Asset is not public",
)
asset_publicurl = self.arch.assets.publicurl(asset["identity"])
LOGGER.debug("asset_publicurl %s", asset_publicurl)
public = self.arch.Public
count = public.events.count(asset_id=asset_publicurl)
LOGGER.debug("count %s", count)
events = public.events.list(asset_id=asset_publicurl)
LOGGER.debug("events %s", json_dumps(list(events), sort_keys=True, indent=4))

def test_public_asset_create_event(self):
"""
Test list
Expand Down