Page MenuHomePhabricator

[ecash-herald] Add new script to support testing, sendMsgByBlock
ClosedPublic

Authored by bytesofman on Jun 9 2023, 23:35.

Details

Summary

T2972

It's impractical to keep adding more and more test blocks as the app covers more and more use cases. Often when adding a new feature, you just need to check the result one a single block, and not all of the test blocks.

This test script allows you to generate a msg and send to your test channel by blockheight, e.g. npm run sendMsgByBlock 700000

Test Plan

npm test
npm run sendMsgByBlock 700000 and msgs send

Diff Detail

Repository
rABC Bitcoin ABC
Branch
herald-build-msg-by-blockheight
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 23984
Build 47578: Build Diffecash-herald-tests
Build 47577: arc lint + arc unit

Event Timeline

emack requested changes to this revision.Jun 10 2023, 07:14
emack added a subscriber: emack.

Both default genesis block and user specified block words fine, just need to test the failed price API scenario on sendBlockSummary

apps/ecash-herald/scripts/sendMsgByBlock.js
85–89 ↗(On Diff #40714)

do you have a way to test this specific call for a failed price API fetch?

This revision now requires changes to proceed.Jun 10 2023, 07:14

Both default genesis block and user specified block words fine, just need to test the failed price API scenario on sendBlockSummary

When you run npm run sendMsgByBlock -- or npm run sendMsgByBlock 700000 -- you should receive 2 msgs. The first has price info, the second does not.

Since this script is primarily for developer use and testing, imo acceptable that each msg is not specifically labeled.

apps/ecash-herald/scripts/sendMsgByBlock.js
85–89 ↗(On Diff #40714)

If handleBlockConnected is called with returnMocks = true, then the returned mocks include blockSummaryTgMsgsApiFailure, which includes telegram bot msg strings that are generated from getBlockTgMessage called with coingeckoPrices = false

So, it's behaving the same as the production app in this case.

At the moment I don't have a better way of testing what the actual messages will look like apart from sending them through the API and reviewing them. Later on, when the features set is more stable, can develop templates and unit tests designed to catch common rendering issues.

This revision is now accepted and ready to land.Jun 12 2023, 22:25