Exemple #1
0
 def _get_or_create_composer(self, signing_key):
     if signing_key in self.composers:
         self.log.debug("Existing Composer object found for signing key {}".format(signing_key))
         return self.composers[signing_key]
     else:
         self.log.debug("Creating new Composer object for signing key {}".format(signing_key))
         c = Composer(interface=self.interface, signing_key=signing_key, name='God-Composer-{}'.format(signing_key[:4]))
         self.composers[signing_key] = c
         return c
Exemple #2
0
 def __init__(self, *args, **kwargs):
     self.log = get_logger("BaseNode")
     self.log.info("-- BaseNode Initiating --")
     self.port = int(os.getenv('PORT', 31337))
     self.host = os.getenv('HOST_IP', '127.0.0.1')
     self.loop = asyncio.get_event_loop()
     self.wallet = ED25519Wallet()
     self.router = Router(statemachine=self)
     self.reactor = ReactorInterface(self.router, self.loop, self.wallet.s)
     self.composer = Composer(self.reactor, self.wallet.s)
Exemple #3
0
    def _build_node(loop, signing_key, ip, node_cls, name) -> NodeBase:

        node = node_cls(signing_key=signing_key, ip=ip, loop=loop, name=name)
        router = Router(statemachine=node, name=name)
        interface = ReactorInterface(router=router, loop=loop, signing_key=signing_key, name=name)
        composer = Composer(interface=interface, signing_key=signing_key, name=name)

        node.composer = composer

        return node
Exemple #4
0
    def build_obj(cls, sk, name='') -> tuple:
        loop = asyncio.get_event_loop()
        asyncio.set_event_loop(loop)

        mock_sm = MagicMock(spec=StateMachine)
        mock_sm.__name__ = name
        router = MagicMock()

        reactor = ReactorInterface(router=router, loop=loop, signing_key=sk)
        composer = Composer(interface=reactor, signing_key=sk)

        return composer, loop, [reactor._recv_messages()]
Exemple #5
0
    def test_init(self):
        """
        Tests init creates an object with the expected properties
        """
        sk, vk = W.new()
        interface = MagicMock(spec=ReactorInterface)
        sender_id = 'yuh_boi'

        comp = Composer(interface=interface, signing_key=sk)

        self.assertEqual(comp.interface, interface)
        # self.assertEqual(comp.sender_id, sender_id)
        self.assertEqual(comp.signing_key, sk)
        self.assertEqual(comp.verifying_key, vk)
Exemple #6
0
 def _get_or_create_composer(self, signing_key):
     # TODO fix this ... this is horribly old and likely broken untested code
     if signing_key in self.composers:
         self.log.debug(
             "Existing Composer object found for signing key {}".format(
                 signing_key))
         return self.composers[signing_key]
     else:
         self.log.debug(
             "Creating new Composer object for signing key {}".format(
                 signing_key))
         c = Composer(manager=self.interface,
                      signing_key=signing_key,
                      name='God-Composer-{}'.format(signing_key[:4]))
         self.composers[signing_key] = c
         return c
Exemple #7
0
    def _build_node(loop, signing_key, ip, node_cls, name) -> NodeBase:

        node = node_cls(signing_key=signing_key, ip=ip, loop=loop, name=name)
        router = Router(get_handler_func=lambda: node.state, name=name)
        manager = ExecutorManager(signing_key=signing_key,
                                  router=router,
                                  name=node_cls.__name__,
                                  loop=loop)
        composer = Composer(manager=manager,
                            signing_key=signing_key,
                            ip=ip,
                            name=name)

        node.composer = composer
        router.composer = composer

        return node