diff --git a/api/src/api/schemas.ts b/api/src/api/schemas.ts index 526ae9a..d873e82 100644 --- a/api/src/api/schemas.ts +++ b/api/src/api/schemas.ts @@ -309,7 +309,6 @@ const RuneDetailResponseSchema = Type.Object({ { id: RuneIdResponseSchema, name: RuneNameResponseSchema, - // number: RuneNumberResponseSchema, spaced_name: RuneSpacedNameResponseSchema, }, { title: 'Rune detail', description: 'Details of the rune affected by this activity' } diff --git a/api/tests/api/api.test.ts b/api/tests/api/api.test.ts index 6c21bfc..345450c 100644 --- a/api/tests/api/api.test.ts +++ b/api/tests/api/api.test.ts @@ -1,15 +1,14 @@ import { ENV } from '../../src/env'; import { PgStore } from '../../src/pg/pg-store'; -import { DbLedgerEntry } from '../../src/pg/types'; import { dropDatabase, - insertDbEntry, + insertDbLedgerEntry, insertRune, sampleRune, runMigrations, startTestApiServer, TestFastifyServer, - insertSupply, + insertSupplyChange, sampleLedgerEntry, } from '../helpers'; @@ -27,8 +26,8 @@ describe('Etchings', () => { await runMigrations(db); await insertRune(db, rune); const event_index = 0; - await insertDbEntry(db, ledgerEntry, event_index); - await insertSupply(db, rune.id, 1); + await insertDbLedgerEntry(db, ledgerEntry, event_index); + await insertSupplyChange(db, rune.id, 1); }); afterEach(async () => { @@ -41,6 +40,40 @@ describe('Etchings', () => { }); test('lists runes', async () => { + const expected = { + divisibility: 0, + id: '1:1', + location: { + block_hash: '0000000000000000000320283a032748cef8227873ff4872689bf23f1cda83a5', + block_height: 840000, + timestamp: 0, + tx_id: '2bb85f4b004be6da54f766c17c1e855187327112c231ef2ff35ebad0ea67c69e', + tx_index: 1, + }, + mint_terms: { + amount: '100', + cap: '5000000', + height_end: null, + height_start: null, + offset_end: null, + offset_start: null, + }, + name: 'Sample Rune', + number: 1, + spaced_name: 'Sample•Rune', + supply: { + burned: '0', + current: '0', + mint_percentage: '0.0000', + mintable: false, + minted: '0', + premine: '0', + total_burns: '0', + total_mints: '0', + }, + symbol: 'ᚠ', + turbo: false, + }; const runesResponse = await fastify.inject({ method: 'GET', url: '/runes/v1/etchings', @@ -53,8 +86,9 @@ describe('Etchings', () => { url: '/runes/v1/etchings/' + ledgerEntry.rune_id, }); expect(response.statusCode).toBe(200); - expect(response.json().name).toEqual(rune.name); + expect(response.json()).toStrictEqual(expected); }); + test('can fetch by spaced name', async () => { const url = '/runes/v1/etchings/' + rune.spaced_name; const response = await fastify.inject({ @@ -64,6 +98,7 @@ describe('Etchings', () => { expect(response.statusCode).toBe(200); expect(response.json().spaced_name).toEqual(rune.spaced_name); }); + test('can not fetch by spaced name if lacking bullets', async () => { const url = '/runes/v1/etchings/' + rune.spaced_name.replaceAll('•', '-'); const response = await fastify.inject({ diff --git a/api/tests/helpers.ts b/api/tests/helpers.ts index 4061416..baf74ce 100644 --- a/api/tests/helpers.ts +++ b/api/tests/helpers.ts @@ -80,7 +80,7 @@ function toSpacedName(name: string | null): string | null { export function sampleRune(id: string, name?: string): DbRune { return { id: '1:1', - name: name || 'SAMPLE RUNE NAME', + name: name || 'SAMPLERUNENAME', spaced_name: (name && toSpacedName(name)) || 'SAMPLE•RUNE•NAME', number: 1, block_hash: '0000000000000000000320283a032748cef8227873ff4872689bf23f1cda83a5', @@ -107,7 +107,7 @@ export function sampleRune(id: string, name?: string): DbRune { }; } -export async function insertDbEntry( +export async function insertDbLedgerEntry( db: PgStore, payload: DbLedgerEntry, event_index: number @@ -139,7 +139,7 @@ export async function insertDbEntry( }); } -export async function insertSupply( +export async function insertSupplyChange( db: PgStore, rune_id: string, block_height: number,