Points on how to work with solana-bankrun
, to update the code and then test it in a project on local computer.
As of the PR kevinheavey/solana-bankrun#31 the change consists of update of src/lib.rs
to update linking to solana program test
: https://github.com/anza-xyz/agave/blob/v2.0.9/program-test/src/lib.rs#L1016
From changes in src/lib.rs
the linking to TypeScript is needed to be coded into index.ts
.
Then building goes with
cargo build
yarn install
yarn run lint && yarn run fmt
yarn run build
yarn run artifacts
yarn run tsc
# not sure why is needed manual `cp` call but `yanr run <smt>` did not work
cp solana-bankrun/solana-bankrun.linux-x64-gnu.node dist/
OUTPUT: dist/
directory with TS and *-gnu.node
As the linked project works with anchor-bankrun
I needed to update the dependencies for it as well.
Otherwise I was getting error
[] Building project '$HOME/marinade-ts-cli/tsconfig.json'...
packages/lib/bankrun-utils/src/extendedProvider.ts:83:3 - error TS2322: Type 'import("$HOME/marinade-ts-cli/node_modules/.pnpm/solana-bankrun@0.2.0_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/solana-bankrun/dist/index").BanksTransactionMeta' is not assignable to type 'import("$HOME/marinade-ts-cli/node_modules/.pnpm/dist@file+..+solana-bankrun+dist/node_modules/dist/index").BanksTransactionMeta'.
Types have separate declarations of a private property 'inner'.
83 return await provider.context.banksClient.processTransaction(tx)
~~~~~~
packages/lib/bankrun-utils/src/testInit.ts:254:38 - error TS2345: Argument of type 'import("$HOME/marinade-ts-cli/node_modules/.pnpm/dist@file+..+solana-bankrun+dist/node_modules/dist/index").ProgramTestContext' is not assignable to parameter of type 'import("$HOME/marinade-ts-cli/node_modules/.pnpm/solana-bankrun@0.2.0_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/solana-bankrun/dist/index").ProgramTestContext'.
Types have separate declarations of a private property 'inner'.
254 return new BankrunExtendedProvider(context)
~~~~~~~
Found 2 errors.
ELIFECYCLE Command failed with exit code 1.
ELIFECYCLE Command failed with exit code 1.
So, changing the anchor-bankrun
dependency path in package.json
to file:/<HOME>/solana-bankrun/dist
at
https://github.com/kevinheavey/anchor-bankrun/blob/v0.4.0/package.json#L18
rm -rf node_modules
yarn install
yarn run tsc
OUTPUT: dist/
dir with TS data
I work with
https://github.com/marinade-finance/marinade-ts-cli/tree/main/packages/lib/bankrun-utils
where both paths to solana-bankrun
and anchor-bankrun
have to be changed (at all places)
"solana-bankrun": "file:/<HOME>/solana-bankrun/dist",
"anchor-bankrun": "file:/<HOME>/anchor-bankrun/dist",
and then update and build
# just to be double-sure to remove old dependencies
rm -rf node_modules/
pnpm install
pnpm build