Page MenuHomePhabricator

[herald] Add price info to sent tg msgs
ClosedPublic

Authored by bytesofman on Apr 8 2023, 17:54.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC11e0a439b57d: [herald] Add price info to sent tg msgs
Summary

T2972

Depends on D13642

Add price info to messages sent by ecash-herald

A slight refactor was required to the getCoingeckoPrices function. We need coingecko's exact API response for unit test mocks. So, I return it.

Another option would be to separate getCoingeckoPrices into two functions. This was considered but dismissed as it is useful to get all the info from using your config.priceApi param.

Test Plan

npm test
npm run sendTestTgMsgs and msgs are sent by test bot with properly formatted price info

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 23171
Build 45961: Build Diff
Build 45960: arc lint + arc unit

Event Timeline

Tail of the build log:

npm WARN EBADENGINE   package: 'eslint-visitor-keys@3.4.0',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v15.14.0', npm: '7.7.6' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'espree@9.5.1',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v15.14.0', npm: '7.7.6' }
npm WARN EBADENGINE }
npm WARN deprecated request-promise@4.2.6: request-promise has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

added 435 packages, and audited 436 packages in 4s

86 packages are looking for funding
  run `npm fund` for details

4 moderate severity vulnerabilities

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
npm notice 
npm notice New major version of npm available! 7.7.6 -> 9.6.4
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.6.4>
npm notice Run `npm install -g npm@9.6.4` to update!
npm notice 

> ecash-herald@1.0.0 test
> mocha "--reporter" "mocha-junit-reporter" "--reporter-options" "mochaFile=test_results/ecash-herald-junit.xml" "--reporter-options" "testsuitesTitle=eCash Herald Unit Tests" "--reporter-options" "rootSuiteTitle=eCash Herald"

--------------------|---------|----------|---------|---------|-------------------
File                | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
--------------------|---------|----------|---------|---------|-------------------
All files           |   95.81 |    84.26 |   94.44 |   95.65 |                   
 ecash-herald       |     100 |      100 |     100 |     100 |                   
  config.js         |     100 |      100 |     100 |     100 |                   
  secrets.sample.js |     100 |      100 |     100 |     100 |                   
 ecash-herald/src   |   95.78 |    84.26 |   94.44 |   95.61 |                   
  events.js         |    82.6 |       80 |     100 |    82.6 | 28,51,71,89       
  main.js           |   84.61 |       80 |     100 |   84.61 | 45-51             
  parse.js          |    97.9 |    81.66 |     100 |   97.79 | 93,134-137        
  utils.js          |     100 |    94.11 |     100 |     100 | 10                
  websocket.js      |   93.75 |      100 |   66.66 |   93.75 | 19                
--------------------|---------|----------|---------|---------|-------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='229']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='239']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='75']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='89']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='17']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='18']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='220']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='230']
##teamcity[blockClosed name='Code Coverage Summary']
Build ecash-herald-tests failed with exit code 1

Mock coingecko call in eventsTests.js

Add unit tests for failed coingecko call

Same remark here as for the node. You can build a mocked price api and avoid axios

This revision is now accepted and ready to land.Apr 10 2023, 19:14
This revision was automatically updated to reflect the committed changes.