Skip to content

Commit

Permalink
Expand and update instruction count tests (#16522)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmay authored Apr 13, 2021
1 parent f7eadd9 commit 74f5837
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
13 changes: 1 addition & 12 deletions programs/bpf/c/src/noop++/noop++.cc
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
/**
* @brief Example C++-based BPF program that prints out the parameters
* @brief Example C++ based BPF program that prints out the parameters
* passed to it
*/
#include <solana_sdk.h>

/**
* Custom error for when input serialization fails
*/
#define INVALID_INPUT 1

extern uint64_t entrypoint(const uint8_t *input) {
SolAccountInfo ka[1];
SolParameters params = (SolParameters) { .ka = ka };

sol_log(__FILE__);

if (!sol_deserialize(input, &params, SOL_ARRAY_SIZE(ka))) {
return ERROR_INVALID_ARGUMENT;
}

// Log the provided input parameters. In the case of the no-op
// program, no account keys or input data are expected but real
// programs will have specific requirements so they can do their work.
sol_log_params(&params);
return SUCCESS;
}
5 changes: 4 additions & 1 deletion programs/bpf/c/src/noop/noop.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
/**
* @brief Example C-based BPF noop program
* @brief Example C based BPF program that prints out the parameters
* passed to it
*/
#include <solana_sdk.h>

extern uint64_t entrypoint(const uint8_t *input) {
SolAccountInfo ka[1];
SolParameters params = (SolParameters) { .ka = ka };

if (!sol_deserialize(input, &params, SOL_ARRAY_SIZE(ka))) {
return ERROR_INVALID_ARGUMENT;
}

return SUCCESS;
}
9 changes: 8 additions & 1 deletion programs/bpf/tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,12 +1223,15 @@ fn assert_instruction_count() {
#[cfg(feature = "bpf_c")]
{
programs.extend_from_slice(&[
("alloc", 1137),
("bpf_to_bpf", 13),
("multiple_static", 8),
("noop", 45),
("noop++", 45),
("relative_call", 10),
("sanity", 175),
("sanity++", 177),
("sha256", 348),
("struct_pass", 8),
("struct_ret", 22),
]);
Expand All @@ -1238,14 +1241,18 @@ fn assert_instruction_count() {
programs.extend_from_slice(&[
("solana_bpf_rust_128bit", 572),
("solana_bpf_rust_alloc", 8906),
("solana_bpf_rust_custom_heap", 516),
("solana_bpf_rust_dep_crate", 2),
("solana_bpf_rust_external_spend", 498),
("solana_bpf_rust_iter", 724),
("solana_bpf_rust_many_args", 237),
("solana_bpf_rust_mem", 2297),
("solana_bpf_rust_noop", 472),
("solana_bpf_rust_param_passing", 46),
("solana_bpf_rust_rand", 475),
("solana_bpf_rust_ristretto", 19220),
("solana_bpf_rust_sanity", 901),
("solana_bpf_rust_sanity", 869),
("solana_bpf_rust_sha256", 10830),
]);
}

Expand Down

0 comments on commit 74f5837

Please sign in to comment.