add solana_name_id, reassociate names with modules, modularize id tests (#4580)
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
|
||||
use crate::exchange_instruction::*;
|
||||
use crate::exchange_state::*;
|
||||
use crate::faucet_id;
|
||||
use crate::faucet;
|
||||
use log::*;
|
||||
use solana_metrics::inc_new_counter_info;
|
||||
use solana_sdk::account::KeyedAccount;
|
||||
@ -192,7 +192,7 @@ impl ExchangeProcessor {
|
||||
let mut to_account =
|
||||
Self::deserialize_account(&keyed_accounts[TO_ACCOUNT_INDEX].account.data)?;
|
||||
|
||||
if &faucet_id() == keyed_accounts[FROM_ACCOUNT_INDEX].unsigned_key() {
|
||||
if &faucet::id() == keyed_accounts[FROM_ACCOUNT_INDEX].unsigned_key() {
|
||||
to_account.tokens[token] += tokens;
|
||||
} else {
|
||||
let state: ExchangeState =
|
||||
@ -590,7 +590,7 @@ mod test {
|
||||
let instruction = exchange_instruction::transfer_request(
|
||||
&owner.pubkey(),
|
||||
to,
|
||||
&faucet_id(),
|
||||
&faucet::id(),
|
||||
token,
|
||||
tokens,
|
||||
);
|
||||
@ -671,7 +671,7 @@ mod test {
|
||||
let instruction = exchange_instruction::transfer_request(
|
||||
&owner.pubkey(),
|
||||
&new,
|
||||
&faucet_id(),
|
||||
&faucet::id(),
|
||||
Token::A,
|
||||
42,
|
||||
);
|
||||
|
@ -10,23 +10,20 @@ pub const EXCHANGE_PROGRAM_ID: [u8; 32] = [
|
||||
33, 70, 185, 192, 42, 31, 141, 152, 0, 0, 0, 0,
|
||||
];
|
||||
|
||||
solana_sdk::solana_program_id!(EXCHANGE_PROGRAM_ID);
|
||||
solana_sdk::solana_name_id!(
|
||||
EXCHANGE_PROGRAM_ID,
|
||||
"Exchange11111111111111111111111111111111111"
|
||||
);
|
||||
|
||||
pub const EXCHANGE_FAUCET_ID: [u8; 32] = [
|
||||
3, 147, 111, 103, 210, 47, 23, 11, 176, 29, 147, 89, 237, 155, 21, 62, 107, 105, 157, 1, 98,
|
||||
204, 206, 211, 54, 212, 79, 15, 160, 0, 0, 0,
|
||||
];
|
||||
pub mod faucet {
|
||||
pub const EXCHANGE_FAUCET_ID: [u8; 32] = [
|
||||
3, 147, 111, 103, 210, 47, 23, 11, 176, 29, 147, 89, 237, 155, 21, 62, 107, 105, 157, 1,
|
||||
98, 204, 206, 211, 54, 212, 79, 15, 160, 0, 0, 0,
|
||||
];
|
||||
|
||||
solana_sdk::solana_name_id!(
|
||||
EXCHANGE_FAUCET_ID,
|
||||
"ExchangeFaucet11111111111111111111111111111"
|
||||
);
|
||||
|
||||
pub fn faucet_id() -> solana_sdk::pubkey::Pubkey {
|
||||
solana_sdk::pubkey::Pubkey::new(&EXCHANGE_FAUCET_ID)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn exchange_faucet_id() {
|
||||
let ids = [("ExchangeFaucet11111111111111111111111111111", faucet_id())];
|
||||
assert!(ids.iter().all(|(name, id)| *name == id.to_string()));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user