Skip to content

Commit

Permalink
move local_account module into testing package
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiao Li committed Mar 30, 2021
1 parent 1897196 commit cf02272
Show file tree
Hide file tree
Showing 18 changed files with 43 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,5 @@ Sub-modules:
- `identifier`: Diem Account Identifier and Diem Intent Identifier. [DIP-5](https://dip.diem.com/dip-5/)
- `txnmetadata`: utils for creating peer to peer transaction metadata. [DIP-4](https://dip.diem.com/dip-4/)
- `testnet`: Testnet utility, minting coins, create Testnet client, chain id, Testnet JSON-RPC URL.
- `LocalAccount` | `local_account`: utility for managing local account keys, generate random local account.
- `testing`: Testing utility, MiniWallet application, MiniWallet test suites, `LocalAccount` for managing local account keys and generating random local account.
- `chain_ids`: list of static chain ids
2 changes: 1 addition & 1 deletion examples/create_child_vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
stdlib,
testnet,
utils,
LocalAccount,
)
from diem.testing import LocalAccount


def test_create_child_vasp():
Expand Down
3 changes: 2 additions & 1 deletion examples/tests/test_offchain_error_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
CommandResponseError,
PaymentActionObject,
)
from diem import LocalAccount, testnet
from diem import testnet
from diem.testing import LocalAccount
from ..vasp.wallet import ActionResult
import dataclasses, requests, json, copy, pytest, uuid

Expand Down
2 changes: 1 addition & 1 deletion examples/vasp/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
stdlib,
testnet,
utils,
LocalAccount,
offchain,
)
from diem.testing import LocalAccount
import logging, threading, typing

logger: logging.Logger = logging.getLogger(__name__)
Expand Down
4 changes: 3 additions & 1 deletion src/diem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@

from .utils import InvalidAccountAddressError, InvalidSubAddressError
from .auth_key import AuthKey
from .local_account import LocalAccount

# keep this import for backwards compatible
from .testing import LocalAccount
9 changes: 9 additions & 0 deletions src/diem/testing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# Copyright (c) The Diem Core Contributors
# SPDX-License-Identifier: Apache-2.0

"""This module provides testing utilities:
1. MiniWallet application as counterparty wallet application stub for testing your wallet application.
2. Payment test suites provide tests running on top of MiniWallet API for testing wallet application payment features.
3. `LocalAccount` for managing local account keys and generating random local account.
"""

from .local_account import LocalAccount
3 changes: 2 additions & 1 deletion src/diem/testing/cli/click.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Copyright (c) The Diem Core Contributors
# SPDX-License-Identifier: Apache-2.0

from diem import testnet, LocalAccount
from diem import testnet
from diem.testing import LocalAccount
from diem.testing.miniwallet import AppConfig, ServerConfig
from diem.testing.suites import envs
from typing import Optional, TextIO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
raw transaction.
"""

from . import diem_types, jsonrpc, utils, stdlib, identifier
from .serde_types import uint64
from .. import diem_types, jsonrpc, utils, stdlib, identifier
from ..serde_types import uint64

from .auth_key import AuthKey
from ..auth_key import AuthKey
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey
from typing import Dict, Optional, Tuple, Union
from dataclasses import dataclass, field
Expand Down
3 changes: 2 additions & 1 deletion src/diem/testing/miniwallet/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from .models import PaymentUri, Subaddress, Account, Transaction, Event, KycSample, Payment, PaymentCommand
from .event_puller import EventPuller
from .json_input import JsonInput
from .... import jsonrpc, offchain, utils, LocalAccount, identifier
from ... import LocalAccount
from .... import jsonrpc, offchain, utils, identifier
from ....offchain import KycDataObject, Status, AbortCode, CommandResponseObject
import threading, logging, numpy

Expand Down
3 changes: 2 additions & 1 deletion src/diem/testing/miniwallet/app/diem_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from dataclasses import dataclass
from typing import Tuple
from .models import Transaction, RefundReason
from .... import jsonrpc, identifier, offchain, stdlib, utils, txnmetadata, LocalAccount
from ... import LocalAccount
from .... import jsonrpc, identifier, offchain, stdlib, utils, txnmetadata


@dataclass
Expand Down
3 changes: 2 additions & 1 deletion src/diem/testing/miniwallet/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from typing import Dict, Any
from .client import RestClient
from .app import App, falcon_api
from ... import offchain, testnet, jsonrpc, utils, LocalAccount
from .. import LocalAccount
from ... import offchain, testnet, jsonrpc, utils
import waitress, threading, logging, falcon, json


Expand Down
6 changes: 4 additions & 2 deletions src/diem/testnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
```python
from diem import testnet, LocalAccount
from diem import testnet
from diem.testing import LocalAccount
# create client connects to testnet
client = testnet.create_client()
Expand All @@ -23,7 +24,8 @@
import requests
import typing

from . import diem_types, jsonrpc, utils, chain_ids, bcs, stdlib, identifier, LocalAccount
from . import diem_types, jsonrpc, utils, chain_ids, bcs, stdlib, identifier
from .testing import LocalAccount


JSON_RPC_URL: str = "http://testnet.diem.com/v1"
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# SPDX-License-Identifier: Apache-2.0


from diem import testnet, offchain, identifier, LocalAccount
from diem import testnet, offchain, identifier
from diem.testing import LocalAccount
import pytest


Expand Down
3 changes: 2 additions & 1 deletion tests/test_local_account.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Copyright (c) The Diem Core Contributors
# SPDX-License-Identifier: Apache-2.0

from diem import identifier, utils, LocalAccount
from diem import identifier, utils
from diem.testing import LocalAccount


def test_from_private_key_hex():
Expand Down
3 changes: 2 additions & 1 deletion tests/test_offchain_jws.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Copyright (c) The Diem Core Contributors
# SPDX-License-Identifier: Apache-2.0

from diem import offchain, LocalAccount
from diem import offchain
from diem.testing import LocalAccount
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
import cryptography, pytest

Expand Down
3 changes: 2 additions & 1 deletion tests/test_offchain_types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Copyright (c) The Diem Core Contributors
# SPDX-License-Identifier: Apache-2.0

from diem import identifier, offchain, LocalAccount
from diem import identifier, offchain
from diem.testing import LocalAccount
import dataclasses, json, pytest, uuid


Expand Down
3 changes: 2 additions & 1 deletion tests/test_testing_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from diem.testing.cli import click
from diem.testing.suites import envs
from diem.testing.miniwallet import ServerConfig
from diem import identifier, testnet, utils, LocalAccount
from diem.testing import LocalAccount
from diem import identifier, testnet, utils
from typing import List
import json, threading, pytest

Expand Down
2 changes: 1 addition & 1 deletion tests/test_testnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
testnet,
utils,
InvalidAccountAddressError,
LocalAccount,
)
from diem.testing import LocalAccount

import time
import pytest
Expand Down

0 comments on commit cf02272

Please sign in to comment.