Skip to content

Commit

Permalink
fix: support new client generator simulate
Browse files Browse the repository at this point in the history
  • Loading branch information
neilcampbell committed Dec 14, 2023
1 parent 00f9135 commit c23c516
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion template_content/.algokit.toml.jinja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[algokit]
min_version = "v1.7.3"
min_version = "v1.8.0"

[deploy]
{%- if deployment_language == 'python' %}
Expand Down
2 changes: 1 addition & 1 deletion template_content/smart_contracts/helpers/build.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def build(output_dir: Path, app: beaker.Application) -> Path:
if result.returncode:
if "No such command" in result.stdout:
raise Exception(
"Could not generate typed client, requires AlgoKit 1.1 or "
"Could not generate typed client, requires AlgoKit 1.8.0 or "
"later. Please update AlgoKit"
)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def test_says_hello({{ contract_name }}_client: {{ contract_name.split('_')|map(
def test_simulate_says_hello_with_correct_budget_consumed(
{{ contract_name }}_client: {{ contract_name.split('_')|map('capitalize')|join }}Client, algod_client: AlgodClient
) -> None:
atc = {{ contract_name }}_client.compose().hello(name="World").hello(name="Jane").atc

result = atc.simulate(algod_client)
result = (
{{ contract_name }}_client.compose().hello(name="World").hello(name="Jane").simulate()
)

assert result.abi_results[0].return_value == "Hello, World"
assert result.abi_results[1].return_value == "Hello, Jane"
assert result.simulate_response["txn-groups"][0]["app-budget-consumed"] == 98
assert result.simulate_response["txn-groups"][0]["app-budget-consumed"] < 100
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ describe('{{ contract_name.split('_')|join(' ') }} contract', () => {
test('simulate says hello with correct budget consumed', async () => {
const { algod, indexer, testAccount } = localnet.context
const { client } = await deploy(testAccount, algod, indexer)
const atc = await client.compose().hello({ name: 'World' }).hello({ name: 'Jane' }).atc()

const result = await atc.simulate(algod)
const result = await client.compose().hello({ name: 'World' }).hello({ name: 'Jane' }).simulate()

expect(result.methodResults[0].returnValue).toBe('Hello, World')
expect(result.methodResults[1].returnValue).toBe('Hello, Jane')
expect(result.simulateResponse.txnGroups[0].appBudgetConsumed).toBe(98)
expect(result.simulateResponse.txnGroups[0].appBudgetConsumed).toBeLessThan(100)
})
})

0 comments on commit c23c516

Please sign in to comment.