jest.mock('@steerprotocol/sdk', () => { const Protocol = { Algebra: 'Algebra', AlgebraIntegral: 'AlgebraIntegral', AlgebraIntegralV2: 'AlgebraIntegralV2', DirectionalAlgebra: 'DirectionalAlgebra', MachineX: 'MachineX', ThickV2: 'ThickV2', Shadow: 'Shadow', PoolShark: 'PoolShark', Aerodrome: 'Aerodrome', Blackhole: 'Blackhole', }; return { Protocol, ALGEBRA_PROTOCOLS: [Protocol.Algebra], ALGEBRA_INTEGRAL_PROTOCOLS: [Protocol.AlgebraIntegral], ALGEBRA_INTEGRAL_V_2_0_PROTOCOLS: [Protocol.AlgebraIntegralV2], DIRECTIONAL_ALGEBRA_PROTOCOLS: [Protocol.DirectionalAlgebra], POOLSHARK_PROTOCOLS: [Protocol.PoolShark], AERODROME_PROTOCOLS: [Protocol.Aerodrome], isShadowProtocol: jest.fn( (protocol: string) => protocol === Protocol.Shadow, ), getProtocolTypeByBeacon: jest.fn(), }; }); import { ProtocolDetector } from '../../src/factory/protocol-detector'; describe('Factory ProtocolDetector', () => { const sdk = require('@steerprotocol/sdk'); beforeEach(() => { sdk.getProtocolTypeByBeacon.mockReset(); }); it('detects algebra protocols', () => { const detector = new ProtocolDetector(); sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.Algebra); expect(detector.isAlgebraVault('beacon')).toBe(true); sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.AlgebraIntegral); expect(detector.isAlgebraIntegralVault('beacon')).toBe(true); sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.AlgebraIntegralV2); expect(detector.isAlgebraIntegral19Vault('beacon')).toBe(true); sdk.getProtocolTypeByBeacon.mockReturnValue( sdk.Protocol.DirectionalAlgebra, ); expect(detector.isAlgebraUniDirectionalVault('beacon')).toBe(true); }); it('detects machinex, thickv2, and blackhole', () => { const detector = new ProtocolDetector(); sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.MachineX); expect(detector.isMachineXV3Vault('beacon')).toBe(true); sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.ThickV2); expect(detector.isThickV2Vault('beacon')).toBe(true); sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.Blackhole); expect(detector.isBlackholeVault('beacon')).toBe(true); }); it('detects poolshark, aerodrome, and shadow', () => { const detector = new ProtocolDetector(); sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.PoolShark); expect(detector.isPoolSharkVault('beacon')).toBe(true); sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.Aerodrome); expect(detector.isAerodromeVault('beacon')).toBe(true); sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.Shadow); expect(detector.isShadowVault('beacon')).toBe(true); }); it('throws when protocol is missing', () => { const detector = new ProtocolDetector(); sdk.getProtocolTypeByBeacon.mockReturnValue(null); expect(() => detector.isAlgebraVault('beacon')).toThrow( 'Protocol not found', ); }); it('returns protocol via getProtocol', () => { const detector = new ProtocolDetector(); sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.Aerodrome); expect(detector.getProtocol('beacon')).toBe(sdk.Protocol.Aerodrome); }); });