-
Notifications
You must be signed in to change notification settings - Fork 23
refactor environment variables handling and remove unused code #33
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,24 +13,26 @@ | |
| from aptos_sdk.account_address import AccountAddress | ||
| from aptos_sdk.aptos_cli_wrapper import AptosCLIWrapper, AptosInstance | ||
|
|
||
| from .common import APTOS_CORE_PATH | ||
|
|
||
|
|
||
| class Test(unittest.IsolatedAsyncioTestCase): | ||
| _node: Optional[AptosInstance] = None | ||
| _aptos_core_path: str | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why this refactor?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we import os.environ["APTOS_FAUCET_URL"] = "http://127.0.0.1:8081"
os.environ["APTOS_NODE_URL"] = "http://127.0.0.1:8080/v1"of So
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm... because it is |
||
|
|
||
| @classmethod | ||
| def setUpClass(self): | ||
| def setUpClass(cls): | ||
| cls._aptos_core_path = os.getenv("APTOS_CORE_PATH") | ||
| if not cls._aptos_core_path: | ||
| raise Exception("Environment variable `APTOS_CORE_PATH` is not set") | ||
|
|
||
| if os.getenv("APTOS_TEST_USE_EXISTING_NETWORK"): | ||
| return | ||
|
|
||
| self._node = AptosCLIWrapper.start_node() | ||
| operational = asyncio.run(self._node.wait_until_operational()) | ||
| cls._node = AptosCLIWrapper.start_node() | ||
| operational = asyncio.run(cls._node.wait_until_operational()) | ||
| if not operational: | ||
| raise Exception("".join(self._node.errors())) | ||
| raise Exception("".join(cls._node.errors())) | ||
|
|
||
| os.environ["APTOS_FAUCET_URL"] = "http://127.0.0.1:8081" | ||
| os.environ["APTOS_INDEXER_CLIENT"] = "none" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so what you're saying is that this doesn't actually set the environment variable and it is overwritten each time in common.py? That doesn't make a lot of sense according to the docs. The way it should work is that we set this once during the class call to "none", each common.py should see that it is set to "none" and leave it alone, during loading of the indexer client we should see it is "none" and not touch it. |
||
| os.environ["APTOS_NODE_URL"] = "http://127.0.0.1:8080/v1" | ||
|
|
||
| async def test_aptos_token(self): | ||
|
|
@@ -47,7 +49,7 @@ async def test_hello_blockchain(self): | |
| from . import hello_blockchain | ||
|
|
||
| hello_blockchain_dir = os.path.join( | ||
| APTOS_CORE_PATH, "aptos-move", "move-examples", "hello_blockchain" | ||
| self._aptos_core_path, "aptos-move", "move-examples", "hello_blockchain" | ||
| ) | ||
| AptosCLIWrapper.test_package( | ||
| hello_blockchain_dir, {"hello_blockchain": AccountAddress.from_str("0xa")} | ||
|
|
@@ -62,7 +64,7 @@ async def test_large_package_publisher(self): | |
| from . import large_package_publisher | ||
|
|
||
| large_packages_dir = os.path.join( | ||
| APTOS_CORE_PATH, "aptos-move", "move-examples", "large_packages" | ||
| self._aptos_core_path, "aptos-move", "move-examples", "large_packages" | ||
| ) | ||
| module_addr = await large_package_publisher.publish_large_packages( | ||
| large_packages_dir | ||
|
|
@@ -121,19 +123,19 @@ async def test_your_coin(self): | |
| from . import your_coin | ||
|
|
||
| moon_coin_path = os.path.join( | ||
| APTOS_CORE_PATH, "aptos-move", "move-examples", "moon_coin" | ||
| self._aptos_core_path, "aptos-move", "move-examples", "moon_coin" | ||
| ) | ||
| AptosCLIWrapper.test_package( | ||
| moon_coin_path, {"MoonCoin": AccountAddress.from_str("0xa")} | ||
| ) | ||
| await your_coin.main(moon_coin_path) | ||
|
|
||
| @classmethod | ||
| def tearDownClass(self): | ||
| def tearDownClass(cls): | ||
| if os.getenv("APTOS_TEST_USE_EXISTING_NETWORK"): | ||
| return | ||
|
|
||
| self._node.stop() | ||
| cls._node.stop() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This first looks into
APTOS_INDEXER_URL, but in the case user is running localnet without the--with-indexer-api(and withoutAPTOS_INDEXER_URL) this default value will give us the devnet indexer url, when we're running local tests without an indexer.Test cases using indexer like
test_transfer_coinfails if we keep this default value.