Page MenuHomePhabricator

[mock-chronik-client] Support ws.unsubscribe
ClosedPublic

Authored by bytesofman on Mar 5 2024, 20:15.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABCb3f29c79ce36: [mock-chronik-client] Support ws.unsubscribe
Summary

Add overlooked ws.unsubscribe feature to mocked-chronik-client

Clean up ws unit tests which, through bugs, made it look like this feature existed.

Test Plan

npm test

Event Timeline

bytesofman published this revision for review.Mar 5 2024, 20:21
bytesofman added inline comments.
apps/mock-chronik-client/test/index.test.js
180

this isn't testing what it looks like it's testing

if we want to enable testing of the ws receiving and responding to msgs, would take more work here. It is probably not doable, at least not in a way where it is helpful to tests.

Testing actual websocket imo would best be done using bridged py regtest mocha integration tests like those in modules/chronik-client

emack requested changes to this revision.Mar 5 2024, 22:06
emack added a subscriber: emack.
emack added inline comments.
apps/mock-chronik-client/index.js
104

The implementation in D15613 throws an error if it's not found so I think it should be reflected here so the unit tests can check this behavior. (there's no equivalent test in D15613)

This revision now requires changes to proceed.Mar 5 2024, 22:06

rebase, add test for thrown error

bytesofman added inline comments.
apps/mock-chronik-client/index.js
104

we do this in unsubscribeFromAddress here, which is the function introduced by D15613. I added a unit test here to confirm this.

For the subscribe function -- let's do that in a separate diff. It is going to change and become subscribeToScript to support in-node chronik tests.

For now, it is modeled on the NNG one -- still used in Cashtab and still tested this way -- which does not have this behavior.

bytesofman added inline comments.
apps/mock-chronik-client/test/index.test.js
232 ↗(On Diff #45951)

added test to confirm chronik-client in-node behavior

This revision is now accepted and ready to land.Mar 6 2024, 00:01