Skip to content

Commit 736bf09

Browse files
committed
add counter example pinocchio
1 parent a11dcf9 commit 736bf09

File tree

12 files changed

+1572
-7
lines changed

12 files changed

+1572
-7
lines changed

Cargo.lock

Lines changed: 36 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ members = [
88
"basics/close-account/native/program",
99
"basics/close-account/anchor/programs/close-account",
1010
"basics/counter/native/program",
11+
"basics/counter/pinocchio/program",
1112
"basics/counter/anchor/programs/counter_anchor",
1213
"basics/counter/mpl-stack",
1314
"basics/create-account/native/program",
@@ -65,8 +66,10 @@ spl-associated-token-account-interface = "2.0.0"
6566
spl-token-2022-interface = "2.0.0"
6667

6768
# pinocchio
68-
pinocchio = "=0.8.1"
69+
pinocchio = "0.9.2"
6970
pinocchio-log = "0.4.0"
71+
pinocchio-system = "0.4.0"
72+
pinocchio-pubkey = "0.3.0"
7073

7174
# testing
7275
litesvm = "0.8.1"

basics/counter/native/program/tests/test.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@ fn test_counter() {
5353
svm.latest_blockhash(),
5454
);
5555

56-
dbg!(&[0].split_at(1));
57-
5856
let _ = svm.send_transaction(tx).is_ok();
5957

6058
let counter_account_data = svm.get_account(&counter_account.pubkey()).unwrap().data;
61-
let couneter = Counter::try_from_slice(&counter_account_data).unwrap();
62-
assert_eq!(couneter.count, 1);
59+
let counter = Counter::try_from_slice(&counter_account_data).unwrap();
60+
assert_eq!(counter.count, 1);
6361
}

basics/counter/pinocchio/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Counter: Solana Pinocchio
2+
3+
This example program is written in Solana using only the Solana toolsuite.
4+
5+
## Setup
6+
7+
1. Build the program with `cargo build-sbf`
8+
2. Run tests + local validator with `yarn test`
9+
10+
## Debugging
11+
12+
1. Start test validator with `yarn start-validator`
13+
2. Start listening to program logs with `solana config set -ul && solana logs`
14+
3. Run tests with `yarn run-tests`
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "counter-solana-pinocchio",
3+
"version": "0.1.0",
4+
"description": "Counter program written using only Solana tooling",
5+
"main": "index.js",
6+
"author": "ngundotra",
7+
"license": "Apache-2.0",
8+
"private": false,
9+
"type": "module",
10+
"scripts": {
11+
"test": "pnpm ts-mocha -p ./tests/tsconfig.test.json -t 1000000 ./tests/counter.test.ts",
12+
"build-and-test": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./tests/fixtures && pnpm test",
13+
"build": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./program/target/so",
14+
"deploy": "solana program deploy ./program/target/so/program.so"
15+
},
16+
"devDependencies": {
17+
"@types/bn.js": "^5.1.0",
18+
"@types/chai": "^4.3.1",
19+
"@types/mocha": "^9.1.1",
20+
"chai": "^4.3.4",
21+
"mocha": "^9.0.3",
22+
"solana-bankrun": "^0.3.0",
23+
"ts-mocha": "^10.0.0",
24+
"typescript": "^4.3.5"
25+
},
26+
"dependencies": {
27+
"@solana/web3.js": "^1.91.4"
28+
}
29+
}

0 commit comments

Comments
 (0)