Page MenuHomePhabricator

[alias-server] get tipHash and tipHeight on app startup
ClosedPublic

Authored by bytesofman on Apr 8 2023, 13:23.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCa2a7e4cd33ad: [alias-server] get tipHash and tipHeight on app startup
Summary

T3060

Depends on D13629

Get tipHash and tipHeight on app startup.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested changes to this revision.Apr 9 2023, 07:18
Fabien added a subscriber: Fabien.
Fabien added inline comments.
apps/alias-server/src/events.js
34 ↗(On Diff #39427)

Macro likestamp:

38 ↗(On Diff #39427)

you don't need that yet, but ok

89 ↗(On Diff #39427)
95 ↗(On Diff #39427)

You don't need these test only strings

apps/alias-server/test/eventsTests.js
11 ↗(On Diff #39427)

that's not what you want to test because this is an implementation detail. You want to check startup causes the aliases to register up to the expected tip

This revision now requires changes to proceed.Apr 9 2023, 07:18
Fabien added inline comments.
apps/alias-server/test/eventsTests.js
10 ↗(On Diff #39427)

See comment in D13632

apps/alias-server/src/events.js
95 ↗(On Diff #39427)

Ultimately they will be changed when the function is complete. For now it's a way to make sure the function is doing what it is supposed to do so far.

apps/alias-server/test/eventsTests.js
11 ↗(On Diff #39427)

For now, the test is designed to test everything the function should do at this stage of app development. The logic to register aliases to expected tip will be added / tested later.

The tests will have to be modified as additional logic is added to the function.

I'm not sure what the abc best practice is here. Should I just not test the function until it's complete? Verifying that it's doing what is expected at this stage seems like a good way to make incremental progress.

Fabien requested changes to this revision.Apr 10 2023, 19:02
Fabien added inline comments.
apps/alias-server/test/eventsTests.js
11 ↗(On Diff #39427)

You're missing my point: the test itself is a good idea, only the execution is wrong. You are changing the behavior of the handleBlockConnected function for the sake of the test and you don't need to.
What you want to check is that you are syncing upon startup: it's enough to check the previously returned value, you don't need to specify where it came from to achieve that.
If you want to make sure you have the proper tip height, just add it to the returned string like I suggested in the other comment.

This revision now requires changes to proceed.Apr 10 2023, 19:02

Unit tests continue to test for desired end condition

This revision is now accepted and ready to land.Apr 11 2023, 04:41