Test: simplify allow(dead_code) to be per-file
This commit is contained in:
parent
8a2d54cce8
commit
d0fef4a586
|
@ -1,3 +1,5 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
use std::{mem, sync::Arc};
|
||||
|
||||
use bytemuck::from_bytes;
|
||||
|
@ -41,7 +43,6 @@ pub struct SerumCookie {
|
|||
}
|
||||
|
||||
impl SerumCookie {
|
||||
#[allow(dead_code)]
|
||||
pub fn create_dex_account(&self, unpadded_len: usize) -> (Keypair, Instruction) {
|
||||
let serum_program_id = self.program_id;
|
||||
let key = Keypair::new();
|
||||
|
@ -57,7 +58,6 @@ impl SerumCookie {
|
|||
return (key, create_account_instr);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn gen_listing_params(
|
||||
&self,
|
||||
_coin_mint: &Pubkey,
|
||||
|
@ -94,7 +94,6 @@ impl SerumCookie {
|
|||
return (info, instructions);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn list_spot_market(
|
||||
&self,
|
||||
coin_mint: &MintCookie,
|
||||
|
@ -186,7 +185,6 @@ impl SerumCookie {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn consume_spot_events(
|
||||
&self,
|
||||
spot_market_cookie: &SpotMarketCookie,
|
||||
|
@ -208,13 +206,11 @@ impl SerumCookie {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn strip_dex_padding(data: &[u8]) -> &[u8] {
|
||||
assert!(data.len() >= 12);
|
||||
&data[5..data.len() - 7]
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn load_open_orders(&self, open_orders: Pubkey) -> serum_dex::state::OpenOrders {
|
||||
let data = self.solana.get_account_data(open_orders).await.unwrap();
|
||||
let slice = Self::strip_dex_padding(&data);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
|
@ -23,7 +25,6 @@ pub struct SolanaCookie {
|
|||
}
|
||||
|
||||
impl SolanaCookie {
|
||||
#[allow(dead_code)]
|
||||
pub async fn process_transaction(
|
||||
&self,
|
||||
instructions: &[Instruction],
|
||||
|
@ -79,7 +80,6 @@ impl SolanaCookie {
|
|||
.unwrap()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn advance_by_slots(&self, slots: u64) {
|
||||
let clock = self.get_clock().await;
|
||||
self.context
|
||||
|
@ -88,8 +88,6 @@ impl SolanaCookie {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
||||
pub async fn advance_clock(&self) {
|
||||
let mut clock = self.get_clock().await;
|
||||
let old_ts = clock.unix_timestamp;
|
||||
|
@ -149,7 +147,6 @@ impl SolanaCookie {
|
|||
key.pubkey()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn create_token_account(&self, owner: &Pubkey, mint: Pubkey) -> Pubkey {
|
||||
let keypair = Keypair::new();
|
||||
let rent = self.rent.minimum_balance(spl_token::state::Account::LEN);
|
||||
|
@ -178,7 +175,6 @@ impl SolanaCookie {
|
|||
}
|
||||
|
||||
// Note: Only one table can be created per authority per slot!
|
||||
#[allow(dead_code)]
|
||||
pub async fn create_address_lookup_table(
|
||||
&self,
|
||||
authority: &Keypair,
|
||||
|
@ -196,7 +192,6 @@ impl SolanaCookie {
|
|||
alt_address
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn get_account_data(&self, address: Pubkey) -> Option<Vec<u8>> {
|
||||
Some(
|
||||
self.context
|
||||
|
@ -210,7 +205,6 @@ impl SolanaCookie {
|
|||
)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn get_account_opt<T: AccountDeserialize>(&self, address: Pubkey) -> Option<T> {
|
||||
self.context
|
||||
.borrow_mut()
|
||||
|
@ -225,17 +219,14 @@ impl SolanaCookie {
|
|||
AccountDeserialize::try_deserialize(&mut data_slice).ok()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn get_account<T: AccountDeserialize>(&self, address: Pubkey) -> T {
|
||||
self.get_account_opt(address).await.unwrap()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn token_account_balance(&self, address: Pubkey) -> u64 {
|
||||
self.get_account::<TokenAccount>(address).await.amount
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn program_log(&self) -> Vec<String> {
|
||||
self.last_transaction_log.borrow().clone()
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
use bytemuck::{bytes_of, Contiguous};
|
||||
use solana_program::program_error::ProgramError;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::Keypair;
|
||||
use std::ops::Deref;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn gen_signer_seeds<'a>(nonce: &'a u64, acc_pk: &'a Pubkey) -> [&'a [u8]; 2] {
|
||||
[acc_pk.as_ref(), bytes_of(nonce)]
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn gen_signer_key(
|
||||
nonce: u64,
|
||||
acc_pk: &Pubkey,
|
||||
|
@ -19,7 +19,6 @@ pub fn gen_signer_key(
|
|||
Ok(Pubkey::create_program_address(&seeds, program_id)?)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn create_signer_key_and_nonce(program_id: &Pubkey, acc_pk: &Pubkey) -> (Pubkey, u64) {
|
||||
for i in 0..=u64::MAX_VALUE {
|
||||
if let Ok(pk) = gen_signer_key(i, acc_pk, program_id) {
|
||||
|
@ -29,7 +28,6 @@ pub fn create_signer_key_and_nonce(program_id: &Pubkey, acc_pk: &Pubkey) -> (Pub
|
|||
panic!("Could not generate signer key");
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn clone_keypair(keypair: &Keypair) -> Keypair {
|
||||
Keypair::from_base58_string(&keypair.to_base58_string())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue