示例#1
0
 def setUp(self):
     ColorDefinition.register_color_def_class(TestColorDefinition)
     self.txhash = 'color_desc_1'
     self.cd = TestColorDefinition(1, {
         'txhash': self.txhash,
         'outindex': 0,
         'height': 0
     })
     self.tx = MockTX(self.txhash, [], [])
示例#2
0
    def issue_coins(self, moniker, pck, units, atoms_in_unit):
        """Issues a new color of name <moniker> using coloring scheme
        <pck> with <units> per share and <atoms_in_unit> total.
        """

        color_definition_cls = ColorDefinition.get_color_def_cls_for_code(pck)
        if not color_definition_cls:
            raise Exception("color scheme %s not recognized" % pck)

        total = units * atoms_in_unit
        op_tx_spec = SimpleOperationalTxSpec(self.model, None)
        wam = self.model.get_address_manager()
        address = wam.get_new_genesis_address()
        op_tx_spec.add_target(address.get_address(), GENESIS_OUTPUT_MARKER, total)
        genesis_ctxs = color_definition_cls.compose_genesis_tx_spec(op_tx_spec)
        genesis_tx = self.model.transform_tx_spec(genesis_ctxs, "signed")
        height = self.model.ccc.blockchain_state.bitcoind.getblockcount() - 1
        genesis_tx_hash = self.publish_tx(genesis_tx)
        color_desc = ":".join([pck, genesis_tx_hash, "0", str(height)])
        adm = self.model.get_asset_definition_manager()
        asset = adm.add_asset_definition({"monikers": [moniker], "color_set": [color_desc], "unit": atoms_in_unit})
        wam.update_genesis_address(address, asset.get_color_set())

        # scan the tx so that the rest of the system knows
        self.model.ccc.colordata.cdbuilder_manager.scan_txhash(asset.color_set.color_id_set, genesis_tx_hash)
示例#3
0
    def issue_coins(self, moniker, pck, units, atoms_in_unit):
        """Issues a new color of name <moniker> using coloring scheme
        <pck> with <units> per share and <atoms_in_unit> total.
        """

        color_definition_cls = ColorDefinition.get_color_def_cls_for_code(pck)
        if not color_definition_cls:
            raise Exception('color scheme %s not recognized' % pck)

        total = units * atoms_in_unit
        op_tx_spec = SimpleOperationalTxSpec(self.model, None)
        wam = self.model.get_address_manager()
        address = wam.get_new_genesis_address()
        op_tx_spec.add_target(
            address.get_address(), GENESIS_OUTPUT_MARKER, total)
        genesis_ctxs = color_definition_cls.compose_genesis_tx_spec(op_tx_spec)
        genesis_tx = self.model.transform_tx_spec(genesis_ctxs, 'signed')
        height = self.model.ccc.blockchain_state.bitcoind.getblockcount() \
            - 1
        genesis_tx_hash = self.publish_tx(genesis_tx)
        color_desc = ':'.join([pck, genesis_tx_hash, '0', str(height)])
        adm = self.model.get_asset_definition_manager()
        asset = adm.add_asset_definition({"monikers": [moniker],
                                          "color_set": [color_desc],
                                          "unit": atoms_in_unit})
        wam.update_genesis_address(address, asset.get_color_set())

        # scan the tx so that the rest of the system knows
        self.model.ccc.colordata.cdbuilder_manager.scan_txhash(
            asset.color_set.color_id_set, genesis_tx_hash)
示例#4
0
 def test_repr(self):
     a = ColorDefinition(1)
     self.assertEqual(a.__repr__(), "Color Definition with 1")
     self.assertEqual(self.cd.__repr__(), "test:color_desc_1:0:0")
示例#5
0
 def test_from_color_desc(self):
     cd = ColorDefinition.from_color_desc(1, "test:%s:0:0" % self.txhash)
     self.assertTrue(isinstance(cd, TestColorDefinition))
示例#6
0
 def setUp(self):
     ColorDefinition.register_color_def_class(TestColorDefinition)
     self.txhash = 'color_desc_1'
     self.cd = TestColorDefinition(1, {'txhash': self.txhash,
                                       'outindex': 0, 'height':0})
     self.tx = MockTX(self.txhash, [], [])
示例#7
0
 def test_repr(self):
     a = ColorDefinition(1)
     self.assertEqual(a.__repr__(), "Color Definition with 1")
     self.assertEqual(self.cd.__repr__(), "test:color_desc_1:0:0")
示例#8
0
 def test_from_color_desc(self):
     cd = ColorDefinition.from_color_desc(1, "test:%s:0:0" % self.txhash)
     self.assertTrue(isinstance(cd, TestColorDefinition))