Skip to content

Commit

Permalink
fixing fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kox committed Nov 22, 2024
1 parent 24d267f commit 6aa6019
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 37 deletions.
3 changes: 2 additions & 1 deletion amm/tests/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ mod deposit_tests {
#[test]
fn deposit() {
let (mollusk, program_id) = shared::setup();
let (token_program, token_program_account) = mollusk_svm_programs_token::token::keyed_account();
let (token_program, token_program_account) =
mollusk_svm_programs_token::token::keyed_account();

let user = Pubkey::new_unique();
let config = Pubkey::new_unique();
Expand Down
3 changes: 2 additions & 1 deletion amm/tests/swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ mod swap_tests {
#[test]
fn swap() {
let (mollusk, program_id) = shared::setup();
let (token_program, token_program_account) = mollusk_svm_programs_token::token::keyed_account();
let (token_program, token_program_account) =
mollusk_svm_programs_token::token::keyed_account();

let user = Pubkey::new_unique();
let config = Pubkey::new_unique();
Expand Down
12 changes: 8 additions & 4 deletions fundraiser/tests/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ mod checker_tests {
fn should_fail_when_still_running() {
let mut mollusk = Mollusk::new(&PROGRAM_ID, "../target/deploy/fundraiser");
mollusk_svm_programs_token::token::add_program(&mut mollusk);
let (token_program, token_program_account) = mollusk_svm_programs_token::token::keyed_account();
let (token_program, token_program_account) =
mollusk_svm_programs_token::token::keyed_account();

let maker = Pubkey::new_unique();
let maker_ta = Pubkey::new_unique();
Expand Down Expand Up @@ -85,7 +86,8 @@ mod checker_tests {
let mut mollusk = Mollusk::new(&PROGRAM_ID, "../target/deploy/fundraiser");
mollusk_svm_programs_token::token::add_program(&mut mollusk);
mollusk.sysvars.warp_to_slot(2); // We start in slot 2 so we can test expired (0)
let (token_program, token_program_account) = mollusk_svm_programs_token::token::keyed_account();
let (token_program, token_program_account) =
mollusk_svm_programs_token::token::keyed_account();

let maker = Pubkey::new_unique();
let maker_ta = Pubkey::new_unique();
Expand Down Expand Up @@ -147,7 +149,8 @@ mod checker_tests {
let mut mollusk = Mollusk::new(&PROGRAM_ID, "../target/deploy/fundraiser");
mollusk_svm_programs_token::token::add_program(&mut mollusk);
mollusk.sysvars.warp_to_slot(2); // We start in slot 2 so we can test expired (0)
let (token_program, token_program_account) = mollusk_svm_programs_token::token::keyed_account();
let (token_program, token_program_account) =
mollusk_svm_programs_token::token::keyed_account();

let scammer = Pubkey::new_unique();
let maker = Pubkey::new_unique();
Expand Down Expand Up @@ -211,7 +214,8 @@ mod checker_tests {
let mut mollusk = Mollusk::new(&PROGRAM_ID, "../target/deploy/fundraiser");
mollusk_svm_programs_token::token::add_program(&mut mollusk);
mollusk.sysvars.warp_to_slot(2); // We start in slot 2 so we can test expired (0)
let (token_program, token_program_account) = mollusk_svm_programs_token::token::keyed_account();
let (token_program, token_program_account) =
mollusk_svm_programs_token::token::keyed_account();

let maker = Pubkey::new_unique();
let maker_ta = Pubkey::new_unique();
Expand Down
12 changes: 8 additions & 4 deletions fundraiser/tests/contribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ mod contribute_tests {
fn should_fail_when_lower_than_minimun() {
let mut mollusk = Mollusk::new(&PROGRAM_ID, "../target/deploy/fundraiser");
mollusk_svm_programs_token::token::add_program(&mut mollusk);
let (token_program, token_program_account) = mollusk_svm_programs_token::token::keyed_account();
let (token_program, token_program_account) =
mollusk_svm_programs_token::token::keyed_account();

let maker = Pubkey::new_unique();
let contributor = Pubkey::new_unique();
Expand Down Expand Up @@ -89,7 +90,8 @@ mod contribute_tests {
fn should_fail_when_expired() {
let mut mollusk = Mollusk::new(&PROGRAM_ID, "../target/deploy/fundraiser");
mollusk_svm_programs_token::token::add_program(&mut mollusk);
let (token_program, token_program_account) = mollusk_svm_programs_token::token::keyed_account();
let (token_program, token_program_account) =
mollusk_svm_programs_token::token::keyed_account();

let maker = Pubkey::new_unique();
let contributor = Pubkey::new_unique();
Expand Down Expand Up @@ -154,7 +156,8 @@ mod contribute_tests {
fn contribute() {
let mut mollusk = Mollusk::new(&PROGRAM_ID, "../target/deploy/fundraiser");
mollusk_svm_programs_token::token::add_program(&mut mollusk);
let (token_program, token_program_account) = mollusk_svm_programs_token::token::keyed_account();
let (token_program, token_program_account) =
mollusk_svm_programs_token::token::keyed_account();

let maker = Pubkey::new_unique();
let contributor = Pubkey::new_unique();
Expand Down Expand Up @@ -298,7 +301,8 @@ mod contribute_tests {
fn contribute_twice() {
let mut mollusk = Mollusk::new(&PROGRAM_ID, "../target/deploy/fundraiser");
mollusk_svm_programs_token::token::add_program(&mut mollusk);
let (token_program, token_program_account) = mollusk_svm_programs_token::token::keyed_account();
let (token_program, token_program_account) =
mollusk_svm_programs_token::token::keyed_account();

let maker = Pubkey::new_unique();
let contributor = Pubkey::new_unique();
Expand Down
9 changes: 6 additions & 3 deletions fundraiser/tests/refund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ mod refund_tests {
fn should_fail_when_campaign_still_running() {
let mut mollusk = Mollusk::new(&PROGRAM_ID, "../target/deploy/fundraiser");
mollusk_svm_programs_token::token::add_program(&mut mollusk);
let (token_program, token_program_account) = mollusk_svm_programs_token::token::keyed_account();
let (token_program, token_program_account) =
mollusk_svm_programs_token::token::keyed_account();

let maker = Pubkey::new_unique();
let contributor = Pubkey::new_unique();
Expand Down Expand Up @@ -86,7 +87,8 @@ mod refund_tests {
let mut mollusk = Mollusk::new(&PROGRAM_ID, "../target/deploy/fundraiser");
mollusk_svm_programs_token::token::add_program(&mut mollusk);
mollusk.sysvars.warp_to_slot(2); // We start in slot 2 so we can test expired (0)
let (token_program, token_program_account) = mollusk_svm_programs_token::token::keyed_account();
let (token_program, token_program_account) =
mollusk_svm_programs_token::token::keyed_account();

let maker = Pubkey::new_unique();
let contributor = Pubkey::new_unique();
Expand Down Expand Up @@ -152,7 +154,8 @@ mod refund_tests {
let mut mollusk = Mollusk::new(&PROGRAM_ID, "../target/deploy/fundraiser");
mollusk_svm_programs_token::token::add_program(&mut mollusk);
mollusk.sysvars.warp_to_slot(2); // We start in slot 2 so we can test expired (0)
let (token_program, token_program_account) = mollusk_svm_programs_token::token::keyed_account();
let (token_program, token_program_account) =
mollusk_svm_programs_token::token::keyed_account();

let maker = Pubkey::new_unique();
let contributor = Pubkey::new_unique();
Expand Down
11 changes: 6 additions & 5 deletions marketplace-native/src/instructions/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ pub fn initialize(accounts: &[AccountInfo], data: &[u8]) -> ProgramResult {
unsafe {
let marketplace_account = marketplace.borrow_mut_data_unchecked().as_mut_ptr();

*(marketplace_account.add(0) as *mut Pubkey) = *((data.as_ptr() as * const Pubkey)); // maker
*(marketplace_account.add(32) as *mut u64) = *((data.as_ptr() as * const u64)); // fee
*(marketplace_account.add(32) as *mut u8) = *((data.as_ptr() as * const u8)); // bump
*(marketplace_account.add(32) as *mut u8) = *((data.as_ptr() as * const u8)); // treasury_bump
*(marketplace_account.add(0) as *mut Pubkey) = *(data.as_ptr() as *const Pubkey); // maker
*(marketplace_account.add(32) as *mut u64) = *(data.as_ptr() as *const u64); // fee
*(marketplace_account.add(32) as *mut u8) = *(data.as_ptr() as *const u8); // bump
*(marketplace_account.add(32) as *mut u8) = *(data.as_ptr() as *const u8);
// treasury_bump
}

Ok(())
}
2 changes: 1 addition & 1 deletion marketplace-native/src/instructions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub use unpublish::*;

pub mod purchase;
pub use purchase::*;

use pinocchio::program_error::ProgramError;

#[derive(Clone, Copy, Debug)]
Expand Down
6 changes: 3 additions & 3 deletions marketplace-native/src/instructions/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use pinocchio::{
// > the marketplace
// > the token account
// > price
//
//
pub fn publish(accounts: &[AccountInfo], data: &[u8]) -> ProgramResult {
// let [publisher, marketplace, , _token_program] = accounts
// let [publisher, marketplace, , _token_program] = accounts

Ok(())
}
1 change: 0 additions & 1 deletion marketplace-native/src/instructions/purchase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ use pinocchio::{
};

pub fn purchase(accounts: &[AccountInfo], data: &[u8]) -> ProgramResult {

Ok(())
}
1 change: 0 additions & 1 deletion marketplace-native/src/instructions/unpublish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ use pinocchio::{
};

pub fn unpublish(accounts: &[AccountInfo], data: &[u8]) -> ProgramResult {

Ok(())
}
8 changes: 5 additions & 3 deletions marketplace-native/src/state/marketplace.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use pinocchio::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey, ProgramResult};
use pinocchio::{
account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey, ProgramResult,
};

/// # Marketplace State
///
Expand All @@ -17,7 +19,7 @@ impl Marketplace {
pub const LEN: usize = 32 // maker
+ 8 // fee
+ 1 // bump
+ 1; // treasury_bump
+ 1; // treasury_bump

#[inline(always)]
pub fn init(&self, data: &[u8; Self::LEN]) -> ProgramResult {
Expand All @@ -37,7 +39,7 @@ impl Marketplace {
Ok(Self::from_account_info_unchecked(account_info))
}

// We store who owns the marketplace
// We store who owns the marketplace
#[inline(always)]
pub fn maker(&self) -> Pubkey {
unsafe { *(self.0 as *const Pubkey) }
Expand Down
19 changes: 11 additions & 8 deletions marketplace-native/tests/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod initialize_tests {

use mollusk_svm::result::Check;
use solana_sdk::{
account::{ AccountSharedData, ReadableAccount },
account::{AccountSharedData, ReadableAccount},
instruction::{AccountMeta, Instruction},
pubkey::Pubkey,
};
Expand All @@ -21,16 +21,19 @@ mod initialize_tests {
let marketplace = Pubkey::new_unique();

let data = [
vec![0], // Instruction
marker.to_bytes().to_vec(), // marker
u64::MAX.to_le_bytes().to_vec(), // fee
u8::MAX.to_le_bytes().to_vec(), // authority bump
u8::MAX.to_le_bytes().to_vec(), // authority bump
vec![0], // Instruction
marker.to_bytes().to_vec(), // marker
u64::MAX.to_le_bytes().to_vec(), // fee
u8::MAX.to_le_bytes().to_vec(), // authority bump
u8::MAX.to_le_bytes().to_vec(), // authority bump
]
.concat();

let instruction =
Instruction::new_with_bytes(program_id, &data, vec![AccountMeta::new(marketplace, false)]);
let instruction = Instruction::new_with_bytes(
program_id,
&data,
vec![AccountMeta::new(marketplace, false)],
);

let lamports = mollusk.sysvars.rent.minimum_balance(Marketplace::LEN);

Expand Down
4 changes: 2 additions & 2 deletions marketplace-native/tests/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub fn create_marketplace(

account
}
/*
/*
#[inline]
pub fn expect_token_balance(result: &InstructionResult, account: Pubkey, expected_balance: u64) {
let account_shared_data = result
Expand All @@ -126,4 +126,4 @@ pub fn expect_token_balance(result: &InstructionResult, account: Pubkey, expecte
assert_eq!(account_data.amount, expected_balance);
}
*/
*/

0 comments on commit 6aa6019

Please sign in to comment.