bcoin-org / bcash

Implementation of Bitcoin Cash protocol in node.js
Other
102 stars 68 forks source link

indexer: fix getCoinsByAddress AssertionError #119

Closed tuxcanfly closed 5 years ago

tuxcanfly commented 5 years ago

fixes #118

address indexer was incorrectly failing to remove coins from transaction inputs, if the transaction was ordered before it's parent. Just like chain, we need to handle this by iterating and adding all outputs first, then iterating again to delete inputs. The reverse needs to handled when unindexing.

Added regression test which covers this case. Tested it fails before the fix, and the fix makes it pass.

Thanks for spotting @jeansouza

codecov-io commented 5 years ago

Codecov Report

Merging #119 into master will increase coverage by 0.05%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #119      +/-   ##
==========================================
+ Coverage   55.48%   55.53%   +0.05%     
==========================================
  Files         109      109              
  Lines       27169    27173       +4     
  Branches     4496     4496              
==========================================
+ Hits        15074    15091      +17     
+ Misses      12095    12082      -13
Impacted Files Coverage Δ
lib/indexer/addrindexer.js 97.64% <100%> (+0.11%) :arrow_up:
lib/workers/child.js 67.9% <0%> (ø) :arrow_up:
lib/indexer/chainclient.js 84.61% <0%> (+1.53%) :arrow_up:
lib/indexer/indexer.js 77.74% <0%> (+1.56%) :arrow_up:
lib/indexer/records.js 62.71% <0%> (+11.86%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 15f7a91...215974a. Read the comment docs.

jeansouza commented 5 years ago

@tuxcanfly thank you man! :)