UNPKG

@drift-labs/sdk

Version:
30 lines (26 loc) 850 B
import { describe, expect, test } from 'bun:test'; import { Keypair, PublicKey } from '@solana/web3.js'; import { DriftCore } from '../../src/core/DriftCore'; describe('DriftCore.pdas', () => { test('derives deterministic user/state PDAs', async () => { const programId = Keypair.generate().publicKey; const authority = Keypair.generate().publicKey; const [state] = await DriftCore.pdas.getDriftStateAccountPublicKeyAndNonce( programId ); const user0 = await DriftCore.pdas.getUserAccountPublicKey( programId, authority, 0 ); const user1 = await DriftCore.pdas.getUserAccountPublicKey( programId, authority, 1 ); expect(state).toBeInstanceOf(PublicKey); expect(user0).toBeInstanceOf(PublicKey); expect(user1).toBeInstanceOf(PublicKey); expect(user0.toBase58()).not.toEqual(user1.toBase58()); }); });