Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

algod: State delta endpoints #483

Merged
merged 8 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
37 changes: 37 additions & 0 deletions algosdk/v2client/algod.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,43 @@ def set_timestamp_offset(
req = f"/devmode/blocks/offset/{offset}"
return self.algod_request("POST", req, **kwargs)

def get_ledger_state_delta(
self, round: int, **kwargs: Any
) -> AlgodResponseType:
"""
Get the ledger state delta for a round.

Returns:
Dict[str, Any]: Response from algod
"""
req = f"/deltas/{round}"
return self.algod_request("GET", req, **kwargs)

def get_transaction_group_ledger_state_deltas_for_round(
self, round: int, **kwargs: Any
) -> AlgodResponseType:
"""
Get the ledger state deltas for a transaction group in a given round.

Returns:
Dict[str, Any]: Response from algod
"""
req = f"/deltas/{round}/txn/group"
return self.algod_request("GET", req, **kwargs)

def get_ledger_state_delta_for_transaction_group(
self, id: str, **kwargs: Any
) -> AlgodResponseType:
"""
Get the ledger state delta for a transaction group given the
transaction or group ID.

Returns:
Dict[str, Any]: Response from algod
"""
req = f"/deltas/txn/group/{id}"
return self.algod_request("GET", req, **kwargs)


def _specify_round_string(
block: Union[int, None], round_num: Union[int, None]
Expand Down
28 changes: 23 additions & 5 deletions tests/steps/other_v2_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -1514,11 +1514,6 @@ def step_impl(context):
context.stx = transaction.SignedTransaction(context.txn, None)


@when("we make a GetLedgerStateDelta call against round {round}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this below to group similar state delta calls

def get_ledger_state_delta_call(context, round):
context.response = context.acl.get_ledger_state_delta(round)


@when("we make a SetSyncRound call against round {round}")
def set_sync_round_call(context, round):
context.response = context.acl.set_sync_round(round)
Expand Down Expand Up @@ -1547,3 +1542,26 @@ def set_block_timestamp_offset(context, offset):
@when("we make a GetBlockTimeStampOffset call")
def get_block_timestamp_offset(context):
context.response = context.acl.get_timestamp_offset()


@when("we make a GetLedgerStateDelta call against round {round}")
def get_ledger_state_delta_call(context, round):
context.response = context.acl.get_ledger_state_delta(round)


@when(
"we make a TransactionGroupLedgerStateDeltaForRoundResponse call for round {round}"
)
def get_transaction_group_ledger_state_deltas_for_round(context, round):
context.response = (
context.acl.get_transaction_group_ledger_state_deltas_for_round(round)
)


@when(
'we make a LedgerStateDeltaForTransactionGroupResponse call for ID "{id}"'
)
def get_ledger_state_delta_for_transaction_group(context, id):
context.response = (
context.acl.get_ledger_state_delta_for_transaction_group(id)
)
2 changes: 2 additions & 0 deletions tests/unit.tags
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
@unit.responses.timestamp
@unit.responses.unlimited_assets
@unit.sourcemap
@unit.statedelta
@unit.sync
@unit.tealsign
@unit.timestamp
@unit.transactions
@unit.transactions.keyreg
@unit.transactions.payment
@unit.txngroupdeltas
@unit.stateproof.paths
@unit.stateproof.responses