Skip to content

Commit 82857da

Browse files
committed
test: update metadata
1 parent 4479876 commit 82857da

File tree

15 files changed

+1648
-246
lines changed

15 files changed

+1648
-246
lines changed

CLAUDE.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This repository uses a comprehensive two-tier testing strategy:
1010

1111
All tests must follow these mandatory requirements:
1212
- **Functional test for every usage flow**
13-
- **Failing test for every error condition**
13+
- **Failing test for every error condition**
1414
- **Complete output verification** with single `assert_eq!` against expected structs
1515
- **1k iteration randomized tests** for complex functions and ZeroCopy structs
1616

@@ -78,4 +78,11 @@ The log file is automatically placed in the cargo workspace target directory, ma
7878

7979
-
8080

81-
- a compressed account the state update is atomic through the cpi to the light system program, writes to the cpi context can produce non atomic transactions if solana accounts are involved and instantly updated for compressed accounts atomicity still applies, in case that a written cpi context account is not executed the state update is never actually applied only prepared.
81+
- a compressed account the state update is atomic through the cpi to the light system program, writes to the cpi context can produce non atomic transactions if solana accounts are involved and instantly updated for compressed accounts atomicity still applies, in case that a written cpi context account is not executed the state update is never actually applied only prepared.
82+
83+
84+
# Zero Copies
85+
- the derive macros ZeroCopy and ZeroCopyMut derive zero copy deserialization methods and should be used in programs
86+
- in client code borsh is preferable
87+
- ZeroCopy is borsh compatible
88+
- Z and Z*Mut structs are derived by the ZeroCopy and ZeroCopyMut macros and cannot be searched with grep or rg, search for the non prefixed struct instead the zero copy struct has the same structure with zero copy types.

UNIT_TESTING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ Unit tests in this repository test individual functions in isolation using mock
55
## General Requirements
66
- don't create many files
77
- don't use the word comprehensive in variable, test function and test file names, tests always must be compreshensive
8-
- we need a functional test for every usage flow
9-
- we need a failing test for each error
8+
- create a functional test for every usage flow
9+
- create a failing test for each error
1010
- unwraps are ok in tests but not in sdks or other library code
11+
- structs should be asserted in one assert_eq!(expected_struct, actual_struct); assert!(result.is_ok(), is insufficient
1112

1213
## Test Organization
1314

program-libs/ctoken-types/src/state/mint.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,20 +325,24 @@ impl ZCompressedMintMut<'_> {
325325
self.supply = ix_data.supply;
326326
self.decimals = ix_data.decimals;
327327
self.is_decompressed = if is_decompressed { 1 } else { 0 };
328+
msg!("set1");
328329
if let Some(self_mint_authority) = self.mint_authority.as_deref_mut() {
329330
*self_mint_authority = *ix_data
330331
.mint_authority
331332
.ok_or(CTokenError::InstructionDataExpectedMintAuthority)?;
332333
}
334+
msg!("set2");
333335
if self.mint_authority.is_some() && ix_data.mint_authority.is_none() {
334336
return Err(CTokenError::ZeroCopyExpectedMintAuthority);
335337
}
338+
msg!("set3");
336339

337340
if let Some(self_freeze_authority) = self.freeze_authority.as_deref_mut() {
338341
*self_freeze_authority = *ix_data
339342
.freeze_authority
340343
.ok_or(CTokenError::InstructionDataExpectedFreezeAuthority)?;
341344
}
345+
msg!("set4");
342346
if self.freeze_authority.is_some() && ix_data.freeze_authority.is_none() {
343347
return Err(CTokenError::ZeroCopyExpectedFreezeAuthority);
344348
}

0 commit comments

Comments
 (0)