Skip to content

Commit fd182fe

Browse files
committed
feat(test): rust testing part 1
1 parent a49bd94 commit fd182fe

File tree

3 files changed

+495
-28
lines changed

3 files changed

+495
-28
lines changed

rust/Anchor.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ cluster = "localnet"
1616
wallet = "~/.config/solana/id.json"
1717

1818
[scripts]
19-
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 \"tests/**/*.ts\""
19+
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"

rust/programs/blog/src/lib.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -226,24 +226,12 @@ pub mod blog {
226226
.ok_or(BlogError::EmptyBalance)?;
227227
require!(amount > 0, BlogError::EmptyBalance);
228228

229-
let authority_key = state.authority;
230-
let bump_seed = [state.bump];
231-
let signer_seeds = [
232-
BlogState::SEED_PREFIX,
233-
authority_key.as_ref(),
234-
&bump_seed[..],
235-
];
236-
system_program::transfer(
237-
CpiContext::new_with_signer(
238-
ctx.accounts.system_program.to_account_info(),
239-
SystemTransfer {
240-
from: ctx.accounts.blog_state.to_account_info(),
241-
to: ctx.accounts.recipient.to_account_info(),
242-
},
243-
&[&signer_seeds],
244-
),
245-
amount,
246-
)?;
229+
**ctx
230+
.accounts
231+
.blog_state
232+
.to_account_info()
233+
.try_borrow_mut_lamports()? -= amount;
234+
**ctx.accounts.recipient.try_borrow_mut_lamports()? += amount;
247235

248236
emit!(FundsWithdrawn {
249237
recipient: ctx.accounts.recipient.key(),

0 commit comments

Comments
 (0)