コード例 #1
0
ファイル: config.py プロジェクト: belovachap/pacli
def load_conf():
    '''load user configuration'''

    init_config()

    class Settings:
        pass

    settings = read_conf(conf_file)

    for key in settings:
        setattr(Settings, key, settings[key])

    setattr(Settings, 'deck_version', int(Settings.deck_version))
    setattr(Settings, 'key', Kutil(network=settings['network'],
                                   privkey=bytearray.fromhex(load_key())
                                   )
            )

    if settings['change'] == "default":
        Settings.change = Settings.key.address

    #logging.basicConfig(filename=logfile, level=logging.getLevelName(Settings.loglevel))
    #logging.basicConfig(level=logging.getLevelName(Settings.loglevel),
    #                    format="%(asctime)s %(levelname)s %(message)s")

    #logging.debug("logging initialized")

    return Settings
コード例 #2
0
    def test_testnet_p2th_address_generation(self):
        '''generating testnet deck p2th from deck spawn id'''

        key = Kutil(network="tppc", privkey=self.txid.encode())

        self.assertEqual(key.address, "mxjFTJApv7sjz9T9a4vCnAQbmsqSoL8VWo")
        self.assertEqual(
            key.wif, "cU6CjGw3mRmirjiUZfRkJ1aj2D493k7uuhywj6tCVbLAMABy4MwU")
コード例 #3
0
    def test_p2th_address_generation(self):
        '''generating deck p2th from deck spawn id'''

        key = Kutil(network="ppc", privkey=self.txid)

        self.assertEqual(key.address, "PRoUKDUhA1vgBseJCaGMd9AYXdQcyEjxu9")
        self.assertEqual(
            key.wif, "UBctiEkfxpU2HkyTbRKjiGHT5socJJwCny6ePfUtzo8Jad9wVzeA")
コード例 #4
0
def test_oversize_card_object():

    deck = Deck(
        name="decky",
        number_of_decimals=12,
        issue_mode=IssueMode.MULTI.value,
        network="ppc",
        production=True,
        version=1,
        asset_specific_data="Just testing.",
    )

    with pytest.raises(OverSizeOPReturn):

        card_transfer = CardTransfer(
            deck=deck,
            receiver=[Kutil(network='ppc').address for i in range(80)],
            amount=[random.randint(20, 12000) for i in range(80)],
            version=1,
        )

        assert card_transfer.metainfo_to_protobuf
コード例 #5
0
def load_conf():
    '''load user configuration'''

    init_config()

    class Settings:
        pass

    settings = read_conf(conf_file)

    for key in settings:
        setattr(Settings, key, settings[key])

    setattr(Settings, 'deck_version', int(Settings.deck_version))
    setattr(
        Settings, 'key',
        Kutil(network=settings['network'],
              privkey=bytearray.fromhex(load_key())))

    if settings['change'] == "default":
        Settings.change = Settings.key.address

    return Settings
コード例 #6
0
def few_random_cards(deck: Deck,
                     n: int,
                     card_type: str = 'random',
                     amount: int = None) -> list:
    '''returns <n> randomly generated cards'''

    types = ['CardIssue', 'CardBurn', 'CardTransfer']

    cards = [
        CardTransfer(
            deck=deck,
            receiver=[Kutil(network='tppc').address],
            amount=[random.randint(1, 100)],
        ) for i in range(n)
    ]

    if card_type == 'transfer':
        for i in cards:
            i.__setattr__('type', 'CardTransfer')

    if card_type == 'random':
        for i in cards:
            i.__setattr__('type', random.choice(types))

    if card_type == 'issue':
        for i in cards:
            i.__setattr__('type', 'CardIssue')

    if card_type == 'burn':
        for i in cards:
            i.__setattr__('type', 'CardBurn')

    if amount:  # if there is strict requirement for amount to be <int>
        for i in cards:
            i.amount = [amount]

    return cards