Skip to content

js: replace bankrun with litesvm#634

Merged
2501babe merged 1 commit intosolana-program:mainfrom
2501babe:20260418_js
Apr 20, 2026
Merged

js: replace bankrun with litesvm#634
2501babe merged 1 commit intosolana-program:mainfrom
2501babe:20260418_js

Conversation

@2501babe
Copy link
Copy Markdown
Member

have to do this now since otherwise i cant test new js required for #631

closes #587

@2501babe 2501babe self-assigned this Apr 18, 2026
@2501babe 2501babe force-pushed the 20260418_js branch 2 times, most recently from f2bc962 to 85bb70b Compare April 18, 2026 10:58
Comment on lines -205 to +246
const slot = await client.getSlot();
context.warpToSlot(slot + SLOTS_PER_EPOCH);
context.advanceEpoch();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bankrun ran on a real test validator so warpToSlot() worked perfectly. litesvm just uses svm, and for infuriating reasons that cost me a long time, they provide a fake warpToSlot() that just changes the clock slot without touching anything else. itd be one thing if they were lazy with stake history but they dont even change the epoch

admittedly im on an old version for web3js support so maybe its different or removed now

Comment on lines -211 to +263
// NOTE we cannot test executing this because bankrun latest is on 1.18
// maybe someday
//await processTransaction(context, transaction);
t.true(true);
const stakeRent = await connection.getMinimumBalanceForRentExemption(StakeProgram.space);
const poolOnrampAccount = svm.getAccount(poolOnrampAddress);
t.is(poolOnrampAccount.lamports, LAMPORTS_PER_SOL + stakeRent, 'lamports have been replenished');
Copy link
Copy Markdown
Member Author

@2501babe 2501babe Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for more context, the reason i have to do this pr is because bankrun was so old it didnt support sol_get_sysvar so any instruction that looked at stake history would immediately halt

@2501babe 2501babe marked this pull request as ready for review April 18, 2026 11:20
@2501babe 2501babe requested a review from grod220 April 18, 2026 11:21
Comment on lines -44 to 58
class BanksConnection {
constructor(client: BanksClient, payer: Keypair) {
this.client = client;
class LiteConnection {
constructor(svm: LiteSVM, payer: Keypair) {
this.svm = svm;
this.payer = payer;
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the point of this is we emulate the interface of a web3js Connection and then can pass it to anything that expects a web3js Connection without it being any the wiser

Copy link
Copy Markdown
Member

@grod220 grod220 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@2501babe 2501babe merged commit a36f8c2 into solana-program:main Apr 20, 2026
22 checks passed
@2501babe 2501babe deleted the 20260418_js branch April 20, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests: port js to litesvm

2 participants