Esempio n. 1
0
 def setUp(self):
     self.network_type = models.NetworkType.MIJIN_TEST
     self.address = models.Address(
         "SD5DT3CH4BLABL5HIMEKP2TAPUKF4NY3L5HRIR54")
     self.namespace_id = models.NamespaceId(0x84b3552d375ffa4b)
     self.address_dto = '90fa39ec47e05600afa74308a7ea607d145e371b5f4f1447bc'
     self.namespace_dto = '914bfa5f372d55b38400000000000000000000000000000000'
     self.address_catbuffer = util.unhexlify(self.address_dto)
     self.namespace_catbuffer = util.unhexlify(self.namespace_dto)
 def test_invalid_identifier(self, address: str):
     with self.assertRaises(KeyError):
         models.Address(address)
Esempio n. 3
0
from tests import responses
from xpxchain import util


@harness.mocked_http_test_case({
    'clients': (client.AccountHTTP, client.AsyncAccountHTTP),
    'network_type':
    models.NetworkType.MIJIN_TEST,
    'tests': [
        {
            'name':
            'test_get_account_info',
            'response':
            responses.ACCOUNT_INFO["Ok"],
            'params':
            [models.Address('SCBO3CAFOVAOGYBAHQKPUOGLAYWFLNJUFFCH3RYY')],
            'method':
            'get_account_info',
            'validation': [
                lambda x:
                (x.public_key,
                 '7A562888C7AE1E082579951D6D93BF931DE979360ACCA4C4085D754E5E122808'
                 ),
                lambda x: (x.mosaics, []),
            ],
        },
        {
            'name':
            'test_get_accounts_info',
            'response':
            responses.ACCOUNTS_INFO["Ok"],
 def test_mostly_valid(self, address: str):
     model = models.Address(address)
     self.assertEqual(model.address.lower(), address.lower())
     self.assertFalse(model.is_valid())
Esempio n. 5
0
 '7CCDF81A60B0A03A3B30D715C5C7513916319C09215E22C67B0A81106FB21445',
 'total_fee':
 0,
 'num_transactions':
 31,
 'num_statements':
 0,
 'signature':
 '82D8C518BF32CA9A8478451F79B7EEC69F11E6022AF7230CE21F230A09E51A0CEB169454CB4AD4499BC9C0769B468AB5A6DD716D00C977F16BF63DD1B0653305',
 'network_type':
 models.NetworkType.MIJIN_TEST,
 'signer':
 models.PublicAccount(
     public_key=
     'A04335F99D9EE3787528A16C7A302F80D511E9CF71D97D95C2182E0EA75A1EF9',
     address=models.Address('SAHCS4U27RLSCD7N6XWR4KV2M4VEQY2OCXMEZN3H'),
 ),
 'version':
 models.TransactionVersion.TRANSFER,
 'type':
 models.BlockType.GENESIS,
 'height':
 1,
 'timestamp':
 0,
 'difficulty':
 100000000000000,
 'fee_multiplier':
 0,
 'previous_block_hash':
 '0000000000000000000000000000000000000000000000000000000000000000',
                        util.u64_from_dto([130473079, 2260557970]))),
         lambda x: (len(x.metadata.flds), 2),
         lambda x: (isinstance(x.metadata.flds[0], models.Field), True),
         lambda x: (x.metadata.flds[0].key, 'foo'),
         lambda x: (x.metadata.flds[0].value, 'bar'),
         lambda x: (x.metadata.flds[1].key, 'foo2'),
         lambda x: (x.metadata.flds[1].value, 'bar'),
     ],
 },
 {
     'name':
     'test_get_metadata',
     'response':
     responses.METADATA["Ok"],
     'params':
     [models.Address('SCV36Q2G5CJ2R2SOIIGG3O46X2N6SGAM2QCW5KRI')],
     'method':
     'get_metadata',
     'validation': [
         lambda x: (isinstance(x, models.MetadataInfo), True),
         lambda x:
         (isinstance(x.metadata, models.AddressMetadata), True),
         lambda x:
         (x.metadata.metadata_type, models.MetadataType.ADDRESS),
         lambda x:
         (isinstance(x.metadata.metadata_id, models.Address), True),
         lambda x:
         (x.metadata.metadata_id.hex,
          '90ABBF4346E893A8EA4E420C6DBB9EBE9BE9180CD4056EAA28'),
         lambda x: (len(x.metadata.flds), 2),
         lambda x: (isinstance(x.metadata.flds[0], models.Field), True),
from xpxchain import models
from xpxchain import util
from tests import harness


@harness.model_test_case({
    'type': models.Account,
    'network_type': models.NetworkType.MIJIN_TEST,
    'data': {
        'address': models.Address('SAUJCIBCOFLHUZIWNB32MR6YUX75HO7GGCVZEXSG'),
        'public_key': '1b153f8b76ef60a4bfe152f4de3698bd230bac9dc239d4e448715aa46bd58955',
        'private_key': '97131746d864f4c9001b1b86044d765ba08d7fddc7a0fb3abbc8d111aa26cdca',
    },
})
class TestAccount(harness.TestCase):

    def test_properties(self):
        public_account = models.PublicAccount(self.model.address, self.model.public_key)
        self.assertEqual(self.model.network_type, self.network_type)
        self.assertEqual(self.model.public_account, public_account)

    @harness.ignore_warnings_test
    def test_create_from_private_key(self):
        value = self.type.create_from_private_key(self.data['private_key'], self.network_type)
        self.assertEqual(value, self.model)

    @harness.ignore_warnings_test
    def test_generate_new_account(self):
        def fake_entropy(size: int) -> bytes:
            return b'0' * size
     [[models.NamespaceId.create_from_hex('84b3552d375ffa4b')]],
     'method':
     'get_namespaces_name',
     'validation': [
         lambda x: (len(x), 1),
         lambda x: (x[0].namespace_id.encoded, '4bfa5f372d55b384'),
         lambda x: (x[0].name, 'nem'),
     ]
 },
 {
     'name':
     'test_get_namespaces_from_account',
     'response':
     responses.NAMESPACES["nem"],
     'params':
     [models.Address('SD3MA6SM7GWRX4DEJVAZEGFXF7G7D36MA6TMSIBM')],
     'method':
     'get_namespaces_from_account',
     'validation': [
         lambda x: (len(x), 1),
         lambda x: (x[0].meta_id, '5C7C07005CC1FE000176FA2B'),
     ]
 },
 {
     'name':
     'test_get_namespaces_from_accounts',
     'response':
     responses.NAMESPACES["nem"],
     'params':
     [[models.Address('SD3MA6SM7GWRX4DEJVAZEGFXF7G7D36MA6TMSIBM')]],
     'method':
from xpxchain import models
from tests import harness


@harness.model_test_case({
    'type': models.AddressAlias,
    'network_type': models.NetworkType.MIJIN_TEST,
    'data': {
        'value': models.Address('SD5DT3CH4BLABL5HIMEKP2TAPUKF4NY3L5HRIR54'),
    },
    # TODO(ahuszagh) Check the format, and confirm.
    # https://xpx.slack.com/archives/CEZKUE4KB/p1553274126174200
    'dto': {
        'type': 2,
        'address': '90fa39ec47e05600afa74308a7ea607d145e371b5f4f1447bc',
    },
    'extras': {
        'mosaic_id': models.MosaicId(5),
    },
})
class TestAddressAlias(harness.TestCase):
    def test_rich_eq(self):
        empty_alias = models.Alias()
        address_alias = models.Alias(models.AliasType.ADDRESS,
                                     self.data['value'])
        mosaic_alias = models.Alias(models.AliasType.MOSAIC_ID,
                                    self.extras['mosaic_id'])

        self.assertNotEqual(self.model, empty_alias)
        self.assertEqual(self.model, address_alias)
        self.assertNotEqual(self.model, mosaic_alias)