Skip to content

Commit fdf1ec2

Browse files
committed
run it back turbo
1 parent 52d5b1b commit fdf1ec2

File tree

11 files changed

+90
-29
lines changed

11 files changed

+90
-29
lines changed
Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
[workspace]
2-
members = [
3-
"program",
4-
]
52
resolver = "2"
3+
members = ["api", "program"]
64

7-
[profile.release]
8-
overflow-checks = true
5+
[workspace.package]
6+
version = "0.1.0"
7+
edition = "2021"
8+
license = "Apache-2.0"
9+
homepage = ""
10+
documentation = ""
11+
repository = ""
12+
readme = "./README.md"
13+
keywords = ["solana"]
14+
15+
[workspace.dependencies]
16+
hello_solana-api = { path = "./api", version = "0.1.0" }
17+
bytemuck = "1.14"
18+
num_enum = "0.7"
19+
solana-program = "1.18"
20+
steel = "2.0"
21+
thiserror = "1.0"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "hello_solana-api"
3+
description = "API for interacting with the HelloSolana program"
4+
version.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
homepage.workspace = true
8+
documentation.workspace = true
9+
repository.workspace = true
10+
readme.workspace = true
11+
keywords.workspace = true
12+
13+
[dependencies]
14+
bytemuck.workspace = true
15+
num_enum.workspace = true
16+
solana-program.workspace = true
17+
steel.workspace = true
18+
thiserror.workspace = true

basics/hello-solana/steel/program/src/api/mod.rs renamed to basics/hello-solana/steel/api/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ pub mod instruction;
22
pub mod sdk;
33

44
pub mod prelude {
5-
pub use super::instruction::*;
6-
pub use super::sdk::*;
7-
pub use super::ID;
5+
pub use crate::instruction::*;
6+
pub use crate::sdk::*;
87
}
98

109
use steel::*;

basics/hello-solana/steel/program/src/api/sdk.rs renamed to basics/hello-solana/steel/api/src/sdk.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use super::prelude::*;
21
use steel::*;
32

3+
use crate::prelude::*;
4+
45
pub fn hello(signer: Pubkey) -> Instruction {
56
Instruction {
6-
program_id: ID,
7+
program_id: crate::ID,
78
accounts: vec![AccountMeta::new(signer, true)],
89
data: HelloSolana {}.to_bytes(),
910
}

basics/hello-solana/steel/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.0",
44
"description": "",
55
"scripts": {
6-
"test": "pnpm ts-mocha -p ./tsconfig.json -t 1000000 ./tests/*.test.ts",
6+
"test": "pnpm ts-mocha -p ./tsconfig.json -t 1000000 ./tests/hello-solana.test.ts",
77
"build-and-test": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./tests/fixtures && pnpm test",
88
"build": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./program/target/so",
99
"deploy": "solana program deploy ./program/target/so/hello_solana_program.so "

basics/hello-solana/steel/program/Cargo.toml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
[package]
2-
name = "steel-hello-solana"
3-
version = "0.1.0"
4-
edition = "2021"
2+
name = "hello_solana-program"
3+
description = ""
4+
version.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
homepage.workspace = true
8+
documentation.workspace = true
9+
repository.workspace = true
10+
readme.workspace = true
11+
keywords.workspace = true
512

613
[lib]
714
crate-type = ["cdylib", "lib"]
815

16+
[dependencies]
17+
hello_solana-api.workspace = true
18+
solana-program.workspace = true
19+
steel.workspace = true
20+
921
[dev-dependencies]
1022
base64 = "0.21"
1123
rand = "0.8.5"
12-
solana-sdk = "^1.18"
24+
solana-program-test = "1.18"
25+
solana-sdk = "1.18"
1326
tokio = { version = "1.35", features = ["full"] }
14-
15-
[dependencies]
16-
bytemuck = "1.14"
17-
num_enum = "0.7"
18-
solana-program = "^1.18"
19-
steel = "2.0"
20-
thiserror = "1.0"
21-
# ~

basics/hello-solana/steel/program/src/hello.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::api::prelude::*;
21
use solana_program::msg;
32
use steel::*;
43

@@ -11,7 +10,7 @@ pub fn process_hello(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul
1110

1211
msg!("Hello, Solana!");
1312

14-
msg!("Our program's Program ID: {}", ID);
13+
msg!("Our program's Program ID: {}", &hello_solana_api::ID);
1514

1615
Ok(())
1716
}

basics/hello-solana/steel/program/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
pub mod api;
21
mod hello;
32

4-
use api::prelude::*;
53
use hello::*;
64

5+
use hello_solana_api::prelude::*;
76
use steel::*;
87

98
pub fn process_instruction(
109
program_id: &Pubkey,
1110
accounts: &[AccountInfo],
1211
data: &[u8],
1312
) -> ProgramResult {
14-
let (ix, data) = parse_instruction(&api::ID, program_id, data)?;
13+
let (ix, data) = parse_instruction(&hello_solana_api::ID, program_id, data)?;
1514

1615
match ix {
1716
SteelInstruction::HelloSolana => process_hello(accounts, data)?,
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use hello_solana_api::prelude::*;
2+
use solana_program::hash::Hash;
3+
use solana_program_test::{processor, BanksClient, ProgramTest};
4+
use solana_sdk::{signature::Keypair, signer::Signer, transaction::Transaction};
5+
6+
async fn setup() -> (BanksClient, Keypair, Hash) {
7+
let mut program_test = ProgramTest::new(
8+
"hello_solana_program",
9+
hello_solana_api::ID,
10+
processor!(hello_solana_program::process_instruction),
11+
);
12+
program_test.prefer_bpf(true);
13+
program_test.start().await
14+
}
15+
16+
#[tokio::test]
17+
async fn run_test() {
18+
// Setup test
19+
let (mut banks, payer, blockhash) = setup().await;
20+
21+
// Submit hello transaction.
22+
let ix = hello(payer.pubkey());
23+
let tx = Transaction::new_signed_with_payer(&[ix], Some(&payer.pubkey()), &[&payer], blockhash);
24+
let res = banks.process_transaction(tx).await;
25+
26+
assert!(res.is_ok());
27+
}

0 commit comments

Comments
 (0)