Skip to content

Commit

Permalink
feat: add unit test for raw transactions with logs in receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
ponyjackal committed Jul 26, 2024
1 parent 668f10c commit 79ba08a
Show file tree
Hide file tree
Showing 4 changed files with 2,461 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/contextualizers/contextualizer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ import ensBulkRenew0x25add712 from './test/transactions/ensBulkRenew-0x25add712.
import skyoneerPlotAction0x9436b659 from './test/transactions/skyoneerPlotAction-0x9436b659.json';
import skyoneerPlotAction0x9bb5a737 from './test/transactions/skyoneerPlotAction-0x9bb5a737.json';
import skyoneerPlotAction0x496c6309 from './test/transactions/skyoneerPlotAction-0x496c6309.json';
// untransformed transactions
import registrarWithConfigRaw0x5d31a49e from './test/transactions/registrarWithConfig-raw-0x5d31a49e.json';
import ensRegistrarRaw0xb14b4771 from './test/transactions/ensRegistrar-raw-0xb14b4771.json';

describe('ContextualizerService', () => {
describe('Detect transactions correctly', () => {
Expand Down Expand Up @@ -255,5 +258,17 @@ describe('ContextualizerService', () => {
);
expect(plotAction3.context?.summaries?.en.title).toBe('Skyoneer');
});

it('Should detect raw transactions', () => {
const ens1 = contextualizer.contextualize(
ensRegistrarRaw0xb14b4771 as unknown as Transaction,
);
expect(ens1.context?.summaries?.en.title).toBe('ENS');

const ens2 = contextualizer.contextualize(
registrarWithConfigRaw0x5d31a49e as unknown as Transaction,
);
expect(ens2.context?.summaries?.en.title).toBe('ENS');
});
});
});
16 changes: 16 additions & 0 deletions src/contextualizers/protocol/ens/registrar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ens0xea1b4ab6 from '../../test/transactions/ens-0xea1b4ab6.json';
import ensBulkRenew0x25add712 from '../../test/transactions/ensBulkRenew-0x25add712.json';
import registrarWithConfig0x5d31a49e from '../../test/transactions/registrarWithConfig-0x5d31a49e.json';
import ensRegistrar0xb14b4771 from '../../test/transactions/ensRegistrar-0xb14b4771.json';
import ensRegistrarRaw0xb14b4771 from '../../test/transactions/ensRegistrar-raw-0xb14b4771.json';

describe('ENS Registrar', () => {
it('Should detect ens registrar', () => {
Expand All @@ -28,6 +29,11 @@ describe('ENS Registrar', () => {
ensRegistrar0xb14b4771 as unknown as Transaction,
);
expect(ensRegistrar3).toBe(true);

const ensRegistrar4 = detect(
ensRegistrarRaw0xb14b4771 as unknown as Transaction,
);
expect(ensRegistrar4).toBe(true);
});

it('Should generate ens context', () => {
Expand Down Expand Up @@ -81,6 +87,16 @@ describe('ENS Registrar', () => {
'0x53c40473dcdfd927c4201ccfe24e314a7d7c3584 REGISTERED lyricist.eth with an expiration of 2025-03-15',
);
expect(containsBigInt(registrar1.context)).toBe(false);

const registrar2 = generate(
ensRegistrarRaw0xb14b4771 as unknown as Transaction,
);
expect(registrar2.context?.summaries?.en.title).toBe('ENS');
const desc5 = contextSummary(registrar1.context);
expect(desc5).toBe(
'0x53c40473dcdfd927c4201ccfe24e314a7d7c3584 REGISTERED lyricist.eth with an expiration of 2025-03-15',
);
expect(containsBigInt(registrar2.context)).toBe(false);
});

it('Should not detect as ens registrar', () => {
Expand Down
Loading

0 comments on commit 79ba08a

Please sign in to comment.