models.Receipt), True),
         lambda x: (x.transaction_statements[0].receipts[0].type, models
                    .ReceiptType.VALIDATE_FEE),
         lambda x: (x.transaction_statements[0].receipts[0].version, 1),
         lambda x:
         (isinstance(x.transaction_statements[0].receipts[0].account,
                     models.PublicAccount), True),
         lambda x:
         (x.transaction_statements[0].receipts[0].account.public_key,
          '346E56F77F07B19D48B3AEF969EDB01F68A5AC9FAF8E5E007577D71BA66385FB'
          ),
         lambda x:
         (isinstance(x.transaction_statements[0].receipts[0].mosaic,
                     models.Mosaic), True),
         lambda x: (x.transaction_statements[0].receipts[0].mosaic.id,
                    models.MosaicId(992621222383397347)),
         lambda x:
         (x.transaction_statements[0].receipts[0].mosaic.amount, 0),
     ]
 },
 {
     'name':
     'test_get_diagnostic_server',
     'response':
     responses.DIAGNOSTIC_SERVER["Ok"],
     'params': [],
     'method':
     'get_diagnostic_server',
     'validation': [
         lambda x: (isinstance(x, models.BlockchainServerInfo), True),
         lambda x: (x.rest_version, '1.0.16'),
          '90ABBF4346E893A8EA4E420C6DBB9EBE9BE9180CD4056EAA28'),
         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_mosaic_metadata',
     'response':
     responses.MOSAIC_METADATA["Ok"],
     'params':
     [models.MosaicId(util.u64_from_dto([1045581869, 105004269]))],
     'method':
     'get_mosaic_metadata',
     'validation': [
         lambda x: (isinstance(x, models.MosaicMetadataInfo), True),
         lambda x:
         (isinstance(x.metadata, models.MosaicMetadata), True),
         lambda x:
         (x.metadata.metadata_type, models.MetadataType.MOSAIC),
         lambda x:
         (isinstance(x.metadata.metadata_id, models.MosaicId), True),
         lambda x:
         (x.metadata.metadata_id,
          models.MosaicId(util.u64_from_dto([1045581869, 105004269]))),
         lambda x: (len(x.metadata.flds), 2),
         lambda x: (isinstance(x.metadata.flds[0], models.Field), True),
Beispiel #3
0
from xpxchain import models
from tests import harness


@harness.model_test_case({
    'type':
    models.Mosaic,
    'network_type':
    models.NetworkType.MIJIN_TEST,
    'data': {
        'id': models.MosaicId(5),
        'amount': 1000,
    },
    'dto': {
        'id': [5, 0],
        'amount': [1000, 0],
    },
    'catbuffer':
    b'\x05\x00\x00\x00\x00\x00\x00\x00\xe8\x03\x00\x00\x00\x00\x00\x00',
})
class TestMosaic(harness.TestCase):
    pass


@harness.model_test_case({
    'type': models.MosaicId,
    'network_type': models.NetworkType.MIJIN_TEST,
    'data': {
        'id': 5,
    },
    'extras': {
 def test_valid(self, id: harness.U64, amount: harness.U64):
     network_type = models.NetworkType.MIJIN_TEST
     model = models.Mosaic(models.MosaicId(id), amount)
     dto = model.to_dto(network_type)
     self.assertEqual(model,
                      models.Mosaic.create_from_dto(dto, network_type))
 def test_invalid(self, id: int):
     network_type = models.NetworkType.MIJIN_TEST
     model = models.Mosaic(models.MosaicId(id), 1)
     with self.assertRaises(ArithmeticError):
         model.to_dto(network_type)

@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)

    def test_properties(self):