当前位置: 首页>>代码示例>>Python>>正文


Python ColorSet.__repr__方法代码示例

本文整理汇总了Python中coloredcoinlib.ColorSet.__repr__方法的典型用法代码示例。如果您正苦于以下问题:Python ColorSet.__repr__方法的具体用法?Python ColorSet.__repr__怎么用?Python ColorSet.__repr__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在coloredcoinlib.ColorSet的用法示例。


在下文中一共展示了ColorSet.__repr__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestAddress

# 需要导入模块: from coloredcoinlib import ColorSet [as 别名]
# 或者: from coloredcoinlib.ColorSet import __repr__ [as 别名]
class TestAddress(unittest.TestCase):

    def setUp(self):
        self.colormap = MockColorMap()
        d = self.colormap.d
        self.colorset0 = ColorSet(self.colormap, [d[0]])
        self.colorset1 = ColorSet(self.colormap, [d[1]])
        self.main_p = '5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF'
        self.main = LooseAddressRecord(address_data=self.main_p,
                                       color_set=self.colorset0,
                                       testnet=False)
        self.test_p = '91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgyUY4Gk1'
        self.test = LooseAddressRecord(address_data=self.test_p,
                                       color_set=self.colorset1,
                                       testnet=True)


    def test_init(self):
        self.assertEqual(self.main.get_address(),
                         '1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj')
        self.assertEqual(self.test.get_address(),
                         'mo3oihY41iwPco1GKwehHPHmxMT4Ld5W3q')
        self.assertRaises(EncodingError, LooseAddressRecord,
                          address_data=self.main_p[:-2] + '88')
        self.assertRaises(EncodingError, LooseAddressRecord,
                          address_data=self.test_p[:-2] + '88',
                          testnet=True)
        self.assertRaises(InvalidAddressError, LooseAddressRecord,
                          address_data=self.main_p, testnet=True)
        self.assertRaises(InvalidAddressError, LooseAddressRecord,
                          address_data=self.test_p, testnet=False)

    def test_get_color_set(self):
        self.assertEqual(self.main.get_color_set().__repr__(),
                         self.colorset0.__repr__())

    def test_get_color_address(self):
        self.assertEqual(self.main.get_color_address(),
                         '1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj')
        self.assertEqual(self.test.get_color_address(),
                         '[email protected]')

    def test_get_data(self):
        self.assertEqual(self.main.get_data()['color_set'],
                         self.colorset0.get_data())
        self.assertEqual(self.main.get_data()['address_data'],
                         self.main_p)
        self.assertEqual(self.test.get_data()['color_set'],
                         self.colorset1.get_data())
        self.assertEqual(self.test.get_data()['address_data'],
                         self.test_p)
开发者ID:amidvidy,项目名称:ngcccbase,代码行数:53,代码来源:test_address.py

示例2: TestDeterministic

# 需要导入模块: from coloredcoinlib import ColorSet [as 别名]
# 或者: from coloredcoinlib.ColorSet import __repr__ [as 别名]
class TestDeterministic(unittest.TestCase):

    def setUp(self):
        self.colormap = MockColorMap()
        d = self.colormap.d
        self.colorset0 = ColorSet(self.colormap, [''])
        self.colorset1 = ColorSet(self.colormap, [d[1]])
        self.colorset1alt = ColorSet(self.colormap, [d[1],d[6]])
        self.colorset2 = ColorSet(self.colormap, [d[2]])
        self.colorset3 = ColorSet(self.colormap, [d[3], d[4]])
        self.def1 = {'monikers': ['test1'],
                     'color_set': self.colorset1.get_data(),
                     'unit':10}
        self.asset1 = AssetDefinition(self.colormap, self.def1)
        self.master_key = '265a1a0ad05e82fa321e3f6f6767679df0c68515797e0e4e24be1afc3272ee658ec53cecb683ab76a8377273347161e123fddf5320cbbce8849b0a00557bd12c'
        self.privkey = '5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF'
        self.pubkey = '1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj'
        c = {
            'dw_master_key': self.master_key,
            'dwam': {
                'genesis_color_sets':[self.colorset1.get_data(),
                                      self.colorset2.get_data()],
                'color_set_states':[
                    {'color_set':self.colorset0.get_data(), "max_index":0},
                    {'color_set':self.colorset1.get_data(), "max_index":3},
                    {'color_set':self.colorset2.get_data(), "max_index":2},
                    ],
                },
            'addresses':[{'address_data': self.privkey,
                          'color_set': self.colorset1.get_data(),
                          }],
            'testnet': False,
            }
        self.config = copy.deepcopy(c)
        self.maindwam = DWalletAddressManager(self.colormap, c)

    def test_init_new_wallet(self):
        c = copy.deepcopy(self.config)
        del c['dw_master_key']
        del c['dwam']
        newdwam = DWalletAddressManager(self.colormap, c)
        params = newdwam.init_new_wallet()
        self.assertNotEqual(self.config['dw_master_key'],
                            newdwam.config['dw_master_key'])

        c = copy.deepcopy(self.config)
        c['addresses'][0]['address_data'] = 'notreal'
        self.assertRaises(EncodingError, DWalletAddressManager,
                          self.colormap, c)

    def test_get_new_address(self):
        self.assertEqual(self.maindwam.get_new_address(self.colorset2).index,
                         3)
        self.assertEqual(self.maindwam.get_new_address(self.asset1).index,
                         4)

    def test_get_new_genesis_address(self):
        addr = self.maindwam.get_new_genesis_address()
        self.assertEqual(addr.index, 2)
        addr2 = self.maindwam.get_new_address(addr.get_color_set())
        self.assertEqual(addr2.index, 0)

    def test_get_update_genesis_address(self):
        addr = self.maindwam.get_genesis_address(0)
        self.maindwam.update_genesis_address(addr, self.colorset1alt)
        self.assertEqual(addr.get_color_set(), self.colorset1alt)

    def test_get_change_address(self):
        addr = self.maindwam.get_change_address(self.colorset0)
        self.assertEqual(addr.get_color_set().__repr__(),
                         self.colorset0.__repr__())
        self.assertEqual(self.maindwam.get_change_address(self.colorset3).index,
                         0)

    def test_get_all_addresses(self):
        addrs = [a.get_address() for a in self.maindwam.get_all_addresses()]
        self.assertTrue(self.pubkey in addrs)
