"""Offline educational example; no wallet calls.""" def can_dispatch(policy, approval, intent_digest): return (policy["enabled"] is True and type(policy["epoch"]) is int and type(approval["epoch"]) is int and policy["epoch"] == approval["epoch"] and policy["wallet"] == approval["wallet"] and type(intent_digest) is str and bool(intent_digest) and approval["digest"] == intent_digest) p = dict(enabled=True,epoch=3,wallet="w") a = dict(epoch=3,wallet="w",digest="fixture") assert can_dispatch(p,a,"fixture") assert not can_dispatch(dict(p,epoch=4),a,"fixture") assert not can_dispatch(dict(p,enabled=False),a,"fixture") assert not can_dispatch(p,a,"other")