Skip to content

Commit

Permalink
chore: don't spin up token registry server, mock func instead
Browse files Browse the repository at this point in the history
  • Loading branch information
slowbackspace committed Feb 16, 2024
1 parent 618b673 commit bc09396
Show file tree
Hide file tree
Showing 60 changed files with 927 additions and 209 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .yarn/cache/fsevents-patch-21ad2b1333-8.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- node_modules
- yarn
- updated vitest
- removed token registry mock server, using function mocking instead

### Fixed

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"start": "yarn build && node --max-http-header-size=32768 dist/server.js",
"start-mainnet": "cross-env-shell NODE_ENV=mainnet \"yarn start\"",
"start-testnet": "cross-env-shell NODE_ENV=testnet \"yarn start\"",
"test": "cross-env NODE_OPTIONS='--max-http-header-size 32768' NODE_ENV=test vitest",
"test": "cross-env NODE_OPTIONS='--max-http-header-size 32768' NODE_ENV=test vitest --run",
"test-badges": "make-coverage-badge --output-path ./docs/images/badge.svg",
"type-check": "tsc --project tsconfig.json"
},
Expand Down Expand Up @@ -67,7 +67,7 @@
"supertest": "^6.3.3",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"vitest": "^0.27"
"vitest": "^1.2.2"
},
"packageManager": "[email protected]",
"type": "module",
Expand Down
13 changes: 5 additions & 8 deletions src/routes/assets/asset/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,11 @@ async function route(fastify: FastifyInstance) {

// retrieve off-chain metadata
const metadata = await fetchAssetMetadata(request.params.asset);
// @ts-expect-error due to using ESM with vitest and some weirdness with cip14 lib we need to call .default
// otherwise unit test fails on ""...is not a function".
const fingerprint = AssetFingerprint.default
.fromParts(
Uint8Array.from(Buffer.from(rows[0].policy_id, 'hex')),
Uint8Array.from(Buffer.from(rows[0].asset_name ?? '', 'hex')),
)
.fingerprint();

const fingerprint = AssetFingerprint.fromParts(
Uint8Array.from(Buffer.from(rows[0].policy_id, 'hex')),
Uint8Array.from(Buffer.from(rows[0].asset_name ?? '', 'hex')),
).fingerprint();

return reply.send({
...rows[0],
Expand Down
124 changes: 0 additions & 124 deletions test/unit/fixtures/token-registry.fixtures.ts

This file was deleted.

26 changes: 0 additions & 26 deletions test/unit/server-token-registry.ts

This file was deleted.

1 change: 1 addition & 0 deletions test/unit/tests/routes/addresses.unit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as databaseUtils from '../../../../src/utils/database.js';
import * as tokenRegistryUtils from '../../../../src/utils/token-registry.js';
import sinon from 'sinon';
import supertest from 'supertest';
import fixtures from '../../fixtures/addresses.fixtures.js';
Expand Down
1 change: 0 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { defineConfig, defaultInclude } from 'vitest/config';
export default defineConfig({
test: {
reporters: ['verbose'],
globalSetup: ['./test/unit/server-token-registry.ts'],
testTimeout: 20_000,
root: '.',
mockReset: true,
Expand Down
137 changes: 94 additions & 43 deletions yarn-project.nix

Large diffs are not rendered by default.

Loading

0 comments on commit bc09396

Please sign in to comment.