def start_protocol(self): coin = Coin(self.network) crypto = Crypto() self.messages.clear_packets() begin_phase = Phase('Announcement') # Make Round self.protocol = Round_wrong_outputs( coin, crypto, self.messages, self.outcome, self.income, self.logger, self.session, begin_phase, self.amount , self.fee, self.sk, self.vk, self.players, self.addr_new, self.change) self.executionThread = threading.Thread(target = self.protocol.protocol_loop) self.executionThread.start() self.done.wait() self.executionThread.join()
def __init__(self, *args, **kwargs): super(TestCoin, self).__init__(*args, **kwargs) self.network = testNetwork() self.ec_keys = [random_sk() for _ in range(10)] self.public_keys = [make_fake_public_key(secret_key=sk) for sk in self.ec_keys] self.addresses = [address_from_public_key(public_key) for public_key in self.public_keys] for address in self.addresses: for value in [10000, 1000, 500, 100]: self.network.add_coin(address, value, tx_hash = fake_hash(address, value)) self.coin = Coin(self.network)
def test_002_insufficient_funds(self): from electroncash_plugins.shuffle.coin import Coin coin = Coin(self.network) protocolThreads = self.make_clients_threads(with_print = True) coins_1 = coin.get_coins(protocolThreads[0].inputs) for pubkey in coins_1: bad_addr = public_key_to_p2pkh(bytes.fromhex(pubkey)) for coin in coins_1[pubkey]: coin['value'] = 0 self.network.coins[bad_addr] = coins_1[pubkey] self.start_protocols(protocolThreads) done = False while not done: completes = [self.is_protocol_complete(p) for p in protocolThreads[1:]] done = all(completes) self.stop_protocols(protocolThreads) tx = protocolThreads[1].protocol.tx.raw for pThread in protocolThreads[2:]: self.assertEqual(tx, pThread.protocol.tx.raw) print(protocolThreads[-1].protocol.tx.raw) print(protocolThreads[-1].protocol.change_addresses)
password = args.password wallet_path = args.wallet storage = WalletStorage(wallet_path) if not storage.file_exists(): basic_logger.send("Error: Wallet file not found.") sys.exit(0) if storage.is_encrypted(): storage.decrypt(password) if args.testnet: NetworkConstants.set_testnet() config = SimpleConfig({'server': "bch0.kister.net:51002:s"}) network = Network(config) network.start() wallet = Wallet(storage) wallet.start_threads(network) coin = Coin(network) # # setup server port = args.port host = args.server stat_port = args.stat_port ssl = args.ssl fee = args.fee secured = ("s" if ssl else "") stat_endpoint = "http{}://{}:{}/stats".format(secured, host, stat_port) schedule.every(args.period).minutes.do(job) while True: schedule.run_pending() sleep(10) ## Delete later