Skip to content

Commit 39f74ac

Browse files
committed
Add account length test
1 parent d4736da commit 39f74ac

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/renderers-rust/public/templates/instructionsCpiPage.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'a, 'b> {{ instruction.name | pascalCase }}Cpi<'a, 'b> {
8787
signers_seeds: &[&[&[u8]]],
8888
remaining_accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]
8989
) -> solana_program::entrypoint::ProgramResult {
90-
let mut accounts = Vec::with_capacity({{ instruction.accounts.length }} + remaining_accounts.len());
90+
let mut accounts = Vec::with_capacity({{ instruction.accounts.length + '+' if instruction.accounts.length > 0}} remaining_accounts.len());
9191
{% for account in instruction.accounts %}
9292
{% if account.isSigner === 'either' %}
9393
{% if account.isOptional and instruction.optionalAccountStrategy === 'programId' %}
@@ -161,7 +161,7 @@ impl<'a, 'b> {{ instruction.name | pascalCase }}Cpi<'a, 'b> {
161161
accounts,
162162
data,
163163
};
164-
let mut account_infos = Vec::with_capacity({{ instruction.accounts.length }} + 1 + remaining_accounts.len());
164+
let mut account_infos = Vec::with_capacity({{ instruction.accounts.length + 1 }} + remaining_accounts.len());
165165
account_infos.push(self.__program.clone());
166166
{% for account in instruction.accounts %}
167167
{% if account.isOptional %}

packages/renderers-rust/public/templates/instructionsPage.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl {{ instruction.name | pascalCase }} {
3232
}
3333
#[allow(clippy::vec_init_then_push)]
3434
pub fn instruction_with_remaining_accounts(&self{{ ', args: ' + instruction.name | pascalCase + 'InstructionArgs' if hasArgs }}, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::instruction::Instruction {
35-
let mut accounts = Vec::with_capacity({{ instruction.accounts.length }} + remaining_accounts.len());
35+
let mut accounts = Vec::with_capacity({{ instruction.accounts.length + '+' if instruction.accounts.length > 0}} remaining_accounts.len());
3636
{% for account in instruction.accounts %}
3737
{% if account.isSigner === 'either' %}
3838
{% if account.isOptional %}

0 commit comments

Comments
 (0)