Esempio n. 1
0
__author__ = '*****@*****.**'

from mock import patch, Mock

from core.utils.logging import getLogger

logger = getLogger(__name__)

operations = []


class EthereumClientMockMixin():
    """
        EthereumClientMockMixin substitute original ethereum client and return mock eth addresses
    """

    def flush_ethereum_client_operations(self):
        global operations
        operations = []

    def get_ethereum_wallet_operations(self):
        global operations
        return operations

    def mock_ethereum_client(self):
        # WARNING!: Be careful with names you may override variables in the class that inherit this mixin!

        self._ethereum_mock_wallet_client = MockClient()
        self._ethereum_client_patcher = patch('absortium.wallet.ethereum.EthereumClient',
                                              new=self._ethereum_mock_wallet_client)
        self._ethereum_client_patcher.start()
Esempio n. 2
0
from ethwallet.utils import HMACClient

__author__ = '*****@*****.**'

from django.contrib.auth import get_user_model

from ethwallet.models import Address

from ethwallet.tests.base import EthWalletUnitTest
from core.utils.logging import getLogger

logger = getLogger(__name__)


class AuthenticationTest(EthWalletUnitTest):
    def test_authentication(self):
        User = get_user_model()
        user = User(username="******")
        user.save()

        self.client.logout()
        self.client = HMACClient()
        self.client.init_user(user)

        first_address = self.create_address()
        obj = Address.objects.get(address=first_address['address'])
        self.assertEqual(obj.owner, user)

        second_address = self.create_address()
        obj = Address.objects.get(address=second_address['address'])
        self.assertEqual(obj.owner, user)