ssbc / ssb-tangle

8 stars 2 forks source link

Add some tests for getHeads #9

Closed Powersource closed 4 years ago

Powersource commented 4 years ago

Helps with solving https://github.com/ssbc/ssb-tangle/issues/7

Powersource commented 4 years ago

For a lack of CI, the failing tests are

getHeads: Root-only graph
getHeads: Graph with simple merge
Powersource commented 4 years ago

wait I remembered another case I want to add

Powersource commented 4 years ago

Ok now I'm done

mixmix commented 4 years ago

thanks so much for adding these tests @Powersource ! Sorry for the long delay. Please feel free to DM me on ssb in general (I honestly don't watch notifications anywhere else).

I notice this method isn't used anywhere in the repo currently, and I think in fact I've been using the reduce function to do this. But I have an emerging need to just calculate heads without reducing, so will see what I can do about getting a working function.

Basically I think the API needs to include the entry point

mixmix commented 4 years ago

Also, I think the file-name lib/misc-junk.js was quite deliberately dodgy sounding. i.e. if you're using things from here ... look out!

mixmix commented 4 years ago

Hey @Powersource I've written a function for finding heads in a way which I think is best. The tests should show how it can be used, let me know if it's not clear though.

NOTE - this ignores any dangling nodes, because for my needs and assumptions about tangles I'm working with, that's appropriate. If you want to include dangling nodes, perhaps check out ssb-sort which is the old (and rough) tangle heads calculator.

mixmix commented 4 years ago

published as ssb-tangle@2.1.0