liftedinit / many-js

JavaScript implementation of the MANY protocol
Apache License 2.0
5 stars 7 forks source link

test: Integration tests for v1 #103

Closed stanleyjones closed 1 year ago

stanleyjones commented 1 year ago

I'm actually working on integration tests for v2 (i.e. the next branch) but they keep failing and I wanted to make sure that the same tests work in v1. So here they are. Honestly, just the basics.

Test Results

❯ npm run test:integration

> @liftedinit/many-js@0.1.0-alpha.9 test:integration
> jest --testMatch '**/?(*.)+(integration).[jt]s?(x)'

 PASS  src/__tests__/network.integration.ts
  Network
    ✓ should send encoded bytes (21 ms)
    ✓ should send a request from bytes (9 ms)
    ✓ should send a request from an object (6 ms)
    ✓ should call a method (6 ms)
    ✓ should call a method from a shortcut (6 ms)
    ✓ should call a method non-anonymously (31 ms)

Test Suites: 1 passed, 1 total
Tests:       6 passed, 6 total
Snapshots:   0 total
Time:        1.189 s
Ran all test suites.

Coverage

From unit tests, not integration.

----------------------------------------|---------|----------|---------|---------|------------------------------------
File                                    | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------------------------------------|---------|----------|---------|---------|------------------------------------
All files                               |   84.77 |     66.6 |   77.25 |   84.92 |
 src                                    |   57.14 |      100 |     100 |   57.14 |
  const.ts                              |     100 |      100 |     100 |     100 |
  index.ts                              |       0 |      100 |     100 |       0 | 1-3
 src/identity                           |   89.13 |    66.66 |   81.81 |   89.13 |
  address.ts                            |   86.48 |    66.66 |   77.77 |   86.48 | 14,34,65-68
  index.ts                              |     100 |      100 |     100 |     100 |
  types.ts                              |     100 |      100 |     100 |     100 |
 src/identity/anonymous                 |   72.72 |      100 |      40 |      70 |
  anonymous-identity.ts                 |   66.66 |      100 |      25 |   66.66 | 12-20
  index.ts                              |     100 |      100 |     100 |     100 |
 src/identity/ed25519                   |   94.59 |      100 |      80 |   94.59 |
  ed25519-key-pair-identity.ts          |   94.44 |      100 |      80 |   94.44 | 61,79
  index.ts                              |     100 |      100 |     100 |     100 |
 src/identity/webauthn                  |      50 |        0 |   31.25 |   50.84 |
  index.ts                              |     100 |      100 |     100 |     100 |
  webauthn-identity.ts                  |   49.15 |        0 |   31.25 |      50 | 24,33-77,111-184
 src/message                            |   75.75 |    39.24 |   85.71 |   75.75 |
  cbor.ts                               |     100 |      100 |     100 |     100 |
  cose.ts                               |   83.33 |    37.03 |   85.71 |   83.33 | 105-114,127,153
  error.ts                              |   91.66 |    64.28 |     100 |   91.66 | 15
  index.ts                              |   60.78 |    31.57 |   81.81 |   60.78 | 43,48,51,55,62,65,68,77,90-101,114
 src/message/attributes                 |     100 |      100 |     100 |     100 |
  attributes.ts                         |     100 |      100 |     100 |     100 |
  index.ts                              |     100 |      100 |     100 |     100 |
  types.ts                              |     100 |      100 |     100 |     100 |
 src/message/attributes/async-attribute |     100 |       80 |     100 |     100 |
  async-attribute.ts                    |     100 |       80 |     100 |     100 | 15,27
  index.ts                              |     100 |      100 |     100 |     100 |
 src/network                            |    91.3 |    55.55 |     100 |    91.3 |
  index.ts                              |     100 |      100 |     100 |     100 |
  network.ts                            |   90.47 |    55.55 |     100 |   90.47 | 31,35
 src/network/modules                    |     100 |      100 |     100 |     100 |
  index.ts                              |     100 |      100 |     100 |     100 |
  types.ts                              |     100 |      100 |     100 |     100 |
 src/network/modules/account            |   94.87 |    77.77 |   94.73 |   97.33 |
  account.ts                            |   94.73 |    77.77 |     100 |   97.29 | 240,272
  index.ts                              |     100 |      100 |       0 |     100 |
 src/network/modules/async              |   89.58 |    71.42 |     100 |   89.13 |
  async.ts                              |   89.36 |    71.42 |     100 |   88.88 | 51,54,61,91,94
  index.ts                              |     100 |      100 |     100 |     100 |
 src/network/modules/base               |     100 |       75 |   83.33 |     100 |
  base.ts                               |     100 |       75 |     100 |     100 | 55-60
  index.ts                              |     100 |      100 |       0 |     100 |
 src/network/modules/blockchain         |      50 |      100 |       0 |      40 |
  blockchain.ts                         |      25 |      100 |       0 |      25 | 5-15
  index.ts                              |     100 |      100 |       0 |     100 |
 src/network/modules/events             |    92.3 |    73.52 |   88.88 |    92.1 |
  events.ts                             |   91.89 |    73.52 |     100 |   91.89 | 203,218,224
  index.ts                              |     100 |      100 |       0 |     100 |
 src/network/modules/id-store           |     100 |    68.75 |     100 |     100 |
  id-store.ts                           |     100 |    68.75 |     100 |     100 | 33-63,80
  index.ts                              |     100 |      100 |     100 |     100 |
 src/network/modules/kvStore            |   22.22 |        0 |   14.28 |   20.45 |
  index.ts                              |     100 |      100 |       0 |     100 |
  kvStore.ts                            |    18.6 |        0 |   15.38 |    18.6 | 23-87,101-114
 src/network/modules/ledger             |   88.88 |    76.92 |    62.5 |   91.17 |
  index.ts                              |     100 |      100 |     100 |     100 |
  ledger.ts                             |   88.23 |    76.92 |   57.14 |    90.9 | 35-46
 src/network/modules/test               |     100 |       75 |     100 |     100 |
  test-utils.ts                         |     100 |       75 |     100 |     100 | 30
 src/network/modules/tokens             |   96.82 |    68.96 |    87.5 |   96.77 |
  index.ts                              |     100 |      100 |       0 |     100 |
  tokens.ts                             |   96.72 |    68.96 |   93.33 |   96.72 | 66-67
 src/utils                              |    92.3 |    78.26 |    87.5 |    92.3 |
  index.ts                              |    92.3 |    78.26 |    87.5 |    92.3 | 43,52,98
 src/utils/transactions                 |   94.68 |       80 |   94.73 |   94.62 |
  index.ts                              |   94.68 |       80 |   94.73 |   94.62 | 95,210,225-229,276
----------------------------------------|---------|----------|---------|---------|------------------------------------
stanleyjones commented 1 year ago

Can you craft a properly signed request using a random identity?

Added.

You should be able to reproduce the following error

Yes, changing the port allowed me to reproduce the error. I've added a means to not get that error (running many message status --hex before running the tests and then using the result) but it makes some assumptions about relative paths. We could beef it up if you think it's the right direction.