Revert "WIP: feature/1098/sorted-claim-results"
This commit is contained in:
parent
e220a57f0e
commit
25c36346b6
4 changed files with 1 additions and 56 deletions
|
@ -52,7 +52,6 @@ at anytime.
|
||||||
* download blockchain headers from s3 before starting the wallet when the local height is more than `s3_headers_depth` (a config setting) blocks behind
|
* download blockchain headers from s3 before starting the wallet when the local height is more than `s3_headers_depth` (a config setting) blocks behind
|
||||||
* track successful reflector uploads in sqlite to minimize how many streams are attempted by auto re-reflect
|
* track successful reflector uploads in sqlite to minimize how many streams are attempted by auto re-reflect
|
||||||
* increase the default `auto_re_reflect_interval` to a day
|
* increase the default `auto_re_reflect_interval` to a day
|
||||||
* `claim_list` and `claim_list_mine` in Daemon `return` sorted results
|
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
* virtual kademlia network and mock udp transport for dht integration tests
|
* virtual kademlia network and mock udp transport for dht integration tests
|
||||||
|
|
|
@ -163,12 +163,6 @@ class AlwaysSend(object):
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
def sort_claim_results(claims):
|
|
||||||
for claim in claims:
|
|
||||||
claim['result'].sort(key=lambda d: (d['height'], d['name'], d['claim_id'], d['txid'], d['nout']))
|
|
||||||
return claims
|
|
||||||
|
|
||||||
|
|
||||||
class Daemon(AuthJSONRPCServer):
|
class Daemon(AuthJSONRPCServer):
|
||||||
"""
|
"""
|
||||||
LBRYnet daemon, a jsonrpc interface to lbry functions
|
LBRYnet daemon, a jsonrpc interface to lbry functions
|
||||||
|
@ -2299,7 +2293,6 @@ class Daemon(AuthJSONRPCServer):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
d = self.session.wallet.get_name_claims()
|
d = self.session.wallet.get_name_claims()
|
||||||
d.addCallback(sort_claim_results)
|
|
||||||
d.addCallback(lambda claims: self._render_response(claims))
|
d.addCallback(lambda claims: self._render_response(claims))
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
@ -2338,8 +2331,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
claims = yield self.session.wallet.get_claims_for_name(name)
|
claims = yield self.session.wallet.get_claims_for_name(name)
|
||||||
result = sort_claim_results(claims)
|
defer.returnValue(claims)
|
||||||
defer.returnValue(result)
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def jsonrpc_claim_list_by_channel(self, page=0, page_size=10, uri=None, uris=[]):
|
def jsonrpc_claim_list_by_channel(self, page=0, page_size=10, uri=None, uris=[]):
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
import unittest
|
|
||||||
|
|
||||||
from lbrynet.daemon.Daemon import sort_claim_results
|
|
||||||
|
|
||||||
|
|
||||||
class ClaimsComparatorTest(unittest.TestCase):
|
|
||||||
def test_sort_claim_results_when_sorted_by_claim_id(self):
|
|
||||||
results = [{"height": 1, "name": "res", "claim_id": "ccc", "nout": 0, "txid": "fdsafa"},
|
|
||||||
{"height": 1, "name": "res", "claim_id": "aaa", "nout": 0, "txid": "w5tv8uorgt"},
|
|
||||||
{"height": 1, "name": "res", "claim_id": "bbb", "nout": 0, "txid": "aecfaewcfa"}]
|
|
||||||
self.run_test(results, 'claim_id', ['aaa', 'bbb', 'ccc'])
|
|
||||||
|
|
||||||
def test_sort_claim_results_when_sorted_by_height(self):
|
|
||||||
results = [{"height": 1, "name": "res", "claim_id": "ccc", "nout": 0, "txid": "aecfaewcfa"},
|
|
||||||
{"height": 3, "name": "res", "claim_id": "ccc", "nout": 0, "txid": "aecfaewcfa"},
|
|
||||||
{"height": 2, "name": "res", "claim_id": "ccc", "nout": 0, "txid": "aecfaewcfa"}]
|
|
||||||
self.run_test(results, 'height', [1, 2, 3])
|
|
||||||
|
|
||||||
def test_sort_claim_results_when_sorted_by_name(self):
|
|
||||||
results = [{"height": 1, "name": "res1", "claim_id": "ccc", "nout": 0, "txid": "aecfaewcfa"},
|
|
||||||
{"height": 1, "name": "res3", "claim_id": "ccc", "nout": 0, "txid": "aecfaewcfa"},
|
|
||||||
{"height": 1, "name": "res2", "claim_id": "ccc", "nout": 0, "txid": "aecfaewcfa"}]
|
|
||||||
self.run_test(results, 'name', ['res1', 'res2', 'res3'])
|
|
||||||
|
|
||||||
def test_sort_claim_results_when_sorted_by_txid(self):
|
|
||||||
results = [{"height": 1, "name": "res1", "claim_id": "ccc", "nout": 2, "txid": "111"},
|
|
||||||
{"height": 1, "name": "res1", "claim_id": "ccc", "nout": 1, "txid": "222"},
|
|
||||||
{"height": 1, "name": "res1", "claim_id": "ccc", "nout": 3, "txid": "333"}]
|
|
||||||
self.run_test(results, 'txid', ['111', '222', '333'])
|
|
||||||
|
|
||||||
def test_sort_claim_results_when_sorted_by_nout(self):
|
|
||||||
results = [{"height": 1, "name": "res1", "claim_id": "ccc", "nout": 2, "txid": "aecfaewcfa"},
|
|
||||||
{"height": 1, "name": "res1", "claim_id": "ccc", "nout": 1, "txid": "aecfaewcfa"},
|
|
||||||
{"height": 1, "name": "res1", "claim_id": "ccc", "nout": 3, "txid": "aecfaewcfa"}]
|
|
||||||
self.run_test(results, 'nout', [1, 2, 3])
|
|
||||||
|
|
||||||
def run_test(self, results, field, expected):
|
|
||||||
data = {'result': results}
|
|
||||||
claims = sort_claim_results([data])
|
|
||||||
claim = claims[0]
|
|
||||||
actual = claim['result']
|
|
||||||
self.assertEqual(expected, [r[field] for r in actual])
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
Loading…
Reference in a new issue