From 4b0c2c48a07e8b2705595c7b49b4867f3d580a8c Mon Sep 17 00:00:00 2001 From: Rob Konsdorf Date: Thu, 8 Oct 2026 15:08:23 -0400 Subject: [PATCH] test(filler): share one mock module loader across the handler tests Each of 25 handler test files defined its own copy of the mock module loader, and the handler test helper held one more copy that it did not export. All 26 bodies were the same, so a change to the loader had to land in 26 places. The helper now exports the loader and the test files import it. No test observes a different value. Signed-off-by: Rob Konsdorf --- .../float-repair.integration.test.ts | 12 +---------- .../processors/assets.integration.test.ts | 19 +++++------------ .../collections.integration.test.ts | 15 +++---------- .../processors/config.integration.test.ts | 15 +++---------- .../processors/logs.integration.test.ts | 17 ++++----------- .../processors/offers.integration.test.ts | 19 +++++------------ .../processors/schemas.integration.test.ts | 15 +++---------- .../processors/templates.integration.test.ts | 15 +++---------- .../processors/claims.integration.test.ts | 17 ++++----------- .../processors/drops.integration.test.ts | 17 ++++----------- .../processors/auctions.integration.test.ts | 21 ++++++------------- .../atomicmarket/processors/auctions.test.ts | 11 +--------- .../processors/buyoffers.integration.test.ts | 19 +++++------------ .../atomicmarket/processors/buyoffers.test.ts | 11 +--------- .../processors/config.integration.test.ts | 15 +++---------- .../processors/royalties.integration.test.ts | 17 ++++----------- .../processors/sales.integration.test.ts | 19 +++++------------ .../atomicmarket/processors/sales.test.ts | 11 +--------- .../processors/claims.integration.test.ts | 19 +++++------------ .../processors/packs.integration.test.ts | 15 +++---------- .../processors/rolls.integration.test.ts | 17 ++++----------- .../processors/assets.integration.test.ts | 17 ++++----------- .../processors/authors.integration.test.ts | 13 ++---------- .../processors/bridge.integration.test.ts | 17 ++++----------- .../snapshot-import.integration.test.ts | 12 +---------- src/filler/handlers/test-helper.ts | 2 +- 26 files changed, 85 insertions(+), 312 deletions(-) diff --git a/src/filler/handlers/atomicassets/float-repair.integration.test.ts b/src/filler/handlers/atomicassets/float-repair.integration.test.ts index 11a18949..2a10d1e6 100644 --- a/src/filler/handlers/atomicassets/float-repair.integration.test.ts +++ b/src/filler/handlers/atomicassets/float-repair.integration.test.ts @@ -3,9 +3,8 @@ import { expect } from 'chai'; import { Client, Pool } from 'pg'; import { getTestPostgresConfig } from '../../../utils/test'; -import { createMockNotifier } from '../test-helper'; +import { createMockNotifier, createMockModuleLoader } from '../test-helper'; import DataProcessor, { ProcessingState } from '../../processor'; -import { ModuleLoader } from '../../modules'; import AtomicAssetsHandler from './index'; import { clearFloatRepairState, @@ -95,15 +94,6 @@ const ASSETS: AssetSeed[] = [ }, ]; -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - override private field - loader.modules = []; - // @ts-ignore - override readonly field - loader.names = []; - return loader; -} - describe('atomicassets float attribute repair', () => { let client: Client; let pool: Pool; diff --git a/src/filler/handlers/atomicassets/processors/assets.integration.test.ts b/src/filler/handlers/atomicassets/processors/assets.integration.test.ts index 5995b076..c34f7bc5 100644 --- a/src/filler/handlers/atomicassets/processors/assets.integration.test.ts +++ b/src/filler/handlers/atomicassets/processors/assets.integration.test.ts @@ -2,13 +2,14 @@ import 'mocha'; import { expect } from 'chai'; import { Client } from 'pg'; import { - createProcessorTestContext, - createMockNotifier, + createActionTrace, createBlock, + createMockModuleLoader, + createMockNotifier, + createProcessorTestContext, + createTestTransaction, createTx, - createActionTrace, processActionTrace, - createTestTransaction, } from '../../test-helper'; import { assetProcessor } from './assets'; import DataProcessor, { ProcessingState } from '../../../processor'; @@ -20,7 +21,6 @@ import { LogTransferActionData, LogBackAssetActionData, } from '../types/actions'; -import { ModuleLoader } from '../../../modules'; import { eosioTimestampToDate } from '../../../../utils/eosio'; const CONTRACT = 'atomicassets'; @@ -42,15 +42,6 @@ function createMockCore(overrides: Record = {}): any { }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - describe('assetProcessor', () => { let client: Client; let processor: DataProcessor; diff --git a/src/filler/handlers/atomicassets/processors/collections.integration.test.ts b/src/filler/handlers/atomicassets/processors/collections.integration.test.ts index 90085c13..e5044634 100644 --- a/src/filler/handlers/atomicassets/processors/collections.integration.test.ts +++ b/src/filler/handlers/atomicassets/processors/collections.integration.test.ts @@ -4,16 +4,16 @@ import { Client } from 'pg'; import { serialize, ObjectSchema } from '@atomichub/atomicassets'; import type { CollectionsTableRow } from '@atomichub/atomicassets'; import { - createProcessorTestContext, createBlock, createContractRow, - processContractRow, + createMockModuleLoader, + createProcessorTestContext, createTestTransaction, + processContractRow, } from '../../test-helper'; import { collectionProcessor } from './collections'; import DataProcessor, { ProcessingState } from '../../../processor'; import { ContractDBTransaction } from '../../../database'; -import { ModuleLoader } from '../../../modules'; const CONTRACT = 'atomicassets'; @@ -42,15 +42,6 @@ function createMockCore(overrides: Record = {}): any { }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - /** * Serialize collection data into the byte format expected by the AtomicAssets contract. */ diff --git a/src/filler/handlers/atomicassets/processors/config.integration.test.ts b/src/filler/handlers/atomicassets/processors/config.integration.test.ts index 342c2b09..819eb8f7 100644 --- a/src/filler/handlers/atomicassets/processors/config.integration.test.ts +++ b/src/filler/handlers/atomicassets/processors/config.integration.test.ts @@ -2,17 +2,17 @@ import 'mocha'; import { expect } from 'chai'; import { Client } from 'pg'; import { - createProcessorTestContext, createBlock, createContractRow, - processContractRow, + createMockModuleLoader, + createProcessorTestContext, createTestTransaction, + processContractRow, } from '../../test-helper'; import { configProcessor } from './config'; import DataProcessor, { ProcessingState } from '../../../processor'; import { ContractDBTransaction } from '../../../database'; import type { TokenConfigsTableRow } from '@atomichub/atomicassets'; -import { ModuleLoader } from '../../../modules'; const CONTRACT = 'atomicassets'; @@ -37,15 +37,6 @@ function createMockCore(overrides: Record = {}): any { }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - async function seedConfigRow(client: Client, markerBlock: number | null = null): Promise { await client.query( 'INSERT INTO atomicassets_config (contract, version, collection_format, v2_marker_block) ' + diff --git a/src/filler/handlers/atomicassets/processors/logs.integration.test.ts b/src/filler/handlers/atomicassets/processors/logs.integration.test.ts index 85c5569e..dc34b02f 100644 --- a/src/filler/handlers/atomicassets/processors/logs.integration.test.ts +++ b/src/filler/handlers/atomicassets/processors/logs.integration.test.ts @@ -4,12 +4,13 @@ import { Client } from 'pg'; import { serialize, ObjectSchema } from '@atomichub/atomicassets'; import type { AuthorSwapsTableRow, CollectionsTableRow } from '@atomichub/atomicassets'; import { - createProcessorTestContext, - createBlock, - createTx, createActionTrace, + createBlock, createContractRow, + createMockModuleLoader, + createProcessorTestContext, createTestTransaction, + createTx, } from '../../test-helper'; import { collectionProcessor } from './collections'; import { logProcessor } from './logs'; @@ -22,7 +23,6 @@ import { LogRamPayerActionData, } from '../types/actions'; import { EosioActionTrace } from '../../../../types/eosio'; -import { ModuleLoader } from '../../../modules'; const CONTRACT = 'atomicassets'; @@ -48,15 +48,6 @@ function createMockCore(overrides: Record = {}): any { }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - function serializeCollectionData(data: Record): number[] { const schema = ObjectSchema(COLLECTION_FORMAT); return Array.from(serialize(data, schema)); diff --git a/src/filler/handlers/atomicassets/processors/offers.integration.test.ts b/src/filler/handlers/atomicassets/processors/offers.integration.test.ts index ab1de399..f6477692 100644 --- a/src/filler/handlers/atomicassets/processors/offers.integration.test.ts +++ b/src/filler/handlers/atomicassets/processors/offers.integration.test.ts @@ -2,13 +2,14 @@ import 'mocha'; import { expect } from 'chai'; import { Client } from 'pg'; import { - createProcessorTestContext, - createMockNotifier, + createActionTrace, createBlock, + createMockModuleLoader, + createMockNotifier, + createProcessorTestContext, + createTestTransaction, createTx, - createActionTrace, processActionTrace, - createTestTransaction, } from '../../test-helper'; import { offerProcessor } from './offers'; import DataProcessor, { ProcessingState } from '../../../processor'; @@ -21,7 +22,6 @@ import { CancelOfferActionData, LogTransferActionData, } from '../types/actions'; -import { ModuleLoader } from '../../../modules'; const CONTRACT = 'atomicassets'; @@ -36,15 +36,6 @@ function createMockCore(overrides: Record = {}): any { }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - describe('offerProcessor', () => { let client: Client; let processor: DataProcessor; diff --git a/src/filler/handlers/atomicassets/processors/schemas.integration.test.ts b/src/filler/handlers/atomicassets/processors/schemas.integration.test.ts index a1693671..a4bd01af 100644 --- a/src/filler/handlers/atomicassets/processors/schemas.integration.test.ts +++ b/src/filler/handlers/atomicassets/processors/schemas.integration.test.ts @@ -2,17 +2,17 @@ import 'mocha'; import { expect } from 'chai'; import { Client } from 'pg'; import { - createProcessorTestContext, createBlock, createContractRow, - processContractRow, + createMockModuleLoader, + createProcessorTestContext, createTestTransaction, + processContractRow, } from '../../test-helper'; import { schemaProcessor } from './schemas'; import DataProcessor, { ProcessingState } from '../../../processor'; import { ContractDBTransaction } from '../../../database'; import { SchemaTypesTableRow, SchemasTableRow } from '@atomichub/atomicassets'; -import { ModuleLoader } from '../../../modules'; const CONTRACT = 'atomicassets'; const COLLECTION = 'schemacol111'; @@ -35,15 +35,6 @@ function createMockCore(overrides: Record = {}): any { }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - describe('schemaProcessor', () => { let client: Client; let processor: DataProcessor; diff --git a/src/filler/handlers/atomicassets/processors/templates.integration.test.ts b/src/filler/handlers/atomicassets/processors/templates.integration.test.ts index 7cd783b7..7a4af6ab 100644 --- a/src/filler/handlers/atomicassets/processors/templates.integration.test.ts +++ b/src/filler/handlers/atomicassets/processors/templates.integration.test.ts @@ -4,16 +4,16 @@ import { Client } from 'pg'; import { serialize, ObjectSchema } from '@atomichub/atomicassets'; import type { MutableTemplatesTableRow, TemplatesTableRow } from '@atomichub/atomicassets'; import { - createProcessorTestContext, createBlock, createContractRow, - processContractRow, + createMockModuleLoader, + createProcessorTestContext, createTestTransaction, + processContractRow, } from '../../test-helper'; import { templateProcessor } from './templates'; import DataProcessor, { ProcessingState } from '../../../processor'; import { ContractDBTransaction } from '../../../database'; -import { ModuleLoader } from '../../../modules'; import { eosioTimestampToDate } from '../../../../utils/eosio'; const CONTRACT = 'atomicassets'; @@ -43,15 +43,6 @@ function createMockCore(overrides: Record = {}): any { }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - /** * Serialize template mutable/immutable data into the contract byte format. */ diff --git a/src/filler/handlers/atomicdropsx/processors/claims.integration.test.ts b/src/filler/handlers/atomicdropsx/processors/claims.integration.test.ts index aff02310..800b5eb7 100644 --- a/src/filler/handlers/atomicdropsx/processors/claims.integration.test.ts +++ b/src/filler/handlers/atomicdropsx/processors/claims.integration.test.ts @@ -3,14 +3,14 @@ import { expect } from 'chai'; import { Client } from 'pg'; import { - createProcessorTestContext, + createActionTrace, createBlock, + createMockModuleLoader, + createProcessorTestContext, + createTestTransaction, createTx, - createActionTrace, processActionTrace, - createTestTransaction, } from '../../test-helper'; -import { ModuleLoader } from '../../../modules'; import DataProcessor, { ProcessingState } from '../../../processor'; import { ContractDBTransaction } from '../../../database'; @@ -36,15 +36,6 @@ function createMockCore(overrides: Record = {}): any { }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - test-only construction matches atomicmarket pattern. - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - async function seedDrop(client: Client, dropId: string, listingPrice = '5000000000'): Promise { await client.query( `INSERT INTO atomicdropsx_drops ( diff --git a/src/filler/handlers/atomicdropsx/processors/drops.integration.test.ts b/src/filler/handlers/atomicdropsx/processors/drops.integration.test.ts index 063f864e..d4661697 100644 --- a/src/filler/handlers/atomicdropsx/processors/drops.integration.test.ts +++ b/src/filler/handlers/atomicdropsx/processors/drops.integration.test.ts @@ -3,14 +3,14 @@ import { expect } from 'chai'; import { Client } from 'pg'; import { - createProcessorTestContext, + createActionTrace, createBlock, + createMockModuleLoader, + createProcessorTestContext, + createTestTransaction, createTx, - createActionTrace, processActionTrace, - createTestTransaction, } from '../../test-helper'; -import { ModuleLoader } from '../../../modules'; import DataProcessor, { ProcessingState } from '../../../processor'; import { ContractDBTransaction } from '../../../database'; @@ -38,15 +38,6 @@ function createMockCore(overrides: Record = {}): any { }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - test-only construction matches atomicmarket pattern. - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - /** Minimal lognewdrop payload - tests override fields they care about. */ function buildLogNewDrop(overrides: Partial & { drop_id: string }): LogNewDropActionData { return { diff --git a/src/filler/handlers/atomicmarket/processors/auctions.integration.test.ts b/src/filler/handlers/atomicmarket/processors/auctions.integration.test.ts index a6c0d676..68dc67b5 100644 --- a/src/filler/handlers/atomicmarket/processors/auctions.integration.test.ts +++ b/src/filler/handlers/atomicmarket/processors/auctions.integration.test.ts @@ -2,15 +2,16 @@ import 'mocha'; import { expect } from 'chai'; import { Client } from 'pg'; import { - createProcessorTestContext, - createMockNotifier, - createBlock, - createTx, createActionTrace, + createBlock, createContractRow, + createMockModuleLoader, + createMockNotifier, + createProcessorTestContext, + createTestTransaction, + createTx, processActionTrace, processContractRow, - createTestTransaction, } from '../../test-helper'; import { auctionProcessor } from './auctions'; import DataProcessor, { ProcessingState } from '../../../processor'; @@ -25,7 +26,6 @@ import { AuctionClaimSellerActionData, } from '../types/actions'; import { AuctionsTableRow } from '../types/tables'; -import { ModuleLoader } from '../../../modules'; const MARKET_CONTRACT = 'atomicmarket'; const ASSETS_CONTRACT = 'atomicassets'; @@ -47,15 +47,6 @@ function createMockCore(overrides: Record = {}, version?: string): }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - describe('auctionProcessor', () => { let client: Client; let processor: DataProcessor; diff --git a/src/filler/handlers/atomicmarket/processors/auctions.test.ts b/src/filler/handlers/atomicmarket/processors/auctions.test.ts index 388c5389..15eaaf40 100644 --- a/src/filler/handlers/atomicmarket/processors/auctions.test.ts +++ b/src/filler/handlers/atomicmarket/processors/auctions.test.ts @@ -4,6 +4,7 @@ import { expect } from 'chai'; import { createActionTrace, createBlock, + createMockModuleLoader, createRecordingNotifier, createStubTransaction, createTx, @@ -11,7 +12,6 @@ import { StubTransaction, } from '../../test-helper'; import DataProcessor, { ProcessingState } from '../../../processor'; -import { ModuleLoader } from '../../../modules'; import { auctionProcessor } from './auctions'; import { AuctionState } from '../index'; import { AuctionBidActionData } from '../types/actions'; @@ -19,15 +19,6 @@ import { AuctionBidActionData } from '../types/actions'; const MARKET_CONTRACT = 'atomicmarket'; const ASSETS_CONTRACT = 'atomicassets'; -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - function createMockCore(version: string): any { return { args: { diff --git a/src/filler/handlers/atomicmarket/processors/buyoffers.integration.test.ts b/src/filler/handlers/atomicmarket/processors/buyoffers.integration.test.ts index f7fffc07..a9ba6ade 100644 --- a/src/filler/handlers/atomicmarket/processors/buyoffers.integration.test.ts +++ b/src/filler/handlers/atomicmarket/processors/buyoffers.integration.test.ts @@ -2,13 +2,14 @@ import 'mocha'; import { expect } from 'chai'; import { Client } from 'pg'; import { - createProcessorTestContext, - createMockNotifier, + createActionTrace, createBlock, + createMockModuleLoader, + createMockNotifier, + createProcessorTestContext, + createTestTransaction, createTx, - createActionTrace, processActionTrace, - createTestTransaction, } from '../../test-helper'; import { buyofferProcessor } from './buyoffers'; import DataProcessor, { ProcessingState } from '../../../processor'; @@ -19,7 +20,6 @@ import { DeclineBuyofferActionData, LogNewBuyofferActionData, } from '../types/actions'; -import { ModuleLoader } from '../../../modules'; const MARKET_CONTRACT = 'atomicmarket'; const ASSETS_CONTRACT = 'atomicassets'; @@ -41,15 +41,6 @@ function createMockCore(overrides: Record = {}, version?: string): }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - describe('buyofferProcessor', () => { let client: Client; let processor: DataProcessor; diff --git a/src/filler/handlers/atomicmarket/processors/buyoffers.test.ts b/src/filler/handlers/atomicmarket/processors/buyoffers.test.ts index c98eb75d..fa3ffd06 100644 --- a/src/filler/handlers/atomicmarket/processors/buyoffers.test.ts +++ b/src/filler/handlers/atomicmarket/processors/buyoffers.test.ts @@ -4,6 +4,7 @@ import { expect } from 'chai'; import { createActionTrace, createBlock, + createMockModuleLoader, createRecordingNotifier, createStubTransaction, createTx, @@ -11,7 +12,6 @@ import { StubTransaction, } from '../../test-helper'; import DataProcessor, { ProcessingState } from '../../../processor'; -import { ModuleLoader } from '../../../modules'; import { buyofferProcessor } from './buyoffers'; import { BuyofferState } from '../index'; import { AcceptBuyofferActionData } from '../types/actions'; @@ -19,15 +19,6 @@ import { AcceptBuyofferActionData } from '../types/actions'; const MARKET_CONTRACT = 'atomicmarket'; const ASSETS_CONTRACT = 'atomicassets'; -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - function createMockCore(version: string): any { return { args: { diff --git a/src/filler/handlers/atomicmarket/processors/config.integration.test.ts b/src/filler/handlers/atomicmarket/processors/config.integration.test.ts index 908b81dd..ddb3229f 100644 --- a/src/filler/handlers/atomicmarket/processors/config.integration.test.ts +++ b/src/filler/handlers/atomicmarket/processors/config.integration.test.ts @@ -2,32 +2,23 @@ import 'mocha'; import { expect } from 'chai'; import { Client } from 'pg'; import { - createProcessorTestContext, createBlock, createContractRow, - processContractRow, + createMockModuleLoader, + createProcessorTestContext, createTestTransaction, + processContractRow, } from '../../test-helper'; import { configProcessor } from './config'; import DataProcessor, { ProcessingState } from '../../../processor'; import { ContractDBTransaction } from '../../../database'; import { ConfigTableRow } from '../types/tables'; import { marketDissolvesBundles } from '../legacy-bundles'; -import { ModuleLoader } from '../../../modules'; const MARKET_CONTRACT = 'atomicmarket'; const READER_NAME = 'test-reader'; const ASSETS_CONTRACT = 'atomicassets'; -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - function createConfigValue(version: string): ConfigTableRow { return { sale_counter: '0', diff --git a/src/filler/handlers/atomicmarket/processors/royalties.integration.test.ts b/src/filler/handlers/atomicmarket/processors/royalties.integration.test.ts index f39072cc..58670fbe 100644 --- a/src/filler/handlers/atomicmarket/processors/royalties.integration.test.ts +++ b/src/filler/handlers/atomicmarket/processors/royalties.integration.test.ts @@ -2,13 +2,14 @@ import 'mocha'; import { expect } from 'chai'; import { Client } from 'pg'; import { - createProcessorTestContext, + createActionTrace, createBlock, + createMockModuleLoader, + createProcessorTestContext, + createTestTransaction, createTx, - createActionTrace, processActionTrace, processContractRow, - createTestTransaction, } from '../../test-helper'; import { royaltyProcessor } from './royalties'; import { logProcessor } from './logs'; @@ -22,7 +23,6 @@ import { LogRoyaltyTemplateActionData, } from '../types/actions'; import { RoyaltyAttrTableRow, RoyaltyConfTableRow, RoyaltyTempTableRow } from '../types/tables'; -import { ModuleLoader } from '../../../modules'; const MARKET_CONTRACT = 'atomicmarket'; const ASSETS_CONTRACT = 'atomicassets'; @@ -39,15 +39,6 @@ function createMockCore(overrides: Record = {}): any { }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - describe('royaltyProcessor', () => { let client: Client; let processor: DataProcessor; diff --git a/src/filler/handlers/atomicmarket/processors/sales.integration.test.ts b/src/filler/handlers/atomicmarket/processors/sales.integration.test.ts index 7e13e248..353f74f0 100644 --- a/src/filler/handlers/atomicmarket/processors/sales.integration.test.ts +++ b/src/filler/handlers/atomicmarket/processors/sales.integration.test.ts @@ -2,13 +2,14 @@ import 'mocha'; import { expect } from 'chai'; import { Client } from 'pg'; import { - createProcessorTestContext, - createMockNotifier, + createActionTrace, createBlock, + createMockModuleLoader, + createMockNotifier, + createProcessorTestContext, + createTestTransaction, createTx, - createActionTrace, processActionTrace, - createTestTransaction, } from '../../test-helper'; import { saleProcessor } from './sales'; import DataProcessor, { ProcessingState } from '../../../processor'; @@ -20,7 +21,6 @@ import { CancelSaleActionData, PurchaseSaleActionData, } from '../types/actions'; -import { ModuleLoader } from '../../../modules'; const MARKET_CONTRACT = 'atomicmarket'; const ASSETS_CONTRACT = 'atomicassets'; @@ -42,15 +42,6 @@ function createMockCore(overrides: Record = {}, version?: string): }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - describe('saleProcessor', () => { let client: Client; let processor: DataProcessor; diff --git a/src/filler/handlers/atomicmarket/processors/sales.test.ts b/src/filler/handlers/atomicmarket/processors/sales.test.ts index 37ba840d..b10fee80 100644 --- a/src/filler/handlers/atomicmarket/processors/sales.test.ts +++ b/src/filler/handlers/atomicmarket/processors/sales.test.ts @@ -4,6 +4,7 @@ import { expect } from 'chai'; import { createActionTrace, createBlock, + createMockModuleLoader, createRecordingNotifier, createStubTransaction, createTx, @@ -11,7 +12,6 @@ import { StubTransaction, } from '../../test-helper'; import DataProcessor, { ProcessingState } from '../../../processor'; -import { ModuleLoader } from '../../../modules'; import { saleProcessor } from './sales'; import { SaleState } from '../index'; import { PurchaseSaleActionData } from '../types/actions'; @@ -21,15 +21,6 @@ const ASSETS_CONTRACT = 'atomicassets'; const OFFER_ID = '999001'; const LISTING_PRICE = '100000'; -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - function createMockCore(version: string | null, overrides: Record = {}): any { return { args: { diff --git a/src/filler/handlers/atomicpacksx/processors/claims.integration.test.ts b/src/filler/handlers/atomicpacksx/processors/claims.integration.test.ts index aa799493..4ef775a6 100644 --- a/src/filler/handlers/atomicpacksx/processors/claims.integration.test.ts +++ b/src/filler/handlers/atomicpacksx/processors/claims.integration.test.ts @@ -3,16 +3,16 @@ import { expect } from 'chai'; import { Client } from 'pg'; import { - createProcessorTestContext, - createBlock, - createTx, createActionTrace, + createBlock, createContractRow, + createMockModuleLoader, + createProcessorTestContext, + createTestTransaction, + createTx, processActionTrace, processContractRow, - createTestTransaction, } from '../../test-helper'; -import { ModuleLoader } from '../../../modules'; import DataProcessor, { ProcessingState } from '../../../processor'; import { ContractDBTransaction } from '../../../database'; @@ -35,15 +35,6 @@ function createMockCore(overrides: Record = {}): any { }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - test-only construction matches atomicmarket pattern. - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - async function seedPack(client: Client, packId: string): Promise { await client.query( `INSERT INTO atomicpacksx_packs ( diff --git a/src/filler/handlers/atomicpacksx/processors/packs.integration.test.ts b/src/filler/handlers/atomicpacksx/processors/packs.integration.test.ts index 123887f3..750cb865 100644 --- a/src/filler/handlers/atomicpacksx/processors/packs.integration.test.ts +++ b/src/filler/handlers/atomicpacksx/processors/packs.integration.test.ts @@ -3,13 +3,13 @@ import { expect } from 'chai'; import { Client } from 'pg'; import { - createProcessorTestContext, createBlock, createContractRow, - processContractRow, + createMockModuleLoader, + createProcessorTestContext, createTestTransaction, + processContractRow, } from '../../test-helper'; -import { ModuleLoader } from '../../../modules'; import DataProcessor, { ProcessingState } from '../../../processor'; import { ContractDBTransaction } from '../../../database'; @@ -30,15 +30,6 @@ function createMockCore(overrides: Record = {}): any { }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - test-only construction matches atomicmarket pattern. - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - function packsRow(overrides: Partial = {}): PacksTableRow { return { pack_id: '5001', diff --git a/src/filler/handlers/atomicpacksx/processors/rolls.integration.test.ts b/src/filler/handlers/atomicpacksx/processors/rolls.integration.test.ts index 436e5e3a..c98bb75f 100644 --- a/src/filler/handlers/atomicpacksx/processors/rolls.integration.test.ts +++ b/src/filler/handlers/atomicpacksx/processors/rolls.integration.test.ts @@ -3,14 +3,14 @@ import { expect } from 'chai'; import { Client } from 'pg'; import { - createProcessorTestContext, + createActionTrace, createBlock, + createMockModuleLoader, + createProcessorTestContext, + createTestTransaction, createTx, - createActionTrace, processActionTrace, - createTestTransaction, } from '../../test-helper'; -import { ModuleLoader } from '../../../modules'; import DataProcessor, { ProcessingState } from '../../../processor'; import { ContractDBTransaction } from '../../../database'; @@ -34,15 +34,6 @@ function createMockCore(overrides: Record = {}): any { }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - test-only construction matches atomicmarket pattern. - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - /** * pack_rolls FK references atomicpacksx_packs(contract, pack_id) so every * test must seed a parent pack row first. diff --git a/src/filler/handlers/simpleassets/processors/assets.integration.test.ts b/src/filler/handlers/simpleassets/processors/assets.integration.test.ts index 48d9261f..f9f6d422 100644 --- a/src/filler/handlers/simpleassets/processors/assets.integration.test.ts +++ b/src/filler/handlers/simpleassets/processors/assets.integration.test.ts @@ -3,17 +3,17 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; import { Client } from 'pg'; import { - createProcessorTestContext, - createBlock, - createTx, createActionTrace, + createBlock, + createMockModuleLoader, + createProcessorTestContext, createTestTransaction, + createTx, } from '../../test-helper'; import { assetProcessor } from './assets'; import SimpleAssetsHandler from '../index'; import DataProcessor, { ProcessingState } from '../../../processor'; import { ContractDBTransaction } from '../../../database'; -import { ModuleLoader } from '../../../modules'; import { ShipBlock } from '../../../../types/ship'; import logger from '../../../../utils/winston'; @@ -33,15 +33,6 @@ function createMockCore(overrides: Record = {}): any { }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - function blockAt(blockNum: number): ShipBlock { return createBlock({ block_num: blockNum }); } diff --git a/src/filler/handlers/simpleassets/processors/authors.integration.test.ts b/src/filler/handlers/simpleassets/processors/authors.integration.test.ts index 31f21d85..a8ccd38a 100644 --- a/src/filler/handlers/simpleassets/processors/authors.integration.test.ts +++ b/src/filler/handlers/simpleassets/processors/authors.integration.test.ts @@ -2,28 +2,19 @@ import 'mocha'; import { expect } from 'chai'; import { Client } from 'pg'; import { - createProcessorTestContext, createBlock, createContractRow, + createMockModuleLoader, + createProcessorTestContext, createTestTransaction, processContractRow, } from '../../test-helper'; import { authorProcessor } from './authors'; import DataProcessor, { ProcessingState } from '../../../processor'; import { ContractDBTransaction } from '../../../database'; -import { ModuleLoader } from '../../../modules'; const CONTRACT = 'simpleassets'; -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - function authorRow(dappinfo: Record): Record { return { author: 'gpk.topps', diff --git a/src/filler/handlers/simpleassets/processors/bridge.integration.test.ts b/src/filler/handlers/simpleassets/processors/bridge.integration.test.ts index b0d0c505..33b59929 100644 --- a/src/filler/handlers/simpleassets/processors/bridge.integration.test.ts +++ b/src/filler/handlers/simpleassets/processors/bridge.integration.test.ts @@ -3,18 +3,18 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; import { Client } from 'pg'; import { - createProcessorTestContext, - createBlock, - createTx, createActionTrace, + createBlock, + createMockModuleLoader, + createProcessorTestContext, createTestTransaction, + createTx, } from '../../test-helper'; import { assetProcessor } from './assets'; import { bridgeProcessor } from './bridge'; import SimpleAssetsHandler from '../index'; import DataProcessor, { ProcessingState } from '../../../processor'; import { ContractDBTransaction } from '../../../database'; -import { ModuleLoader } from '../../../modules'; import { EosioActionTrace } from '../../../../types/eosio'; import logger from '../../../../utils/winston'; @@ -38,15 +38,6 @@ function createMockCore(overrides: Record = {}): any { }; } -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - // The attribute map form a logmint trace carries after ABI deserialization. function logmintTrace(assetId: string, overrides: Record = {}): EosioActionTrace { const immutable = 'sassets_id' in overrides diff --git a/src/filler/handlers/simpleassets/snapshot-import.integration.test.ts b/src/filler/handlers/simpleassets/snapshot-import.integration.test.ts index c130f7de..951d78c3 100644 --- a/src/filler/handlers/simpleassets/snapshot-import.integration.test.ts +++ b/src/filler/handlers/simpleassets/snapshot-import.integration.test.ts @@ -6,11 +6,10 @@ import * as os from 'os'; import * as path from 'path'; import { Client } from 'pg'; import { getTestPostgresConfig } from '../../../utils/test'; -import { createBlock, createTx, createActionTrace, createTestTransaction } from '../test-helper'; +import { createBlock, createTx, createActionTrace, createTestTransaction, createMockModuleLoader } from '../test-helper'; import { importSimpleAssetsSnapshot, runSnapshotImport, SnapshotImportOptions } from './snapshot-import'; import { assetProcessor } from './processors/assets'; import DataProcessor, { ProcessingState } from '../../processor'; -import { ModuleLoader } from '../../modules'; import logger from '../../../utils/winston'; const SA = 'simpleassets'; @@ -32,15 +31,6 @@ const AA_ASSETS: AaAsset[] = [ { id: '1099511627005', minter: BRIDGE, block: S - 5 }, ]; -function createMockModuleLoader(): ModuleLoader { - const loader = Object.create(ModuleLoader.prototype) as ModuleLoader; - // @ts-ignore - loader.modules = []; - // @ts-ignore - loader.names = []; - return loader; -} - describe('simpleassets snapshot import', () => { let client: Client; let dir: string; diff --git a/src/filler/handlers/test-helper.ts b/src/filler/handlers/test-helper.ts index 0782fe24..a538b6c4 100644 --- a/src/filler/handlers/test-helper.ts +++ b/src/filler/handlers/test-helper.ts @@ -18,7 +18,7 @@ import { ModuleLoader } from '../modules'; // --------------------------------------------------------------------------- // Mock ModuleLoader that has no modules (nothing to filter) // --------------------------------------------------------------------------- -function createMockModuleLoader(): ModuleLoader { +export function createMockModuleLoader(): ModuleLoader { // ModuleLoader constructor tries to require() module files from disk. // We bypass this by creating a plain object that satisfies the interface. const loader = Object.create(ModuleLoader.prototype) as ModuleLoader;