import type { Address } from '@solana/kit'; import { getAtlasRewardConfigEncoder, getAtlasRewardRegistryEncoder, getAtlasRewardTreasuryEncoder, getKingSystemTrackerEncoder, getLoyaltyAtlasBankEncoder, getLoyaltyContributionEncoder, getLoyaltyEpochEncoder, } from '../src/generated/accounts'; import { findAtlasRewardConfigPda, findAtlasRewardTreasuryPda, findKingSystemTrackerPda, findLoyaltyAtlasBankPda, findLoyaltyContributionPda, findLoyaltyEpochPda, } from '../src/generated/pdas'; const game = 'C4SAgeKLgb3pTLWhVr6NRwWyYFuTR7ZeSXFrzoLwfMzF' as Address; const profile = '11111111111111111111111111111111' as Address; describe('ATLAS rewards generated surfaces', () => { it('keeps generated account codecs byte-exact with packed Rust layouts', () => { expect(getAtlasRewardConfigEncoder().fixedSize).toBe(1_610); expect(getAtlasRewardRegistryEncoder().fixedSize).toBe(126); expect(getKingSystemTrackerEncoder().fixedSize).toBe(363); expect( getAtlasRewardTreasuryEncoder().encode({ version: 0, bump: 0, gameId: game, reserves: new Map(), }).byteLength, ).toBe(46); expect(getLoyaltyEpochEncoder().fixedSize).toBe(156); expect(getLoyaltyContributionEncoder().fixedSize).toBe(148); expect(getLoyaltyAtlasBankEncoder().fixedSize).toBe(170); }); it('separates immutable config versions and epoch-scoped contributions', async () => { const [configV1] = await findAtlasRewardConfigPda({ gameId: game, configVersion: 1, }); const [configV2] = await findAtlasRewardConfigPda({ gameId: game, configVersion: 2, }); expect(configV1).not.toBe(configV2); const [tracker] = await findKingSystemTrackerPda({ gameId: game }); const [treasury] = await findAtlasRewardTreasuryPda({ gameId: game }); expect(tracker).not.toBe(treasury); const [epochMud] = await findLoyaltyEpochPda({ gameId: game, factionId: 1, epochIndex: 42, }); const [epochOni] = await findLoyaltyEpochPda({ gameId: game, factionId: 2, epochIndex: 42, }); expect(epochMud).not.toBe(epochOni); const [day42] = await findLoyaltyContributionPda({ gameId: game, profile, factionId: 1, epochIndex: 42, }); const [day43] = await findLoyaltyContributionPda({ gameId: game, profile, factionId: 1, epochIndex: 43, }); expect(day42).not.toBe(day43); const [bank] = await findLoyaltyAtlasBankPda({ gameId: game, profile, factionId: 1, }); expect(bank).not.toBe(day42); }); });