コード例 #1
0
 def test_valid_int(self, nonce: harness.U32):
     network_type = models.NetworkType.MIJIN_TEST
     model = models.MosaicNonce(nonce)
     dto = model.to_dto(network_type)
     self.assertEqual(model,
                      models.MosaicNonce.create_from_dto(dto, network_type))
     catbuffer = model.to_catbuffer(network_type)
     self.assertEqual(
         model,
         models.MosaicNonce.create_from_catbuffer(catbuffer, network_type))
コード例 #2
0
async def create_mosaic(account, nonce):
    nonce = models.MosaicNonce(nonce)
    mosaic_id = models.MosaicId.create_from_nonce(nonce, account)

    tx = models.MosaicDefinitionTransaction.create(
        deadline=models.Deadline.create(),
        network_type=config.network_type,
        nonce=nonce,
        mosaic_id=mosaic_id,
        mosaic_properties=models.MosaicProperties(0x3, 3),
    )

    signed_tx = tx.sign_with(account, config.gen_hash)

    tx = await announce(signed_tx)

    return mosaic_id
コード例 #3
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': {
        'nonce':
        models.MosaicNonce(b'\x00\x00\x00\x00'),
        'public_key':
        '7D08373CFFE4154E129E04F0827E5F3D6907587E348757B0F87D2F839BF88246',
    },
})
class TestMosaicId(harness.TestCase):
    def test_int(self):
        self.assertEqual(int(self.model), 5)

    def test_index(self):
        self.assertEqual(hex(self.model), "0x5")

    def test_format(self):
        value = self.type(13)
        self.assertEqual(f'{value:x}', 'd')
        self.assertEqual(f'{value:X}', 'D')
コード例 #4
0
 def test_invalid_str(self, nonce: str):
     with self.assertRaises((ValueError, binascii.Error)):
         models.MosaicNonce(nonce)
コード例 #5
0
 def test_invalid_bytes(self, nonce: bytes):
     with self.assertRaises(ValueError):
         models.MosaicNonce(nonce)
コード例 #6
0
 def test_invalid_int(self, nonce: int):
     with self.assertRaises(OverflowError):
         models.MosaicNonce(nonce)