Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
feat: add bpf-c-noop example
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Oct 30, 2018
1 parent 7042754 commit b088a77
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 147 deletions.
1 change: 1 addition & 0 deletions examples/bpf-c-noop/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/out/
1 change: 1 addition & 0 deletions examples/bpf-c-noop/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../bpf-sdk/bpf.mk
24 changes: 24 additions & 0 deletions examples/bpf-c-noop/src/noop.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @brief Example C-based BPF program that prints out the parameters
* passed to it
*/

#include <sol_bpf.h>

/**
* Number of SolKeyedAccounts expected. The program should bail if an
* unexpected number of accounts are passed to the program's entrypoint
*/
#define NUM_KA 1

extern bool entrypoint(const uint8_t *input) {
SolKeyedAccounts ka[NUM_KA];
uint8_t *data;
uint64_t data_len;

if (!sol_deserialize(input, NUM_KA, ka, &data, &data_len)) {
return false;
}
sol_print_params(NUM_KA, ka, data, data_len);
return true;
}
4 changes: 0 additions & 4 deletions test/bin/build.sh

This file was deleted.

133 changes: 0 additions & 133 deletions test/bin/noop.c

This file was deleted.

Binary file removed test/bin/noop_c.o
Binary file not shown.
9 changes: 0 additions & 9 deletions test/bin/noop_c.readme.txt

This file was deleted.

2 changes: 1 addition & 1 deletion test/bpf-loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test('load BPF program', async () => {

const connection = new Connection(url);
const from = await newAccountWithTokens(connection);
const data = await fs.readFile('test/bin/noop_c.o');
const data = await fs.readFile('test/fixtures/noop/noop.o');
const programId = await BpfLoader.load(connection, from, data);
const transaction = new Transaction().add({
keys: [from.publicKey],
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/noop/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash -ex

make -C ../../../examples/bpf-c-noop/
cp ../../../examples/bpf-c-noop/out/noop.o .
Binary file added test/fixtures/noop/noop.o
Binary file not shown.

0 comments on commit b088a77

Please sign in to comment.