Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/sdk-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- program: token test
sub-tests: '["cargo-test-sbf -p sdk-token-test"]'
- program: sdk-libs
packages: light-sdk-macros light-sdk light-program-test light-client light-token-types light-token-sdk
packages: light-sdk-macros light-sdk light-program-test light-client light-token-types light-token
test_cmd: |
cargo test -p light-sdk-macros
cargo test -p light-sdk-macros --all-features
Expand All @@ -64,7 +64,7 @@ jobs:
cargo test -p light-client
cargo test -p light-sparse-merkle-tree
cargo test -p light-token-types
cargo test -p light-token-sdk --all-features
cargo test -p light-token --all-features
steps:
- name: Checkout sources
uses: actions/checkout@v6
Expand Down
32 changes: 32 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,35 @@ assert_eq!(ctoken, expected_ctoken, "CToken account should match expected");
- Maintainable - if account layout changes, deserialization handles it
- Readable - clear field names vs `account.data[108]`
- Single assertion point for the entire account state

### Getting Anchor Program Instruction Discriminators

Anchor uses 8-byte discriminators derived from the instruction name. To get discriminators from an Anchor program:

```rust
#[cfg(test)]
mod discriminator_tests {
use super::*;
use anchor_lang::Discriminator;

#[test]
fn print_instruction_discriminators() {
// Each instruction in the #[program] module has a corresponding struct
// in the `instruction` module with the DISCRIMINATOR constant
println!("InstructionName: {:?}", instruction::InstructionName::DISCRIMINATOR);
}
}
```

Run with: `cargo test -p <program-crate> print_instruction_discriminators -- --nocapture`

**Example output:**
```
Claim: [62, 198, 214, 193, 213, 159, 108, 210]
CompressAndClose: [96, 94, 135, 18, 121, 42, 213, 117]
```

**When to use discriminators:**
- Building instructions manually without Anchor's `InstructionData` trait
- Creating SDK functions that don't depend on Anchor crate
- Verifying instruction data in tests or validators
Loading
Loading