-
Notifications
You must be signed in to change notification settings - Fork 19
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
refactor environment variables handling and remove unused code #33
base: main
Are you sure you want to change the base?
Conversation
* common.py: removed default `INDEXER_URL` value since it shouldn't be set when we're running localnet without an indexer. * integration_test.py: decoupled from common.py since currently it is also loaded in each test case, but only imported once at import time of integration_test.py. This nullifies environment variable handling in the `setUpClass` method. * multikey.py: removed unused code * README.md: `APTOS_CORE_REPO` => `APTOS_CORE_PATH`
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.
Thanks!
We use indexer here: https://github.com/aptos-labs/aptos-python-sdk/blob/main/examples/transfer_coin.py#L68
better to keep it around since we likely will use it for some SDK Api, sooner than later.
@davidiw Got it!
All the cases are handled properly in https://github.com/aptos-labs/aptos-python-sdk/blob/main/examples/transfer_coin.py#L16 This will still allow utilizing the indexer in local/devnet/testnet tests once the |
…gration_test.py` to utilize local indexer if it is running
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.
almost there
INDEXER_URL = os.getenv( | ||
"APTOS_INDEXER_URL", | ||
"https://api.devnet.aptoslabs.com/v1/graphql", | ||
) | ||
INDEXER_URL = os.getenv("APTOS_INDEXER_URL") |
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 without APTOS_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_coin
fails if we keep this default value.
|
||
class Test(unittest.IsolatedAsyncioTestCase): | ||
_node: Optional[AptosInstance] = None | ||
_aptos_core_path: str |
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 this refactor?
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.
If we import common.py
here,
os.environ["APTOS_FAUCET_URL"] = "http://127.0.0.1:8081"
os.environ["APTOS_NODE_URL"] = "http://127.0.0.1:8080/v1"
of setUpClass
method in integration_test.py
will not be applied in each test case.
So make integration_test
is basically running tests on devnet right now.
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.
Hmm... because it is setUpClass
, let's move these to setUp
then. Good call!
but how does one even test common otherwise? |
|
||
os.environ["APTOS_FAUCET_URL"] = "http://127.0.0.1:8081" | ||
os.environ["APTOS_INDEXER_CLIENT"] = "none" |
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.
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.
Description
common.py: removed default
INDEXER_URL
value since it shouldn't be set when we're running localnet without an indexer.integration_test.py: decoupled from common.py since currently it is also loaded in each test case, but only imported once at import time of integration_test.py. This nullifies environment variable handling in the
setUpClass
method.multikey.py: removed unused code
README.md:
APTOS_CORE_REPO
=>APTOS_CORE_PATH
Test Plan
Related Links