Skip to content

Commit eb4e792

Browse files
committed
fix yield test errors
1 parent 47584f6 commit eb4e792

File tree

1 file changed

+6
-31
lines changed

1 file changed

+6
-31
lines changed

tests/unit/yield.test.ts

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ import {
66
Transaction,
77
} from '@solana/web3.js';
88
import { fromWorkspace, LiteSVMProvider } from 'anchor-litesvm';
9-
import { createPublicClient, http, MINT, PROGRAM_ID, TOKEN_2022_ID, EarnAuthority } from '@m0-foundation/solana-m-sdk';
9+
import { EarnAuthority, ConsoleLogger } from '@m0-foundation/solana-m-sdk';
1010
import { M0SolanaApi } from '@m0-foundation/solana-m-api-sdk';
1111
import nock from 'nock';
1212
import { TransactionMetadata } from 'litesvm';
1313
import BN from 'bn.js';
1414

1515
const API_URL = 'http://localhost:5500';
16+
const PROGRAM_ID = new PublicKey('wMXX1K1nca5W4pZr1piETe78gcAVVrEFi9f4g46uXko');
17+
const TOKEN_2022_ID = new PublicKey('TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb');
18+
const MINT = new PublicKey('mzeroXDoBpRVhnEXBra27qzAMdxgpWVY3DzQW7xMVJp');
1619

1720
describe('Yield calculation tests', () => {
1821
const svm = fromWorkspace('../').withSplPrograms();
19-
const evmClient = createPublicClient({ transport: http('http://localhost:8545') });
2022
const provider = new LiteSVMProvider(svm);
2123
const connection = provider.connection;
2224

@@ -83,17 +85,6 @@ describe('Yield calculation tests', () => {
8385
),
8486
});
8587

86-
// Mint Mulitsig
87-
svm.setAccount(new PublicKey('ms2SCrTYioPuumF6oBvReXoVRizEW5qYkiVuUEak7Th'), {
88-
executable: false,
89-
owner: TOKEN_2022_ID,
90-
lamports: 4851120,
91-
data: Buffer.from(
92-
'AQIBhI3MukCLt9bNZReoZG9yHU+BVceFnS9LIH0+7+c54FqaouLGPcvnsHbwterjiAcIu1l2R99H2pIkxuBTYyQP/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==',
93-
'base64',
94-
),
95-
});
96-
9788
// User Token Account
9889
svm.setAccount(new PublicKey('BXr9Y8RarW8GhZ43Ma1vfUgm5haJVy9x2XSea9aCFSya'), {
9990
executable: false,
@@ -105,23 +96,6 @@ describe('Yield calculation tests', () => {
10596
),
10697
});
10798

108-
const setTokenAccountBalance = (balance: bigint) => {
109-
// encode the balance as a big-endian hex string
110-
const balanceHex = balance.toString(16).padStart(16, '0').match(/../g)?.reverse().join('') ?? '000000000000000';
111-
112-
const data = Buffer.from(
113-
`0b86be66d32bc5a4b5ab1febdf48e33b06c3b5a163b19c1730ed78705f7ef68c54592e90a3d0812d2ba6712e2c42888a30d3266e63608461091432d850ef8379${balanceHex}00000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002070000000f00010000`,
114-
'hex',
115-
);
116-
117-
svm.setAccount(new PublicKey('BXr9Y8RarW8GhZ43Ma1vfUgm5haJVy9x2XSea9aCFSya'), {
118-
executable: false,
119-
owner: TOKEN_2022_ID,
120-
lamports: 2108880,
121-
data,
122-
});
123-
};
124-
12599
describe('calculations', () => {
126100
// create index updates
127101
const indexUpdates: { ts: bigint; index: bigint }[] = [];
@@ -205,9 +179,10 @@ describe('Yield calculation tests', () => {
205179
mockSubgraphIndexUpdates(testConfig.indexUpdates.slice(lastClaim, j + 2));
206180

207181
// build claim for earner
208-
const auth = await EarnAuthority.load(connection, evmClient);
182+
const auth = await EarnAuthority.load(connection, PROGRAM_ID, new ConsoleLogger());
209183
const earner = (await auth.getAllEarners())[0];
210184
const ix = await auth.buildClaimInstruction(earner);
185+
211186
// build transaction
212187
const tx = new Transaction().add(ix!);
213188
tx.feePayer = provider.wallet.publicKey;

0 commit comments

Comments
 (0)