Skip to content

Commit 1b5f66c

Browse files
test: use the shared _create_account_xdr helper after merging main
The main merge brought a two-argument _create_account_xdr(keypair, account); drop this branch's stale zero-argument copy and update the xdrFormat tests to call the shared helper.
1 parent 460d81e commit 1b5f66c

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

src/tests/integration/test_server.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -739,23 +739,15 @@ def builder() -> TransactionBuilder:
739739
# ----------------------------------------------------------------------
740740

741741

742-
def _create_account_xdr() -> str:
743-
"""A freshly signed CreateAccount transaction envelope, base64 XDR."""
742+
def test_xdr_format_base64_behaves_as_default(server: StellarRpcServer) -> None:
743+
"""xdrFormat 'base64' is the explicit spelling of the default on both methods."""
744744
keypair = Keypair.random()
745745
account = Account(keypair.public_key, sequence=0)
746-
envelope = (
747-
TransactionBuilder(account, Network.TESTNET_NETWORK_PASSPHRASE)
748-
.append_create_account_op(destination=keypair.public_key, starting_balance='1000')
749-
.set_timeout(30)
750-
.build()
746+
send_result = _rpc(
747+
server.port(),
748+
'sendTransaction',
749+
{'transaction': _create_account_xdr(keypair, account), 'xdrFormat': 'base64'},
751750
)
752-
envelope.sign(keypair)
753-
return envelope.to_xdr()
754-
755-
756-
def test_xdr_format_base64_behaves_as_default(server: StellarRpcServer) -> None:
757-
"""xdrFormat 'base64' is the explicit spelling of the default on both methods."""
758-
send_result = _rpc(server.port(), 'sendTransaction', {'transaction': _create_account_xdr(), 'xdrFormat': 'base64'})
759751
assert send_result['result']['status'] == 'PENDING'
760752
tx_hash = send_result['result']['hash']
761753

@@ -782,7 +774,13 @@ def test_get_transaction_xdr_format_non_string_returns_invalid_params(server: St
782774

783775
def test_send_transaction_xdr_format_json_returns_invalid_params_without_executing(server: StellarRpcServer) -> None:
784776
"""An unsupported xdrFormat is rejected before the transaction runs: no state change."""
785-
result = _rpc(server.port(), 'sendTransaction', {'transaction': _create_account_xdr(), 'xdrFormat': 'json'})
777+
keypair = Keypair.random()
778+
account = Account(keypair.public_key, sequence=0)
779+
result = _rpc(
780+
server.port(),
781+
'sendTransaction',
782+
{'transaction': _create_account_xdr(keypair, account), 'xdrFormat': 'json'},
783+
)
786784
assert result['error']['code'] == -32602
787785
assert 'json' in result['error']['message'].lower()
788786

@@ -792,7 +790,13 @@ def test_send_transaction_xdr_format_json_returns_invalid_params_without_executi
792790

793791

794792
def test_send_transaction_xdr_format_invalid_value_returns_invalid_params(server: StellarRpcServer) -> None:
795-
result = _rpc(server.port(), 'sendTransaction', {'transaction': _create_account_xdr(), 'xdrFormat': 'yaml'})
793+
keypair = Keypair.random()
794+
account = Account(keypair.public_key, sequence=0)
795+
result = _rpc(
796+
server.port(),
797+
'sendTransaction',
798+
{'transaction': _create_account_xdr(keypair, account), 'xdrFormat': 'yaml'},
799+
)
796800
assert result['error']['code'] == -32602
797801
assert list((server.io_dir / 'receipts').iterdir()) == []
798802

0 commit comments

Comments
 (0)