Page MenuHomePhabricator

[ecash-lib] Add `TestRunner`
ClosedPublic

Authored by tobias_ruck on Apr 28 2024, 02:02.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Commits
rABCa1e137d5e8eb: [ecash-lib] Add `TestRunner`
Summary

Currently, the integration tests setup is copy-pasted between each test. In this diff, TestRunner is added so we can abstract this setup away so tests can focus on the actual test.

Previous attempts tried to add a ecash-test-utils package with this class, however, since it depended on both chronik-client and ecash-lib (which in turn depended on ecash-test-utils), it was very difficult to resolve this circular dependency, so this approach has been dropped.

Test Plan

npm run test && npm run integration-tests && npm run build

Diff Detail

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

Event Timeline

Tail of the build log:

   Compiling once_cell v1.19.0
   Compiling log v0.4.21
   Compiling thiserror v1.0.58
   Compiling wasm-bindgen v0.2.92
   Compiling cfg-if v1.0.0
   Compiling abc-rust-lint v0.1.0 (/work/chronik/abc-rust-lint)
   Compiling generic-array v0.14.7
   Compiling quote v1.0.36
   Compiling syn v2.0.58
   Compiling secp256k1-sys-abc v0.4.1 (https://github.com/raipay/secp256k1-abc?rev=b23e742#b23e7421)
   Compiling crypto-common v0.1.6
   Compiling block-buffer v0.10.4
   Compiling digest v0.10.7
   Compiling sha2 v0.10.8
   Compiling ripemd v0.1.3
   Compiling wasm-bindgen-backend v0.2.92
   Compiling secp256k1-abc v0.20.3 (https://github.com/raipay/secp256k1-abc?rev=b23e742#b23e7421)
   Compiling thiserror-impl v1.0.58
   Compiling wasm-bindgen-macro-support v0.2.92
   Compiling wasm-bindgen-macro v0.2.92
   Compiling ecash-lib-wasm v0.1.0 (/work/modules/ecash-lib-wasm)
    Finished release-wasm [optimized] target(s) in 5.81s
Test depends on chronik-client. Building TypeScript...
/work/modules/chronik-client /work/modules/ecash-lib-wasm /work/abc-ci-builds/ecash-lib-tests

> chronik-client@0.26.2 prepublish
> npm run build


> chronik-client@0.26.2 build
> tsc


added 270 packages, and audited 271 packages in 6s

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

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
/work/modules/ecash-lib /work/modules/chronik-client /work/modules/ecash-lib-wasm /work/abc-ci-builds/ecash-lib-tests

added 363 packages, and audited 366 packages in 2s

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

found 0 vulnerabilities
CI configured to test build. Building...

> ecash-lib@0.1.0 build
> tsc && npm run build:only

tests/alp.test.ts(7,28): error TS2307: Cannot find module 'ecash-test-utils' or its corresponding type declarations.
tests/txBuilder.test.ts(7,28): error TS2307: Cannot find module 'ecash-test-utils' or its corresponding type declarations.
Build ecash-lib-tests failed with exit code 2

Tail of the build log:

    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:179:18)
    at exports.requireOrImport (/work/modules/ecash-lib/node_modules/mocha/lib/nodejs/esm-utils.js:53:16)
    at async exports.loadFilesAsync (/work/modules/ecash-lib/node_modules/mocha/lib/nodejs/esm-utils.js:100:20)
    at async singleRun (/work/modules/ecash-lib/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at async exports.handler (/work/modules/ecash-lib/node_modules/mocha/lib/cli/run.js:370:5) {
  code: 'MODULE_NOT_FOUND',
  path: '/work/modules/ecash-lib/node_modules/ecash-test-utils/package.json',
  requestPath: 'ecash-test-utils'
}
---------------------|---------|----------|---------|---------|-------------------
File                 | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
---------------------|---------|----------|---------|---------|-------------------
All files            |       0 |        0 |       0 |       0 |                   
 ecash-lib           |       0 |        0 |       0 |       0 |                   
  eslint.config.js   |       0 |        0 |       0 |       0 |                   
 ecash-lib/src       |       0 |        0 |       0 |       0 |                   
  ecc.ts             |       0 |      100 |       0 |       0 | 22-35             
  hash.ts            |       0 |      100 |     100 |       0 | 7-9               
  index.ts           |       0 |        0 |       0 |       0 |                   
  init.ts            |       0 |        0 |       0 |       0 | 9-16              
  op.ts              |       0 |        0 |       0 |       0 | 33-124            
  opcode.ts          |       0 |      100 |     100 |       0 | 10-154            
  script.ts          |       0 |        0 |       0 |       0 | 26-158            
  sigHashType.ts     |       0 |        0 |       0 |       0 | 19-166            
  tx.ts              |       0 |        0 |       0 |       0 | 20-163            
  txBuilder.ts       |       0 |        0 |       0 |       0 | 67-238            
  unsignedTx.ts      |       0 |        0 |       0 |       0 | 38-229            
 ecash-lib/src/ffi   |       0 |        0 |       0 |       0 |                   
  ecash_lib_wasm.js  |       0 |        0 |       0 |       0 | 3-336             
 ecash-lib/src/io    |       0 |        0 |       0 |       0 |                   
  bytes.ts           |       0 |        0 |       0 |       0 | 13-64             
  hex.ts             |       0 |        0 |       0 |       0 | 5-68              
  int.ts             |       0 |        0 |       0 |       0 |                   
  str.ts             |       0 |      100 |       0 |       0 | 5-9               
  varsize.ts         |       0 |        0 |       0 |       0 | 14-47             
  writer.ts          |       0 |        0 |       0 |       0 |                   
  writerbytes.ts     |       0 |        0 |       0 |       0 | 21-79             
  writerlength.ts    |       0 |      100 |       0 |       0 | 16-41             
 ecash-lib/src/token |       0 |        0 |       0 |       0 |                   
  alp.ts             |       0 |        0 |       0 |       0 | 13-145            
  common.ts          |       0 |      100 |     100 |       0 | 9-12              
  empp.ts            |       0 |        0 |       0 |       0 | 11-28             
---------------------|---------|----------|---------|---------|-------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='796']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='275']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='127']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='780']
##teamcity[blockClosed name='Code Coverage Summary']
mv: cannot stat 'test_results/ecash-lib-integration-tests-junit.xml': No such file or directory
Build ecash-lib-integration-tests failed with exit code 1

move TestRunner into ecash-lib (no crazy circular dependency hell)

tobias_ruck retitled this revision from [ecash-lib] Add `ecash-test-utils` package in modules to [ecash-lib] Add `TestRunner`.Apr 29 2024, 22:48
tobias_ruck edited the summary of this revision. (Show Details)
tobias_ruck edited the test plan for this revision. (Show Details)

reorder imports, delay ChronikClientNode import, use Script in sendToScript

This revision is now accepted and ready to land.Apr 29 2024, 23:17
This revision was automatically updated to reflect the committed changes.