Compare commits

...
8 Commits
6 changed files with 69 additions and 43 deletions

No files matched your search

+49 -33
View File
@@ -14,9 +14,17 @@ default:
stages:
- test
- build
- assets
- release
.tagged:
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9\.]+$/'
when: on_success
test:lint:
stage: test
script:
@@ -29,29 +37,25 @@ test:lbry-unit:
- make install tools
- cd lbry && HOME=/tmp coverage run -p --source=lbry -m unittest discover -vv tests.unit
test:lbry-integ:
stage: test
script:
- pip install coverage tox-travis
- cd lbry && tox
.torba-tests: &torba_tests
test:torba-unit:
stage: test
script:
- pip install coverage tox-travis
- cd torba && tox
test:torba-unit:
before_script:
- export TESTTYPE=unit
<<: *torba_tests
- cd torba/tests
- tox -e py37-unit
test:torba-integ:
before_script:
- export TESTTYPE=integration
<<: *torba_tests
stage: test
script:
- pip install coverage tox-travis
- cd torba/tests
- tox -e py37-integration-torba.coin.bitcoinsegwit
test:json-api:
stage: test
@@ -129,15 +133,15 @@ build:windows:
- python docker/set_build.py
- pip install -e lbry/.
- pyinstaller --additional-hooks-dir=lbry/scripts/. --icon=lbry/icons/lbry256.ico -F -n lbrynet lbry/lbry/extras/cli.py
- 7z a -tzip $env:CI_PROJECT_DIR/lbrynet-${OS}.zip dist/lbrynet.exe
- 7z a -tzip $env:CI_PROJECT_DIR/lbrynet-${OS}.zip ./dist/lbrynet.exe
- checksum --type=sha256 --file=$env:CI_PROJECT_DIR/lbrynet-${OS}.zip
- dist/lbrynet.exe --version
# s3 = upload asset to s3 (build.lbry.io)
# could be done by making it a yaml alias and putting it right into the build step. that way if one OS fails, the others still get uploaded
.s3:
stage: release
stage: assets
variables:
GIT_STRATEGY: none
script:
@@ -149,42 +153,54 @@ build:windows:
s3:linux:
extends: .s3
variables: {OS: linux}
dependencies: ["build:linux"]
needs: ["build:linux"]
s3:mac:
extends: .s3
variables: {OS: mac}
dependencies: ["build:mac"]
needs: ["build:mac"]
s3:windows:
extends: .s3
variables: {OS: windows}
dependencies: ["build:windows"]
needs: ["build:windows"]
# release = upload assets to github when there's a tagged release
.release:
stage: release
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9\.]+$/'
when: on_success
# github = upload assets to github when there's a tagged release
.github:
extends: .tagged
stage: assets
variables:
GIT_STRATEGY: none
script:
- pip install githubrelease
- githubrelease --no-progress --github-token ${GITHUB_CI_USER_ACCESS_TOKEN} asset lbryio/lbry-sdk upload ${CI_COMMIT_TAG} lbrynet-${OS}.zip
release:linux:
extends: .release
github:linux:
extends: .github
variables: {OS: linux}
dependencies: ["build:linux"]
needs: ["build:linux"]
release:mac:
extends: .release
github:mac:
extends: .github
variables: {OS: mac}
dependencies: ["build:mac"]
needs: ["build:mac"]
release:windows:
extends: .release
github:windows:
extends: .github
variables: {OS: windows}
dependencies: ["build:windows"]
needs: ["build:windows"]
publish:
extends: .tagged
stage: release
variables:
GIT_STRATEGY: none
script:
- pip install githubrelease
- githubrelease --no-progress --github-token ${GITHUB_CI_USER_ACCESS_TOKEN} release lbryio/lbry-sdk publish ${CI_COMMIT_TAG}
- >
curl -X POST -H 'Content-type: application/json' --data '{"text":"<!channel> There's a new SDK release: https://github.com/lbryio/lbry-sdk/releases/tag/'"${CI_COMMIT_TAG}"'\n'"$(curl -s "https://api.github.com/repos/lbryio/lbry-sdk/releases/tags/${CI_COMMIT_TAG}" | egrep '\w*\"body\":' | cut -d':' -f 2- | tail -c +3 | head -c -2)"'", "channel":"tech"}' "$(echo ${SLACK_WEBHOOK_URL_BASE64} | base64 -d)"
+5 -3
View File
@@ -128,11 +128,13 @@ class WalletComponent(Component):
if self.wallet_manager.ledger.network.remote_height:
local_height = self.wallet_manager.ledger.local_height_including_downloaded_height
disk_height = len(self.wallet_manager.ledger.headers)
download_height = local_height - disk_height if disk_height != local_height else local_height
remote_height = self.wallet_manager.ledger.network.remote_height
target_height = remote_height - disk_height if disk_height != local_height else remote_height
best_hash = self.wallet_manager.get_best_blockhash()
if disk_height != local_height != remote_height:
download_height, target_height = local_height - disk_height, remote_height - disk_height
else:
download_height, target_height = local_height, remote_height
progress = min(max(math.ceil(float(download_height) / float(target_height) * 100), 0), 100)
best_hash = self.wallet_manager.get_best_blockhash()
result.update({
'headers_synchronization_progress': progress,
'blocks': max(local_height, 0),
+4 -4
View File
@@ -718,8 +718,6 @@ class SQLDB:
claim_hash = output.claim_hash
update_claims.append(output)
recalculate_claim_hashes.add(claim_hash)
delete_claim_hashes.discard(claim_hash)
update_claim_hashes.add(claim_hash)
body_timer.stop()
skip_update_claim_timer = timer.add_timer('skip update of abandoned claims')
@@ -727,8 +725,10 @@ class SQLDB:
for updated_claim in list(update_claims):
if updated_claim.ref.hash in delete_others:
update_claims.remove(updated_claim)
delete_claim_hashes.add(updated_claim.claim_hash)
update_claim_hashes.discard(updated_claim.claim_hash)
for updated_claim in update_claims:
claim_hash = updated_claim.claim_hash
delete_claim_hashes.discard(claim_hash)
update_claim_hashes.add(claim_hash)
skip_update_claim_timer.stop()
skip_insert_claim_timer = timer.add_timer('skip insertion of abandoned claims')
@@ -321,6 +321,14 @@ class TestClaimtrie(TestSQLDB):
advance(10, [stream, self.get_stream_update(stream, 11*COIN)])
self.assertTrue(reader._search())
def test_double_updates_in_same_block(self):
advance, state = self.advance, self.state
stream = self.get_stream('Claim A', 10*COIN)
advance(10, [stream])
update = self.get_stream_update(stream, 11*COIN)
advance(20, [update, self.get_stream_update(update, 9*COIN)])
self.assertTrue(reader._search())
def test_create_and_abandon_in_same_block(self):
advance, state = self.advance, self.state
stream = self.get_stream('Claim A', 10*COIN)
@@ -180,7 +180,7 @@ class TestQueryBuilder(unittest.TestCase):
a__not='b', b__in='select * from blah where c=:$c',
d__any={'one__like': 'o', 'two': 2},
a0=3, a00=1, a00a=2, a00aa=4, # <-- breaks without correct interpolation key order
ahash=memoryview(sha256(b'hello world')),
ahash=sha256(b'hello world'),
limit=10, order_by='b', **{'$c': 3})
),
"select * from foo WHERE a != 'b' AND "
+2 -2
View File
@@ -199,8 +199,8 @@ def query(select, **constraints) -> Tuple[str, Dict[str, Any]]:
def interpolate(sql, values):
for k in sorted(values.keys(), reverse=True):
value = values[k]
if isinstance(value, memoryview):
value = f"X'{hexlify(bytes(value)).decode()}'"
if isinstance(value, bytes):
value = f"X'{hexlify(value).decode()}'"
elif isinstance(value, str):
value = f"'{value}'"
else: