Skip to content

Commit

Permalink
Fix test with 512 inputs (make sure to avoid the high fee warning)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigspider committed Jan 29, 2024
1 parent db5c6d8 commit fbacb20
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 41 deletions.
20 changes: 12 additions & 8 deletions tests/test_sign_psbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,16 +709,13 @@ def test_sign_psbt_singlesig_large_amount(client: Client, comm: SpeculosClient,

@pytest.mark.timeout(0) # disable timeout
@has_automation("automations/sign_with_default_wallet_accept.json")
def test_sign_psbt_singlesig_wpkh_512to256(client: Client, enable_slow_tests: bool):
def test_sign_psbt_singlesig_tr_512to256(client: Client, enable_slow_tests: bool):
# PSBT for a transaction with 512 inputs and 256 outputs (maximum currently supported in the app)
# Very slow test (esp. with DEBUG enabled), so disabled unless the --enableslowtests option is used

if not enable_slow_tests:
pytest.skip()

n_inputs = 512
n_outputs = 256

wallet = WalletPolicy(
"",
"tr(@0/**)",
Expand All @@ -727,10 +724,17 @@ def test_sign_psbt_singlesig_wpkh_512to256(client: Client, enable_slow_tests: bo
],
)

n_inputs = 512
n_outputs = 256

input_amounts = [10000 + 10000 * i for i in range(n_inputs)]
total_amount = sum(input_amounts)
output_amounts = [(total_amount // n_outputs) - 10 for _ in range(n_outputs)]

psbt = txmaker.createPsbt(
wallet,
[10000 + 10000 * i for i in range(n_inputs)],
[999 + 99 * i for i in range(n_outputs)],
input_amounts,
output_amounts,
[i == 42 for i in range(n_outputs)]
)

Expand All @@ -739,7 +743,7 @@ def test_sign_psbt_singlesig_wpkh_512to256(client: Client, enable_slow_tests: bo
assert len(result) == n_inputs


def ux_thread_acept_prompt_stax(speculos_client: SpeculosClient, all_events: List[dict]):
def ux_thread_accept_prompt_stax(speculos_client: SpeculosClient, all_events: List[dict]):
"""Completes the signing flow always going right and accepting at the appropriate time, while collecting all the events in all_events."""

while True:
Expand Down Expand Up @@ -772,7 +776,7 @@ def test_sign_psbt_fail_11_changes(client: Client, comm: SpeculosClient, model:
all_events: List[dict] = []

if model == "stax":
x = threading.Thread(target=ux_thread_acept_prompt_stax, args=[comm, all_events])
x = threading.Thread(target=ux_thread_accept_prompt_stax, args=[comm, all_events])

x.start()
with pytest.raises(NotSupportedError):
Expand Down
33 changes: 0 additions & 33 deletions tests/test_sign_psbt_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,39 +481,6 @@ def test_sign_psbt_singlesig_large_amount_v1(client: Client, comm: SpeculosClien
assert parsed_events["amounts"][0] == format_amount(CURRENCY_TICKER, out_amt)


@pytest.mark.timeout(0) # disable timeout
@has_automation("automations/sign_with_default_wallet_accept.json")
def test_sign_psbt_singlesig_wpkh_512to256_v1(client: Client, enable_slow_tests: bool):
# PSBT for a transaction with 512 inputs and 256 outputs (maximum currently supported in the app)
# Very slow test (esp. with DEBUG enabled), so disabled unless the --enableslowtests option is used

if not enable_slow_tests:
pytest.skip()

n_inputs = 512
n_outputs = 256

wallet = WalletPolicy(
"",
"tr(@0)",
[
"[f5acc2fd/86'/1'/0']tpubDDKYE6BREvDsSWMazgHoyQWiJwYaDDYPbCFjYxN3HFXJP5fokeiK4hwK5tTLBNEDBwrDXn8cQ4v9b2xdW62Xr5yxoQdMu1v6c7UDXYVH27U/**"
],
version=WalletType.WALLET_POLICY_V1
)

psbt = txmaker.createPsbt(
wallet,
[10000 + 10000 * i for i in range(n_inputs)],
[999 + 99 * i for i in range(n_outputs)],
[i == 42 for i in range(n_outputs)]
)

result = client.sign_psbt(psbt, wallet, None)

assert len(result) == n_inputs


def ux_thread_accept_prompt_stax(speculos_client: SpeculosClient, all_events: List[dict]):
"""Completes the signing flow always going right and accepting at the appropriate time, while collecting all the events in all_events."""

Expand Down

0 comments on commit fbacb20

Please sign in to comment.