コード例 #1
0
    def create_std_tx(cls, sender: tuple, receiver: tuple,
                      amount: int) -> StandardTransaction:
        if type(receiver) is tuple:
            receiver = receiver[1]

        return StandardTransactionBuilder.create_tx(sender[0], sender[1],
                                                    receiver, amount)
コード例 #2
0
ファイル: test_composer.py プロジェクト: JeffWScott/cilantro
def publisher():
    SLEEP_TIME = 1
    MAX_TIME = 10
    from cilantro.logger import get_logger, overwrite_logger_level
    from cilantro.utils.test import MPComposer
    from cilantro.messages.transaction.standard import StandardTransactionBuilder
    import time, os

    log = get_logger("Publisher")
    sub_info = delegates[1]
    sub_info['ip'] = os.getenv('HOST_IP')

    d_info = delegates[0]
    d_info['ip'] = os.getenv('HOST_IP')

    pub = MPComposer(sk=d_info['sk'])

    # Publish on this node's own IP
    pub.add_pub(os.getenv('HOST_IP'))

    log.critical(
        "Starting experiment, sending messages every {} seconds for a total of {} seconds"
        .format(SLEEP_TIME, MAX_TIME))
    elapsed_time = 0

    while elapsed_time < MAX_TIME:
        log.info("Sending pub")
        msg = StandardTransactionBuilder.random_tx()
        pub.send_pub_msg(filter='0', message=msg)

        time.sleep(SLEEP_TIME)
        elapsed_time += SLEEP_TIME

    pub.teardown()
    log.critical("Done with experiment!")
コード例 #3
0
ファイル: test_composers.py プロジェクト: JeffWScott/cilantro
def publisher():
    from cilantro.logger import get_logger
    from cilantro.utils.test import MPComposer
    from cilantro.messages.transaction.standard import StandardTransactionBuilder
    import time, os, sys

    log = get_logger("Publisher")
    sub_info = delegates[1]
    sub_info['ip'] = os.getenv('HOST_IP')

    d_info = delegates[0]
    d_info['ip'] = os.getenv('HOST_IP')

    pub = MPComposer(sk=d_info['sk'])

    # Publish on this node's own IP
    pub.add_pub(os.getenv('HOST_IP'))

    for i in range(100):
        log.critical("Sending pub")
        msg = StandardTransactionBuilder.random_tx()
        time.sleep(0.1)
        pub.send_pub_msg(filter='0', message=msg)

    log.critical("Pub Done")
    sys.exit(0)
    exit
コード例 #4
0
def random_envelope():
    sk, vk = wallet.new()
    tx = StandardTransactionBuilder.random_tx()
    sender = 'me'
    return Envelope.create_from_message(message=tx,
                                        signing_key=sk,
                                        sender_id=sender)
コード例 #5
0
    def test_builder_serializiation(self):
        """
        Tests serialization/deserialization using the StandardTransactionBuilder object
        """
        tx = StandardTransactionBuilder.random_tx()
        clone = StandardTransaction.from_bytes(tx.serialize())

        self.assertTrue(True)
コード例 #6
0
 def create_tx_struct(amount):
     """
     Helper method to create and return a valid transaction struct with a random sender/receiever and
     the specified amount
     """
     s = Constants.Protocol.Wallets.new()
     r = Constants.Protocol.Wallets.new()
     return StandardTransactionBuilder.create_tx_struct(
         s[0], s[1], r[1], amount)
コード例 #7
0
    def test_builder_reserialization(self):
        """
        Tests that a transaction object can be loaded from binary created using StandardTransactionBuilder, and then
        properly serialized again
        """
        tx = StandardTransactionBuilder.random_tx()
        clone = StandardTransaction.from_bytes(tx.serialize())
        clone.serialize()

        self.assertTrue(True)
コード例 #8
0
    def _convenience_build_standard_transaction(self):
        """These transactions get POSTed directly to masternodes by TAU wallet software"""
        STU = (wallet.new())
        DAVIS = (wallet.new())
        DENTON = (wallet.new())
        FALCON = (wallet.new())
        KNOWN_ADRS = (STU, DAVIS, DENTON, FALCON)
        amount = 10

        tx = StandardTransactionBuilder.create_tx(STU[0], STU[1], DAVIS[1], amount)
        return tx
コード例 #9
0
    def test_create_with_envelope(self):
        """
        Tests creating a message with an envelope produces an object with the expected properties
        """
        sk, vk = wallet.new()
        tx = StandardTransactionBuilder.random_tx()
        sender = 'me'
        env = Envelope.create_from_message(message=tx, signing_key=sk)

        cmd = ReactorCommand.create_cmd('some_cls', 'some_func', envelope=env)

        self.assertTrue(ReactorCommand.envelope, env)
コード例 #10
0
def random_msg():
    return StandardTransactionBuilder.random_tx()
コード例 #11
0
ファイル: test_envelope.py プロジェクト: sanko61/cilantro
 def _default_msg(self):
     # TODO -- write default TestMessage class
     # We should really have a default TestMessage object that is a bare-minimum subclass of MessageBase
     # instead of using other live objects for these kinds of tests
     message = StandardTransactionBuilder.random_tx()
     return message