开发者ID:Andymeows,项目名称:ngcccbase,代码行数:79,代码来源:test_deterministic.py

示例3: TestColorSet

# 需要导入模块: from coloredcoinlib import ColorSet [as 别名]
# 或者: from coloredcoinlib.ColorSet import __repr__ [as 别名]
class TestColorSet(unittest.TestCase):
    def setUp(self):
        self.colormap = MockColorMap()
        d = self.colormap.d
        self.colorset0 = ColorSet(self.colormap, [""])
        self.colorset1 = ColorSet(self.colormap, [d[1]])
        self.colorset2 = ColorSet(self.colormap, [d[2]])
        self.colorset3 = ColorSet(self.colormap, [d[1], d[2]])
        self.colorset4 = ColorSet(self.colormap, [d[3], d[2]])
        self.colorset5 = ColorSet(self.colormap, [d[3], d[1]])
        self.colorset6 = ColorSet(self.colormap, [])

    def test_repr(self):
        self.assertEquals(self.colorset0.__repr__(), "['']")
        self.assertEquals(self.colorset1.__repr__(), "['obc:color_desc_1:0:0']")
        self.assertEquals(self.colorset3.__repr__(), "['obc:color_desc_1:0:0', 'obc:color_desc_2:0:1']")

    def test_uncolored_only(self):
        self.assertTrue(self.colorset0.uncolored_only())
        self.assertFalse(self.colorset1.uncolored_only())
        self.assertFalse(self.colorset3.uncolored_only())

    def test_get_data(self):
        self.assertEquals(self.colorset0.get_data(), [""])
        self.assertEquals(self.colorset1.get_data(), ["obc:color_desc_1:0:0"])

    def test_get_hash_string(self):
        self.assertEquals(
            self.colorset0.get_hash_string(), "055539df4a0b804c58caf46c0cd2941af10d64c1395ddd8e50b5f55d945841e6"
        )
        self.assertEquals(
            self.colorset1.get_hash_string(), "ca90284eaa79e05d5971947382214044fe64f1bdc2e97040cfa9f90da3964a14"
        )
        self.assertEquals(
            self.colorset3.get_hash_string(), "09f731f25cf5bfaad512d4ee6f37cb9481f442df3263b15725dd1624b4678557"
        )

    def test_get_earliest(self):
        self.assertEquals(self.colorset5.get_earliest(), "obc:color_desc_1:0:0")
        self.assertEquals(self.colorset4.get_earliest(), "obc:color_desc_2:0:1")
        self.assertEquals(self.colorset6.get_earliest(), "\x00\x00\x00\x00")

    def test_get_color_string(self):
        self.assertEquals(self.colorset1.get_color_hash(), "CP4YWLr8aAe4Hn")
        self.assertEquals(self.colorset3.get_color_hash(), "ZUTSoEEwZY6PB")

    def test_has_color_id(self):
        self.assertTrue(self.colorset0.has_color_id(0))
        self.assertTrue(self.colorset3.has_color_id(1))
        self.assertFalse(self.colorset1.has_color_id(0))
        self.assertFalse(self.colorset4.has_color_id(1))

    def test_intersects(self):
        self.assertFalse(self.colorset0.intersects(self.colorset1))
        self.assertTrue(self.colorset1.intersects(self.colorset3))
        self.assertTrue(self.colorset3.intersects(self.colorset1))
        self.assertTrue(self.colorset4.intersects(self.colorset3))
        self.assertFalse(self.colorset2.intersects(self.colorset0))
        self.assertFalse(self.colorset1.intersects(self.colorset4))

    def test_equals(self):
        self.assertFalse(self.colorset1.equals(self.colorset0))
        self.assertTrue(self.colorset3.equals(self.colorset3))
        self.assertFalse(self.colorset4.equals(self.colorset5))

    def test_from_color_ids(self):
        self.assertTrue(self.colorset0.equals(ColorSet.from_color_ids(self.colormap, [0])))
        self.assertTrue(self.colorset3.equals(ColorSet.from_color_ids(self.colormap, [1, 2])))
        tmp = ColorSet.from_color_ids(self.colormap, [1, 2, 3])
        self.assertTrue(tmp.has_color_id(1))
        self.assertTrue(tmp.has_color_id(2))
        self.assertTrue(tmp.has_color_id(3))
开发者ID:shadowxxx,项目名称:ngcccbase,代码行数:74,代码来源:test_colorset.py


注:本文中的coloredcoinlib.ColorSet.__repr__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。