Example #1
0
    def _execute(self, request):
        depth = request['depth']  # type: int
        min_weight_magnitude = request['minWeightMagnitude']  # type: int
        trytes = request['trytes']  # type: List[TryteString]

        # Call ``getTransactionsToApprove`` to locate trunk and branch
        # transactions so that we can attach the bundle to the Tangle.
        gta_response = GetTransactionsToApproveCommand(self.adapter)(depth=depth)

        att_response = AttachToTangleCommand(self.adapter)(
            branchTransaction=gta_response.get('branchTransaction'),
            trunkTransaction=gta_response.get('trunkTransaction'),

            minWeightMagnitude=min_weight_magnitude,
            trytes=trytes,
        )

        # ``trytes`` now have POW!
        trytes = att_response['trytes']

        BroadcastAndStoreCommand(self.adapter)(trytes=trytes)

        return {
            'trytes': trytes,
        }
Example #2
0
  def setUp(self):
    self.adapter = MockAdapter()
    self.command = BroadcastAndStoreCommand(self.adapter)

    # Define a few valid values that we can reuse across tests.
    self.trytes1 = b'RBTC9D9DCDQAEASBYBCCKBFA'
    self.trytes2 =\
      b'CCPCBDVC9DTCEAKDXC9D9DEARCWCPCBDVCTCEAHDWCTCEAKDCDFD9DSCSA'