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 0da1813
Show file tree
Hide file tree
Showing 60 changed files with 933 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
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.

9 changes: 8 additions & 1 deletion test/unit/tests/routes/addresses.unit.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
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';
import buildFastify from '../../../../src/app.js';
import { describe, expect, test, vi } from 'vitest';
import { beforeEach, describe, expect, test, vi } from 'vitest';

import * as config from '../../../../src/config.js';

describe('address service', () => {
beforeEach(() => {
vi.spyOn(tokenRegistryUtils, 'fetchAssetMetadata').mockImplementation(() => {
return Promise.resolve(null);
});
});

fixtures.map(fixture => {
test(fixture.name, async () => {
const fastify = buildFastify({ maxParamLength: 32_768 });
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 0da1813

Please sign in to comment.