diff --git a/README.md b/README.md index 2ca0349..636d825 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ make test * Download and install the [Aptos CLI](https://aptos.dev/tools/aptos-cli/use-cli/running-a-local-network). * Set the environment variable `APTOS_CLI_PATH` to the full path of the CLI. * Retrieve the [Aptos Core Github Repo](https://github.com/aptos-labs/aptos-core) (git clone https://github.com/aptos-labs/aptos-core) -* Set the environment variable `APTOS_CORE_REPO` to the full path of the Repository. +* Set the environment variable `APTOS_CORE_PATH` to the full path of the Repository. * `make integration_test` You can do this a bit more manually by: @@ -41,7 +41,7 @@ aptos node run-local-testnet --force-restart --assume-yes --with-indexer-api Next, tell the end-to-end tests to talk to this locally running testnet: ```bash -export APTOS_CORE_REPO="/path/to/repo" +export APTOS_CORE_PATH="/path/to/repo" export APTOS_FAUCET_URL="http://127.0.0.1:8081" export APTOS_INDEXER_URL="http://127.0.0.1:8090/v1/graphql" export APTOS_NODE_URL="http://127.0.0.1:8080/v1" diff --git a/examples/common.py b/examples/common.py index 6ac9d84..b80d54f 100644 --- a/examples/common.py +++ b/examples/common.py @@ -13,9 +13,6 @@ "APTOS_FAUCET_URL", "https://faucet.devnet.aptoslabs.com", ) -INDEXER_URL = os.getenv( - "APTOS_INDEXER_URL", - "https://api.devnet.aptoslabs.com/v1/graphql", -) +INDEXER_URL = os.getenv("APTOS_INDEXER_URL") NODE_URL = os.getenv("APTOS_NODE_URL", "https://api.devnet.aptoslabs.com/v1") # <:!:section_1 diff --git a/examples/integration_test.py b/examples/integration_test.py index 1814a9a..6f38cb9 100644 --- a/examples/integration_test.py +++ b/examples/integration_test.py @@ -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 @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" 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,7 +123,7 @@ 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")} @@ -129,11 +131,11 @@ async def test_your_coin(self): 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__": diff --git a/examples/multikey.py b/examples/multikey.py index aeac707..4239eb8 100644 --- a/examples/multikey.py +++ b/examples/multikey.py @@ -7,7 +7,7 @@ from aptos_sdk.account import Account from aptos_sdk.account_address import AccountAddress from aptos_sdk.asymmetric_crypto_wrapper import MultiSignature, Signature -from aptos_sdk.async_client import FaucetClient, IndexerClient, RestClient +from aptos_sdk.async_client import FaucetClient, RestClient from aptos_sdk.authenticator import AccountAuthenticator, MultiKeyAuthenticator from aptos_sdk.bcs import Serializer from aptos_sdk.transactions import ( @@ -17,17 +17,13 @@ TransactionPayload, ) -from .common import FAUCET_URL, INDEXER_URL, NODE_URL +from .common import FAUCET_URL, NODE_URL async def main(): # :!:>section_1 rest_client = RestClient(NODE_URL) faucet_client = FaucetClient(FAUCET_URL, rest_client) # <:!:section_1 - if INDEXER_URL and INDEXER_URL != "none": - IndexerClient(INDEXER_URL) - else: - pass # :!:>section_2 key1 = secp256k1_ecdsa.PrivateKey.random()