示例#1
0
def _test():
    from crypt import signed
    from lib import packetid

    lg.set_debug_level(24)
    A("init")
    A().offline_mode = True
    A("start")
    coins = []
    for _ in xrange(5):
        coin = coins_io.storage_contract_open("http://some.id-host.org/alice_customer.xml", 3600, 4096)
        if coins_io.verify_coin_signature(coin):
            coins.append(coin)
        else:
            print coin
            sys.exit()
    outpacket = signed.Packet(
        commands.Coin(),
        my_id.getLocalID(),
        my_id.getLocalID(),
        packetid.UniqueID(),
        json.dumps(coins),
        "http://server.com/id.xml",
    )
    reactor.callLater(0.1, callback.run_inbox_callbacks, outpacket, None, "finished", "")
    # reactor.callLater(5.1, A, 'shutdown')
    reactor.run()
示例#2
0
def _test_coin_worker(customer_idurl,
                      duration,
                      amount,
                      price=1.0,
                      trustee=None):
    global _prev_hash
    from coins import coins_miner
    storage_coin = coins_io.storage_contract_open(customer_idurl, duration,
                                                  amount, price, trustee)
    storage_coin['miner']['prev'] = _prev_hash
    d = coins_miner.start_offline_job(storage_coin)
    d.addBoth(_test_coin_mined, customer_idurl, duration, amount, price,
              trustee)
 def doRequestCustomerSignature(self, *args, **kwargs):
     """
     Action method.
     """
     bytes_allocated = accounting.get_customer_quota(self.customer_idurl)
     assert bytes_allocated is not None
     assert bytes_allocated > 0
     coin_json = coins_io.storage_contract_open(
         self.customer_idurl,
         self.current_duration,
         bytes_allocated,
     )
     coin_json_sined = coins_io.add_signature(coin_json, 'creator')
     p2p_service.SendCoin(self.customer_idurl, [
         coin_json_sined,
     ],
                          callbacks={
                              commands.Ack(): self._on_signature_ack,
                              commands.Fail(): self._on_signature_fail,
                          })
示例#4
0
def _test():
    lg.set_debug_level(20)
    acoin = coins_io.storage_contract_open('http://abc.com/id.xml', 3600, 100)
    start_offline_job(acoin).addBoth(lambda *a, **kw: reactor.stop())
    reactor.run()