mirror of
https://github.com/d0zingcat/ore.git
synced 2026-06-08 15:11:42 +00:00
Discriminator
This commit is contained in:
@@ -5,7 +5,13 @@ use solana_program::{
|
|||||||
program_error::ProgramError, pubkey::Pubkey, system_program,
|
program_error::ProgramError, pubkey::Pubkey, system_program,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{instruction::CreateProofArgs, loaders::*, state::Proof, utils::create_pda, PROOF};
|
use crate::{
|
||||||
|
instruction::CreateProofArgs,
|
||||||
|
loaders::*,
|
||||||
|
state::{Discriminator, Proof},
|
||||||
|
utils::create_pda,
|
||||||
|
PROOF,
|
||||||
|
};
|
||||||
|
|
||||||
pub fn process_create_proof<'a, 'info>(
|
pub fn process_create_proof<'a, 'info>(
|
||||||
_program_id: &Pubkey,
|
_program_id: &Pubkey,
|
||||||
@@ -27,12 +33,13 @@ pub fn process_create_proof<'a, 'info>(
|
|||||||
create_pda(
|
create_pda(
|
||||||
proof_info,
|
proof_info,
|
||||||
&crate::id(),
|
&crate::id(),
|
||||||
size_of::<Proof>(),
|
8 + size_of::<Proof>(),
|
||||||
&[PROOF, signer.key.as_ref(), &[args.bump]],
|
&[PROOF, signer.key.as_ref(), &[args.bump]],
|
||||||
system_program,
|
system_program,
|
||||||
signer,
|
signer,
|
||||||
)?;
|
)?;
|
||||||
let mut proof_data = proof_info.data.borrow_mut();
|
let mut proof_data = proof_info.data.borrow_mut();
|
||||||
|
proof_data[0] = Proof::discriminator() as u8;
|
||||||
let mut proof = Proof::try_from_bytes_mut(&mut proof_data)?;
|
let mut proof = Proof::try_from_bytes_mut(&mut proof_data)?;
|
||||||
proof.bump = args.bump as u64;
|
proof.bump = args.bump as u64;
|
||||||
proof.authority = *signer.key;
|
proof.authority = *signer.key;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use solana_program::{
|
|||||||
};
|
};
|
||||||
use spl_token::state::Mint;
|
use spl_token::state::Mint;
|
||||||
|
|
||||||
|
use crate::state::Discriminator;
|
||||||
use crate::{instruction::*, BUS, INITIAL_DIFFICULTY, MINT_ADDRESS, TREASURY_ADDRESS};
|
use crate::{instruction::*, BUS, INITIAL_DIFFICULTY, MINT_ADDRESS, TREASURY_ADDRESS};
|
||||||
use crate::{
|
use crate::{
|
||||||
loaders::*,
|
loaders::*,
|
||||||
@@ -70,31 +71,30 @@ pub fn process_initialize<'a, 'info>(
|
|||||||
create_pda(
|
create_pda(
|
||||||
bus_infos[i],
|
bus_infos[i],
|
||||||
&crate::id(),
|
&crate::id(),
|
||||||
size_of::<Bus>(),
|
8 + size_of::<Bus>(),
|
||||||
&[BUS, &[i as u8], &[bus_bumps[i]]],
|
&[BUS, &[i as u8], &[bus_bumps[i]]],
|
||||||
system_program,
|
system_program,
|
||||||
signer,
|
signer,
|
||||||
)?;
|
)?;
|
||||||
bus_infos[i].try_borrow_mut_data()?.copy_from_slice(
|
let mut bus_data = bus_infos[i].try_borrow_mut_data()?;
|
||||||
Bus {
|
bus_data[0] = Bus::discriminator() as u8;
|
||||||
bump: bus_bumps[i] as u32,
|
let mut bus = Bus::try_from_bytes_mut(&mut bus_data)?;
|
||||||
id: i as u32,
|
bus.bump = bus_bumps[i] as u32;
|
||||||
available_rewards: 0,
|
bus.id = i as u32;
|
||||||
}
|
bus.available_rewards = 0;
|
||||||
.to_bytes(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize treasury
|
// Initialize treasury
|
||||||
create_pda(
|
create_pda(
|
||||||
treasury_info,
|
treasury_info,
|
||||||
&crate::id(),
|
&crate::id(),
|
||||||
size_of::<Treasury>(),
|
8 + size_of::<Treasury>(),
|
||||||
&[TREASURY, &[args.treasury_bump]],
|
&[TREASURY, &[args.treasury_bump]],
|
||||||
system_program,
|
system_program,
|
||||||
signer,
|
signer,
|
||||||
)?;
|
)?;
|
||||||
let mut treasury_data = treasury_info.data.borrow_mut();
|
let mut treasury_data = treasury_info.data.borrow_mut();
|
||||||
|
treasury_data[0] = Treasury::discriminator() as u8;
|
||||||
let mut treasury = Treasury::try_from_bytes_mut(&mut treasury_data)?;
|
let mut treasury = Treasury::try_from_bytes_mut(&mut treasury_data)?;
|
||||||
treasury.bump = args.treasury_bump as u64;
|
treasury.bump = args.treasury_bump as u64;
|
||||||
treasury.admin = *signer.key;
|
treasury.admin = *signer.key;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ use bytemuck::{Pod, Zeroable};
|
|||||||
|
|
||||||
use crate::{impl_account_from_bytes, impl_to_bytes};
|
use crate::{impl_account_from_bytes, impl_to_bytes};
|
||||||
|
|
||||||
|
use super::{AccountDiscriminator, Discriminator};
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||||
pub struct Bus {
|
pub struct Bus {
|
||||||
@@ -15,5 +17,11 @@ pub struct Bus {
|
|||||||
pub available_rewards: u64,
|
pub available_rewards: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Discriminator for Bus {
|
||||||
|
fn discriminator() -> super::AccountDiscriminator {
|
||||||
|
AccountDiscriminator::Bus
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl_to_bytes!(Bus);
|
impl_to_bytes!(Bus);
|
||||||
impl_account_from_bytes!(Bus);
|
impl_account_from_bytes!(Bus);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::mem::transmute;
|
|||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use solana_program::keccak::{Hash as KeccakHash, HASH_BYTES};
|
use solana_program::keccak::{Hash as KeccakHash, HASH_BYTES};
|
||||||
|
|
||||||
use crate::{impl_account_from_bytes, impl_to_bytes};
|
use crate::impl_to_bytes;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||||
@@ -24,4 +24,4 @@ impl From<Hash> for KeccakHash {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl_to_bytes!(Hash);
|
impl_to_bytes!(Hash);
|
||||||
impl_account_from_bytes!(Hash);
|
// impl_account_from_bytes!(Hash);
|
||||||
|
|||||||
@@ -5,5 +5,18 @@ mod treasury;
|
|||||||
|
|
||||||
pub use bus::*;
|
pub use bus::*;
|
||||||
pub use hash::*;
|
pub use hash::*;
|
||||||
|
use num_enum::{IntoPrimitive, TryFromPrimitive};
|
||||||
pub use proof::*;
|
pub use proof::*;
|
||||||
pub use treasury::*;
|
pub use treasury::*;
|
||||||
|
|
||||||
|
#[repr(u8)]
|
||||||
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
|
||||||
|
pub enum AccountDiscriminator {
|
||||||
|
Bus = 100,
|
||||||
|
Proof = 101,
|
||||||
|
Treasury = 102,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait Discriminator {
|
||||||
|
fn discriminator() -> AccountDiscriminator;
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use solana_program::pubkey::Pubkey;
|
|||||||
|
|
||||||
use crate::{impl_account_from_bytes, impl_to_bytes};
|
use crate::{impl_account_from_bytes, impl_to_bytes};
|
||||||
|
|
||||||
use super::Hash;
|
use super::{AccountDiscriminator, Discriminator, Hash};
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||||
@@ -27,5 +27,11 @@ pub struct Proof {
|
|||||||
pub total_rewards: u64,
|
pub total_rewards: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Discriminator for Proof {
|
||||||
|
fn discriminator() -> super::AccountDiscriminator {
|
||||||
|
AccountDiscriminator::Proof
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl_to_bytes!(Proof);
|
impl_to_bytes!(Proof);
|
||||||
impl_account_from_bytes!(Proof);
|
impl_account_from_bytes!(Proof);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use solana_program::pubkey::Pubkey;
|
|||||||
|
|
||||||
use crate::{impl_account_from_bytes, impl_to_bytes};
|
use crate::{impl_account_from_bytes, impl_to_bytes};
|
||||||
|
|
||||||
use super::Hash;
|
use super::{AccountDiscriminator, Discriminator, Hash};
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||||
@@ -27,5 +27,11 @@ pub struct Treasury {
|
|||||||
pub total_claimed_rewards: u64,
|
pub total_claimed_rewards: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Discriminator for Treasury {
|
||||||
|
fn discriminator() -> super::AccountDiscriminator {
|
||||||
|
AccountDiscriminator::Treasury
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl_to_bytes!(Treasury);
|
impl_to_bytes!(Treasury);
|
||||||
impl_account_from_bytes!(Treasury);
|
impl_account_from_bytes!(Treasury);
|
||||||
|
|||||||
10
src/utils.rs
10
src/utils.rs
@@ -50,14 +50,20 @@ macro_rules! impl_account_from_bytes {
|
|||||||
pub fn try_from_bytes(
|
pub fn try_from_bytes(
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Result<&Self, solana_program::program_error::ProgramError> {
|
) -> Result<&Self, solana_program::program_error::ProgramError> {
|
||||||
bytemuck::try_from_bytes::<Self>(data).or(Err(
|
if (Self::discriminator() as u8).ne(&data[0]) {
|
||||||
|
return Err(solana_program::program_error::ProgramError::InvalidAccountData);
|
||||||
|
}
|
||||||
|
bytemuck::try_from_bytes::<Self>(&data[8..]).or(Err(
|
||||||
solana_program::program_error::ProgramError::InvalidAccountData,
|
solana_program::program_error::ProgramError::InvalidAccountData,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
pub fn try_from_bytes_mut(
|
pub fn try_from_bytes_mut(
|
||||||
data: &mut [u8],
|
data: &mut [u8],
|
||||||
) -> Result<&mut Self, solana_program::program_error::ProgramError> {
|
) -> Result<&mut Self, solana_program::program_error::ProgramError> {
|
||||||
bytemuck::try_from_bytes_mut::<Self>(data).or(Err(
|
if (Self::discriminator() as u8).ne(&data[0]) {
|
||||||
|
return Err(solana_program::program_error::ProgramError::InvalidAccountData);
|
||||||
|
}
|
||||||
|
bytemuck::try_from_bytes_mut::<Self>(&mut data[8..]).or(Err(
|
||||||
solana_program::program_error::ProgramError::InvalidAccountData,
|
solana_program::program_error::ProgramError::InvalidAccountData,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,12 @@ async fn test_initialize() {
|
|||||||
assert_eq!(bus.bump as u8, bus_pdas[i].1);
|
assert_eq!(bus.bump as u8, bus_pdas[i].1);
|
||||||
assert_eq!(bus.id as u8, i as u8);
|
assert_eq!(bus.id as u8, i as u8);
|
||||||
assert_eq!(bus.available_rewards, 0);
|
assert_eq!(bus.available_rewards, 0);
|
||||||
|
println!(
|
||||||
|
"Bus {:?} {:?} {:?}",
|
||||||
|
bus_pdas[i].0,
|
||||||
|
bus_account,
|
||||||
|
bs64::encode(&bus_account.data)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test treasury state
|
// Test treasury state
|
||||||
@@ -105,6 +111,12 @@ async fn test_initialize() {
|
|||||||
assert_eq!(treasury.epoch_start_at as u8, 0);
|
assert_eq!(treasury.epoch_start_at as u8, 0);
|
||||||
assert_eq!(treasury.reward_rate, INITIAL_REWARD_RATE);
|
assert_eq!(treasury.reward_rate, INITIAL_REWARD_RATE);
|
||||||
assert_eq!(treasury.total_claimed_rewards as u8, 0);
|
assert_eq!(treasury.total_claimed_rewards as u8, 0);
|
||||||
|
println!(
|
||||||
|
"Treasury {:?} {:?} {:?}",
|
||||||
|
treasury_pda.0,
|
||||||
|
treasury_account,
|
||||||
|
bs64::encode(&treasury_account.data)
|
||||||
|
);
|
||||||
|
|
||||||
// Test mint state
|
// Test mint state
|
||||||
let mint_account = banks.get_account(mint_pda.0).await.unwrap().unwrap();
|
let mint_account = banks.get_account(mint_pda.0).await.unwrap().unwrap();
|
||||||
@@ -133,13 +145,6 @@ async fn test_initialize() {
|
|||||||
assert_eq!(treasury_tokens.delegated_amount, 0);
|
assert_eq!(treasury_tokens.delegated_amount, 0);
|
||||||
assert_eq!(treasury_tokens.close_authority, COption::None);
|
assert_eq!(treasury_tokens.close_authority, COption::None);
|
||||||
|
|
||||||
// println!(
|
|
||||||
// "Treasury {:?} {:?} {:?}",
|
|
||||||
// treasury_pda.0,
|
|
||||||
// treasury_account,
|
|
||||||
// bs64::encode(&treasury_account.data)
|
|
||||||
// );
|
|
||||||
|
|
||||||
// assert!(false);
|
// assert!(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ async fn test_mine() {
|
|||||||
AccountMeta::new_readonly(treasury_pda.0, false),
|
AccountMeta::new_readonly(treasury_pda.0, false),
|
||||||
// AccountMeta::new(treasury_pda.0, false),
|
// AccountMeta::new(treasury_pda.0, false),
|
||||||
// AccountMeta::new(proof_pda.0, false),
|
// AccountMeta::new(proof_pda.0, false),
|
||||||
// AccountMeta::new(bus_pda.0, false),
|
|
||||||
AccountMeta::new_readonly(sysvar::slot_hashes::id(), false),
|
AccountMeta::new_readonly(sysvar::slot_hashes::id(), false),
|
||||||
],
|
],
|
||||||
data: [
|
data: [
|
||||||
@@ -126,49 +125,49 @@ async fn setup_program_test_env() -> (BanksClient, Keypair, solana_program::hash
|
|||||||
Pubkey::from_str("2uwqyH2gKqstgAFCSniirx73X4iQek5ETc2vVJKUiNMg").unwrap(),
|
Pubkey::from_str("2uwqyH2gKqstgAFCSniirx73X4iQek5ETc2vVJKUiNMg").unwrap(),
|
||||||
1002240,
|
1002240,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"/wAAAAAAAACAsuYOAAAAAA==",
|
"ZAAAAAAAAAD/AAAAAAAAAICy5g4AAAAA",
|
||||||
);
|
);
|
||||||
program_test.add_account_with_base64_data(
|
program_test.add_account_with_base64_data(
|
||||||
Pubkey::from_str("FRMC6jVczm1cRaEs5EhDsfw7X8vsmSDpf3bJWVkawngu").unwrap(),
|
Pubkey::from_str("FRMC6jVczm1cRaEs5EhDsfw7X8vsmSDpf3bJWVkawngu").unwrap(),
|
||||||
1002240,
|
1002240,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"/gAAAAEAAACAsuYOAAAAAA==",
|
"ZAAAAAAAAAD+AAAAAQAAAICy5g4AAAAA",
|
||||||
);
|
);
|
||||||
program_test.add_account_with_base64_data(
|
program_test.add_account_with_base64_data(
|
||||||
Pubkey::from_str("9nWyycs4GHjnLujPR2sbA1A8K8CkiLc5VzxWUD4hg2uM").unwrap(),
|
Pubkey::from_str("9nWyycs4GHjnLujPR2sbA1A8K8CkiLc5VzxWUD4hg2uM").unwrap(),
|
||||||
1002240,
|
1002240,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"/wAAAAIAAACAsuYOAAAAAA==",
|
"ZAAAAAAAAAD/AAAAAgAAAICy5g4AAAAA",
|
||||||
);
|
);
|
||||||
program_test.add_account_with_base64_data(
|
program_test.add_account_with_base64_data(
|
||||||
Pubkey::from_str("Kt7kqD3MyvxLbj4ek9urXUxkDoxaMuQn82K2VdYD1jM").unwrap(),
|
Pubkey::from_str("Kt7kqD3MyvxLbj4ek9urXUxkDoxaMuQn82K2VdYD1jM").unwrap(),
|
||||||
1002240,
|
1002240,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"+gAAAAMAAACAsuYOAAAAAA==",
|
"ZAAAAAAAAAD6AAAAAwAAAICy5g4AAAAA",
|
||||||
);
|
);
|
||||||
program_test.add_account_with_base64_data(
|
program_test.add_account_with_base64_data(
|
||||||
Pubkey::from_str("8r9mXYnFQXhwrNfvatGUTxbbNSqxScuCwp4sBTSxDVTJ").unwrap(),
|
Pubkey::from_str("8r9mXYnFQXhwrNfvatGUTxbbNSqxScuCwp4sBTSxDVTJ").unwrap(),
|
||||||
1002240,
|
1002240,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"/QAAAAQAAACAsuYOAAAAAA==",
|
"ZAAAAAAAAAD9AAAABAAAAICy5g4AAAAA",
|
||||||
);
|
);
|
||||||
program_test.add_account_with_base64_data(
|
program_test.add_account_with_base64_data(
|
||||||
Pubkey::from_str("D9cEH32k8p9uWc4w5RrStK9rWssU8NuX1Dg5YaUim4wL").unwrap(),
|
Pubkey::from_str("D9cEH32k8p9uWc4w5RrStK9rWssU8NuX1Dg5YaUim4wL").unwrap(),
|
||||||
1002240,
|
1002240,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"/wAAAAUAAACAsuYOAAAAAA==",
|
"ZAAAAAAAAAD/AAAABQAAAICy5g4AAAAA",
|
||||||
);
|
);
|
||||||
program_test.add_account_with_base64_data(
|
program_test.add_account_with_base64_data(
|
||||||
Pubkey::from_str("H1RKMYADPzd4C1j1RZu51NvRSVktoTYEJyeVy98Kmdyu").unwrap(),
|
Pubkey::from_str("H1RKMYADPzd4C1j1RZu51NvRSVktoTYEJyeVy98Kmdyu").unwrap(),
|
||||||
1002240,
|
1002240,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"/wAAAAYAAACAsuYOAAAAAA==",
|
"ZAAAAAAAAAD/AAAABgAAAICy5g4AAAAA",
|
||||||
);
|
);
|
||||||
program_test.add_account_with_base64_data(
|
program_test.add_account_with_base64_data(
|
||||||
Pubkey::from_str("3XbdZNbBjjp8qnDJjv1RxaKisyfx6ahznYkSigs6dayy").unwrap(),
|
Pubkey::from_str("3XbdZNbBjjp8qnDJjv1RxaKisyfx6ahznYkSigs6dayy").unwrap(),
|
||||||
1002240,
|
1002240,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"+QAAAAcAAACAsuYOAAAAAA==",
|
"ZAAAAAAAAAD5AAAABwAAAICy5g4AAAAA",
|
||||||
);
|
);
|
||||||
|
|
||||||
// Treasury (difficulty = MAX)
|
// Treasury (difficulty = MAX)
|
||||||
@@ -176,8 +175,7 @@ async fn setup_program_test_env() -> (BanksClient, Keypair, solana_program::hash
|
|||||||
Pubkey::from_str("67PLJej6iZm915WbEu6NLeZtRZtnHc5nSVQvkHRZyPiC").unwrap(),
|
Pubkey::from_str("67PLJej6iZm915WbEu6NLeZtRZtnHc5nSVQvkHRZyPiC").unwrap(),
|
||||||
1559040,
|
1559040,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"/wAAAAAAAADHPztpT4Jpqy1n9x6y1psKOUdDt07/OgR6noRFAOuOcP//////////////////////////////////////////ZAAAAAAAAAD0AQAAAAAAAAAAAAAAAAAA"
|
"ZgAAAAAAAAD/AAAAAAAAAI9MXkItHZzhz/U8d4MsXPzDSQZSRgZsJnNpvgvcborr//////////////////////////////////////////9kAAAAAAAAAPQBAAAAAAAAAAAAAAAAAAA=",
|
||||||
// "/wAAAAAAAACO+OozfX3xTr9I8U/aRel4qp0ixaw9/PjyseBa6CcLyv//////////////////////////////////////////AAAAAAAAAADoAwAAAAAAAAAAAAAAAAAA"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Mint
|
// Mint
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ async fn test_reset() {
|
|||||||
assert_eq!(treasury.bump as u8, treasury_pda.1);
|
assert_eq!(treasury.bump as u8, treasury_pda.1);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
treasury.admin,
|
treasury.admin,
|
||||||
Pubkey::from_str("EQn4AkZ9UvLcwRgyx1B8Y9sRM3KjfKyti8mjUJW1kL6B").unwrap()
|
Pubkey::from_str("AeNqnoLwFanMd3ig9WoMxQZVwQHtCtqKMMBsT1sTrvz6").unwrap()
|
||||||
);
|
);
|
||||||
assert_eq!(treasury.difficulty, INITIAL_DIFFICULTY.into());
|
assert_eq!(treasury.difficulty, INITIAL_DIFFICULTY.into());
|
||||||
assert_eq!(treasury.epoch_start_at as u8, 100);
|
assert_eq!(treasury.epoch_start_at as u8, 100);
|
||||||
@@ -115,12 +115,12 @@ async fn test_reset() {
|
|||||||
assert_eq!(mint.decimals, ore::TOKEN_DECIMALS);
|
assert_eq!(mint.decimals, ore::TOKEN_DECIMALS);
|
||||||
assert_eq!(mint.is_initialized, true);
|
assert_eq!(mint.is_initialized, true);
|
||||||
assert_eq!(mint.freeze_authority, COption::None);
|
assert_eq!(mint.freeze_authority, COption::None);
|
||||||
println!(
|
// println!(
|
||||||
"Mint {:?} {:?} {:?}",
|
// "Mint {:?} {:?} {:?}",
|
||||||
mint_pda.0,
|
// mint_pda.0,
|
||||||
mint_account,
|
// mint_account,
|
||||||
bs64::encode(&mint_account.data)
|
// bs64::encode(&mint_account.data)
|
||||||
);
|
// );
|
||||||
|
|
||||||
// Test treasury token state
|
// Test treasury token state
|
||||||
let treasury_tokens_account = banks
|
let treasury_tokens_account = banks
|
||||||
@@ -138,12 +138,12 @@ async fn test_reset() {
|
|||||||
assert_eq!(treasury_tokens.is_native, COption::None);
|
assert_eq!(treasury_tokens.is_native, COption::None);
|
||||||
assert_eq!(treasury_tokens.delegated_amount, 0);
|
assert_eq!(treasury_tokens.delegated_amount, 0);
|
||||||
assert_eq!(treasury_tokens.close_authority, COption::None);
|
assert_eq!(treasury_tokens.close_authority, COption::None);
|
||||||
println!(
|
// println!(
|
||||||
"Treasury tokens {:?} {:?} {:?}",
|
// "Treasury tokens {:?} {:?} {:?}",
|
||||||
treasury_tokens_address,
|
// treasury_tokens_address,
|
||||||
treasury_tokens_account,
|
// treasury_tokens_account,
|
||||||
bs64::encode(&treasury_tokens_account.data)
|
// bs64::encode(&treasury_tokens_account.data)
|
||||||
);
|
// );
|
||||||
|
|
||||||
// assert!(false);
|
// assert!(false);
|
||||||
}
|
}
|
||||||
@@ -157,49 +157,49 @@ async fn setup_program_test_env() -> (BanksClient, Keypair, Hash) {
|
|||||||
Pubkey::from_str("2uwqyH2gKqstgAFCSniirx73X4iQek5ETc2vVJKUiNMg").unwrap(),
|
Pubkey::from_str("2uwqyH2gKqstgAFCSniirx73X4iQek5ETc2vVJKUiNMg").unwrap(),
|
||||||
1002240,
|
1002240,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"/wAAAAAAAAAAAAAAAAAAAA==",
|
"ZAAAAAAAAAD/AAAAAAAAAAAAAAAAAAAA",
|
||||||
);
|
);
|
||||||
program_test.add_account_with_base64_data(
|
program_test.add_account_with_base64_data(
|
||||||
Pubkey::from_str("FRMC6jVczm1cRaEs5EhDsfw7X8vsmSDpf3bJWVkawngu").unwrap(),
|
Pubkey::from_str("FRMC6jVczm1cRaEs5EhDsfw7X8vsmSDpf3bJWVkawngu").unwrap(),
|
||||||
1002240,
|
1002240,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"/gAAAAEAAAAAAAAAAAAAAA==",
|
"ZAAAAAAAAAD+AAAAAQAAAAAAAAAAAAAA",
|
||||||
);
|
);
|
||||||
program_test.add_account_with_base64_data(
|
program_test.add_account_with_base64_data(
|
||||||
Pubkey::from_str("9nWyycs4GHjnLujPR2sbA1A8K8CkiLc5VzxWUD4hg2uM").unwrap(),
|
Pubkey::from_str("9nWyycs4GHjnLujPR2sbA1A8K8CkiLc5VzxWUD4hg2uM").unwrap(),
|
||||||
1002240,
|
1002240,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"/wAAAAIAAAAAAAAAAAAAAA==",
|
"ZAAAAAAAAAD/AAAAAgAAAAAAAAAAAAAA",
|
||||||
);
|
);
|
||||||
program_test.add_account_with_base64_data(
|
program_test.add_account_with_base64_data(
|
||||||
Pubkey::from_str("Kt7kqD3MyvxLbj4ek9urXUxkDoxaMuQn82K2VdYD1jM").unwrap(),
|
Pubkey::from_str("Kt7kqD3MyvxLbj4ek9urXUxkDoxaMuQn82K2VdYD1jM").unwrap(),
|
||||||
1002240,
|
1002240,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"+gAAAAMAAAAAAAAAAAAAAA==",
|
"ZAAAAAAAAAD6AAAAAwAAAAAAAAAAAAAA",
|
||||||
);
|
);
|
||||||
program_test.add_account_with_base64_data(
|
program_test.add_account_with_base64_data(
|
||||||
Pubkey::from_str("8r9mXYnFQXhwrNfvatGUTxbbNSqxScuCwp4sBTSxDVTJ").unwrap(),
|
Pubkey::from_str("8r9mXYnFQXhwrNfvatGUTxbbNSqxScuCwp4sBTSxDVTJ").unwrap(),
|
||||||
1002240,
|
1002240,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"/QAAAAQAAAAAAAAAAAAAAA==",
|
"ZAAAAAAAAAD9AAAABAAAAAAAAAAAAAAA",
|
||||||
);
|
);
|
||||||
program_test.add_account_with_base64_data(
|
program_test.add_account_with_base64_data(
|
||||||
Pubkey::from_str("D9cEH32k8p9uWc4w5RrStK9rWssU8NuX1Dg5YaUim4wL").unwrap(),
|
Pubkey::from_str("D9cEH32k8p9uWc4w5RrStK9rWssU8NuX1Dg5YaUim4wL").unwrap(),
|
||||||
1002240,
|
1002240,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"/wAAAAUAAAAAAAAAAAAAAA==",
|
"ZAAAAAAAAAD/AAAABQAAAAAAAAAAAAAA",
|
||||||
);
|
);
|
||||||
program_test.add_account_with_base64_data(
|
program_test.add_account_with_base64_data(
|
||||||
Pubkey::from_str("H1RKMYADPzd4C1j1RZu51NvRSVktoTYEJyeVy98Kmdyu").unwrap(),
|
Pubkey::from_str("H1RKMYADPzd4C1j1RZu51NvRSVktoTYEJyeVy98Kmdyu").unwrap(),
|
||||||
1002240,
|
1002240,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"/wAAAAYAAAAAAAAAAAAAAA==",
|
"ZAAAAAAAAAD/AAAABgAAAAAAAAAAAAAA",
|
||||||
);
|
);
|
||||||
program_test.add_account_with_base64_data(
|
program_test.add_account_with_base64_data(
|
||||||
Pubkey::from_str("3XbdZNbBjjp8qnDJjv1RxaKisyfx6ahznYkSigs6dayy").unwrap(),
|
Pubkey::from_str("3XbdZNbBjjp8qnDJjv1RxaKisyfx6ahznYkSigs6dayy").unwrap(),
|
||||||
1002240,
|
1002240,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"+QAAAAcAAAAAAAAAAAAAAA==",
|
"ZAAAAAAAAAD5AAAABwAAAAAAAAAAAAAA",
|
||||||
);
|
);
|
||||||
|
|
||||||
// Treasury
|
// Treasury
|
||||||
@@ -207,7 +207,7 @@ async fn setup_program_test_env() -> (BanksClient, Keypair, Hash) {
|
|||||||
Pubkey::from_str("67PLJej6iZm915WbEu6NLeZtRZtnHc5nSVQvkHRZyPiC").unwrap(),
|
Pubkey::from_str("67PLJej6iZm915WbEu6NLeZtRZtnHc5nSVQvkHRZyPiC").unwrap(),
|
||||||
1559040,
|
1559040,
|
||||||
ore::id(),
|
ore::id(),
|
||||||
"/wAAAAAAAADHPztpT4Jpqy1n9x6y1psKOUdDt07/OgR6noRFAOuOcAAA////////////////////////////////////////AAAAAAAAAADoAwAAAAAAAAAAAAAAAAAA",
|
"ZgAAAAAAAAD/AAAAAAAAAI9MXkItHZzhz/U8d4MsXPzDSQZSRgZsJnNpvgvcborrAAD///////////////////////////////////////8AAAAAAAAAAOgDAAAAAAAAAAAAAAAAAAA=",
|
||||||
);
|
);
|
||||||
|
|
||||||
// Mint
|
// Mint
|
||||||
|
|||||||
Reference in New Issue
Block a user