Skip to content

Commit

Permalink
feat: add support for --sbf-program flag in test-validator
Browse files Browse the repository at this point in the history
This allows adding SBF programs to the genesis configuration with upgrades disabled. The flag accepts pairs of arguments (address and path) to specify programs, and validates input to ensure correct usage.
  • Loading branch information
sergeytimoshin committed Dec 14, 2024
1 parent 97a2568 commit b4674a0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cli/src/commands/test-validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ class SetupCommand extends Command {
required: false,
exclusive: ["geyser-config"],
}),
"sbf-program": Flags.string({
description:
"Add a SBF program to the genesis configuration with upgrades disabled. If the ledger already exists then this parameter is silently ignored. First argument can be a pubkey string or path to a keypair",
required: false,
multiple: true,
}),
};

async run() {
Expand All @@ -139,7 +145,22 @@ class SetupCommand extends Command {
});
this.log("\nTest validator stopped successfully \x1b[32m✔\x1b[0m");
} else {
const rawValues = flags["sbf-program"] || [];

if (rawValues.length % 2 !== 0) {
this.error("Each --sbf-program flag must have exactly two arguments");
}

const programs: { address: string; path: string }[] = [];
for (let i = 0; i < rawValues.length; i += 2) {
programs.push({
address: rawValues[i],
path: rawValues[i + 1],
});
}

await initTestEnv({
additionalPrograms: programs,
checkPhotonVersion: !flags["relax-indexer-version-constraint"],
indexer: !flags["skip-indexer"],
limitLedgerSize: flags["limit-ledger-size"],
Expand Down

0 comments on commit b4674a0

Please sign in to comment.