-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added network id to the base transaction Added network id to the server_info response Added network id to the binary codec Added network id to autofill if custom network id was supplied to client. Co-authored-by: pdp2121 <71317875+pdp2121@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
199 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from unittest import TestCase | ||
|
||
from xrpl.asyncio.transaction.main import _RESTRICTED_NETWORKS | ||
from xrpl.clients import JsonRpcClient, WebsocketClient | ||
from xrpl.models.transactions import AccountSet | ||
from xrpl.transaction import autofill | ||
from xrpl.wallet.wallet_generation import generate_faucet_wallet | ||
|
||
_FEE = "0.00001" | ||
|
||
|
||
class TestAutofill(TestCase): | ||
# Autofill should override tx networkID for network with ID > 1024 | ||
# and build_version from 1.11.0 or later. | ||
def test_networkid_override(self): | ||
client = JsonRpcClient("https://sidechain-net1.devnet.rippletest.net:51234") | ||
wallet = generate_faucet_wallet(client, debug=True) | ||
# Override client build_version since 1.11.0 is not released yet. | ||
client.build_version = "1.11.0" | ||
tx = AccountSet( | ||
account=wallet.classic_address, | ||
fee=_FEE, | ||
domain="www.example.com", | ||
) | ||
tx_autofilled = autofill(tx, client) | ||
self.assertGreaterEqual(client.network_id, _RESTRICTED_NETWORKS) | ||
self.assertEqual(tx_autofilled.network_id, client.network_id) | ||
|
||
# Autofill should ignore tx network_id for build version earlier than 1.11.0. | ||
def test_networkid_ignore_early_version(self): | ||
client = JsonRpcClient("https://sidechain-net1.devnet.rippletest.net:51234") | ||
wallet = generate_faucet_wallet(client, debug=True) | ||
# Override client build_version since 1.11.0 is not released yet. | ||
client.build_version = "1.10.0" | ||
tx = AccountSet( | ||
account=wallet.classic_address, | ||
fee=_FEE, | ||
domain="www.example.com", | ||
) | ||
tx_autofilled = autofill(tx, client) | ||
self.assertEqual(tx_autofilled.network_id, None) | ||
|
||
# Autofill should ignore tx network_id for networks with ID <= 1024. | ||
def test_networkid_ignore_restricted_networks(self): | ||
client = JsonRpcClient("https://s.altnet.rippletest.net:51234") | ||
wallet = generate_faucet_wallet(client, debug=True) | ||
# Override client build_version since 1.11.0 is not released yet. | ||
client.build_version = "1.11.0" | ||
tx = AccountSet( | ||
account=wallet.classic_address, | ||
fee=_FEE, | ||
domain="www.example.com", | ||
) | ||
tx_autofilled = autofill(tx, client) | ||
self.assertLessEqual(client.network_id, _RESTRICTED_NETWORKS) | ||
self.assertEqual(tx_autofilled.network_id, None) | ||
|
||
# Autofill should override tx networkID for hooks-testnet. | ||
def test_networkid_override_hooks_testnet(self): | ||
with WebsocketClient("wss://hooks-testnet-v3.xrpl-labs.com") as client: | ||
wallet = generate_faucet_wallet(client, debug=True) | ||
tx = AccountSet( | ||
account=wallet.classic_address, | ||
fee=_FEE, | ||
domain="www.example.com", | ||
) | ||
tx_autofilled = autofill(tx, client) | ||
self.assertEqual(tx_autofilled.network_id, client.network_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters