示例#1
0
 def test_class_variables(self):
     self.assertEqual(self.type.NAMESPACE_ID,
                      models.NamespaceId(0x941299B2B7E1291C))
     self.assertEqual(self.type.DIVISIBILITY, 3)
     self.assertEqual(self.type.INITIAL_SUPPLY, 15000000)
     self.assertEqual(self.type.TRANSFERABLE, True)
     self.assertEqual(self.type.SUPPLY_MUTABLE, True)
     self.assertEqual(self.type.LEVY_MUTABLE, False)
示例#2
0
 def test_class_variables(self):
     self.assertEqual(self.type.NAMESPACE_ID,
                      models.NamespaceId(0x85BBEA6CC462B244))
     self.assertEqual(self.type.DIVISIBILITY, 6)
     self.assertEqual(self.type.INITIAL_SUPPLY, 8999999998)
     self.assertEqual(self.type.TRANSFERABLE, True)
     self.assertEqual(self.type.SUPPLY_MUTABLE, False)
     self.assertEqual(self.type.LEVY_MUTABLE, False)
示例#3
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_properties(self):
        self.assertEqual(self.model.id, models.NamespaceId(0x84b3552d375ffa4b))
        self.assertTrue(self.model.is_root())
        self.assertFalse(self.model.is_subnamespace())
        self.assertFalse(self.model.has_alias())

        with self.assertRaises(ValueError):
            self.model.parent_namespace_id()

        sub_namespace = self.model.replace(
            type=models.NamespaceType.SUB_NAMESPACE,
            parent_id=self.extras['parent'],
            levels=[self.extras['child']],
        )
        self.assertEqual(sub_namespace.parent_namespace_id(),
                         self.extras['parent'])
        name = mosaic_names[0].names[0]


# Get network type
with client.NodeHTTP(endpoint) as http:
    node_info = http.get_node_info()
    network_type = node_info.network_identifier

# Get generation hash of this blockchain
with client.BlockchainHTTP(endpoint) as http:
    block_info = http.get_block_by_height(1)

# Get the XPX mosaic by its namespace alias. Mosaics don't have names, you can only asign an alias to them.
# Namespace will give us the mosaic id.
with client.NamespaceHTTP(endpoint) as http:
    namespace_info = http.get_namespace(models.NamespaceId('prx.xpx'))

# Get mosaic info by its id.
with client.MosaicHTTP(endpoint) as http:
    xpx = http.get_mosaic(namespace_info.alias.value)

alice = models.Account.create_from_private_key(
    "6b2a97945d0f318114215ee80c012a5ea2ad39a3cd472a9ff2caf7488c4c2ede",
    network_type)

# Ask for test XPX from the faucet
try:
    print(f"Requesting test XPX for {alice.address.address}")
    reply = requests.get(
        f"https://bctestnetfaucet.xpxsirius.io/api/faucet/GetXpx/{alice.address.address}"
    ).json()
          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),
         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_namespace_metadata',
     'response':
     responses.NAMESPACE_METADATA["Ok"],
     'params':
     [models.NamespaceId(util.u64_from_dto([130473079, 2260557970]))],
     'method':
     'get_namespace_metadata',
     'validation': [
         lambda x: (isinstance(x, models.NamespaceMetadataInfo), True),
         lambda x:
         (isinstance(x.metadata, models.NamespaceMetadata), True),
         lambda x:
         (x.metadata.metadata_type, models.MetadataType.NAMESPACE),
         lambda x:
         (isinstance(x.metadata.metadata_id, models.NamespaceId), True),
         lambda x: (x.metadata.metadata_id,
                    models.NamespaceId(
                        util.u64_from_dto([130473079, 2260557970]))),
         lambda x: (len(x.metadata.flds), 2),
         lambda x: (isinstance(x.metadata.flds[0], models.Field), True),
 {
     'name':
     'test_get_namespace',
     'response':
     responses.NAMESPACE['nem'],
     'params': [models.NamespaceId.create_from_hex('84b3552d375ffa4b')],
     'method':
     'get_namespace',
     'validation': [
         lambda x: (x.active, True),
         lambda x: (x.index, 0),
         lambda x: (x.meta_id, '5C7C07005CC1FE000176FA2B'),
         lambda x: (x.type, models.NamespaceType.ROOT_NAMESPACE),
         lambda x: (x.depth, 1),
         lambda x: (x.levels[0].encoded, '4bfa5f372d55b384'),
         lambda x: (x.parent_id, models.NamespaceId(0)),
         lambda x: (x.owner.address.address,
                    'SD3MA6SM7GWRX4DEJVAZEGFXF7G7D36MA6TMSIBM'),
         lambda x:
         (x.owner.public_key,
          '7A562888C7AE1E082579951D6D93BF931DE979360ACCA4C4085D754E5E122808'
          ),
         lambda x: (x.start_height, 1),
         lambda x: (x.end_height, 18446744073709551615),
         lambda x: (x.alias, models.EmptyAlias()),
     ]
 },
 {
     'name':
     'test_get_namespaces_name',
     'response':
 def create(name):
     # Create_from_name will detect the name is invalid, just do this.
     return self.type(models.NamespaceId(0), name)
@harness.model_test_case({
    'type': models.NamespaceInfo,
    'network_type': models.NetworkType.MIJIN_TEST,
    'data': {
        'active':
        True,
        'index':
        0,
        'meta_id':
        '5c7c07005cc1fe000176fa2b',
        'type':
        models.NamespaceType.ROOT_NAMESPACE,
        'depth':
        1,
        'levels': [
            models.NamespaceId(0x84b3552d375ffa4b),
        ],
        'parent_id':
        models.NamespaceId(0),
        'owner':
        models.PublicAccount.create_from_public_key(
            '7a562888c7ae1e082579951d6d93bf931de979360acca4c4085d754e5e122808',
            models.NetworkType.MIJIN_TEST),
        'start_height':
        1,
        'end_height':
        0xffffffffffffffff,
        'alias':
        models.Alias(),
    },
    'dto': {