def submitblock(blob): stub = get_mining_stub() request = qrlmining_pb2.SubmitMinedBlockReq(blob=bytes(hstr2bin(blob))) response = stub.SubmitMinedBlock(request=request, timeout=10) if response.error: raise Exception # Mining pool expected exception when block submission fails return MessageToJson(response, sort_keys=True)
def submitblock(blob): stub = get_mining_stub() request = qrlmining_pb2.SubmitMinedBlockReq(blob=bytes(hstr2bin(blob))) response = stub.SubmitMinedBlock(request=request, timeout=10) if response.error: raise Exception # Mining pool expected exception when block submission fails return {'status': 'OK', 'error': 0}
def test_SubmitMinedBlock(self): req = qrlmining_pb2.SubmitMinedBlockReq(blob=b'minedblob') # Submit mined block encountered an error self.qrlnode.submit_mined_block = MagicMock(return_value=False) answer = self.service.SubmitMinedBlock(req, context=None) self.assertTrue(answer.error) # This time it was successful self.qrlnode.submit_mined_block = MagicMock(return_value=True) answer = self.service.SubmitMinedBlock(req, context=None) self.assertFalse(answer.error)
def submitblock(blob): stub = get_mining_stub() request = qrlmining_pb2.SubmitMinedBlockReq(blob=bytes(hstr2bin(blob))) response = stub.SubmitMinedBlock(request=request, timeout=10) return MessageToJson(response)