This commit is contained in:
Hardhat Chad
2024-02-14 18:30:51 +00:00
parent bbc1d835ea
commit 25c2b17ee9
21 changed files with 670 additions and 45 deletions

View File

@@ -89,7 +89,7 @@ async fn test_initialize() {
for i in 0..BUS_COUNT {
let bus_account = banks.get_account(bus_pdas[i].0).await.unwrap().unwrap();
assert_eq!(bus_account.owner, ore::id());
let bus = bytemuck::try_from_bytes::<Bus>(&bus_account.data).unwrap();
let bus = Bus::try_from_bytes(&bus_account.data).unwrap();
assert_eq!(bus.bump as u8, bus_pdas[i].1);
assert_eq!(bus.id as u8, i as u8);
assert_eq!(bus.available_rewards, 0);
@@ -98,7 +98,7 @@ async fn test_initialize() {
// Test treasury state
let treasury_account = banks.get_account(treasury_pda.0).await.unwrap().unwrap();
assert_eq!(treasury_account.owner, ore::id());
let treasury = bytemuck::try_from_bytes::<Treasury>(&treasury_account.data).unwrap();
let treasury = Treasury::try_from_bytes(&treasury_account.data).unwrap();
assert_eq!(treasury.bump as u8, treasury_pda.1);
assert_eq!(treasury.admin, payer.pubkey());
assert_eq!(treasury.difficulty, INITIAL_DIFFICULTY.into());

View File

@@ -48,12 +48,12 @@ async fn test_mine() {
// Assert proof state
let proof_account = banks.get_account(proof_pda.0).await.unwrap().unwrap();
assert_eq!(proof_account.owner, ore::id());
let proof = bytemuck::try_from_bytes::<Proof>(&proof_account.data).unwrap();
let proof = Proof::try_from_bytes(&proof_account.data).unwrap();
// Assert proof state
let treasury_pda = Pubkey::find_program_address(&[TREASURY], &ore::id());
let treasury_account = banks.get_account(treasury_pda.0).await.unwrap().unwrap();
let treasury = bytemuck::try_from_bytes::<Treasury>(&treasury_account.data).unwrap();
let treasury = Treasury::try_from_bytes(&treasury_account.data).unwrap();
// Find next hash
let (next_hash, nonce) = find_next_hash(
@@ -72,6 +72,9 @@ async fn test_mine() {
AccountMeta::new(bus_pda.0, false),
AccountMeta::new(proof_pda.0, false),
AccountMeta::new_readonly(treasury_pda.0, false),
// AccountMeta::new(treasury_pda.0, false),
// AccountMeta::new(proof_pda.0, false),
// AccountMeta::new(bus_pda.0, false),
AccountMeta::new_readonly(sysvar::slot_hashes::id(), false),
],
data: [

View File

@@ -74,7 +74,7 @@ async fn test_reset() {
for i in 0..BUS_COUNT {
let bus_account = banks.get_account(bus_pdas[i].0).await.unwrap().unwrap();
assert_eq!(bus_account.owner, ore::id());
let bus = bytemuck::try_from_bytes::<Bus>(&bus_account.data).unwrap();
let bus = Bus::try_from_bytes(&bus_account.data).unwrap();
println!(
"Bus {:?} {:?} {:?}",
bus_pdas[i].0,
@@ -89,7 +89,7 @@ async fn test_reset() {
// Test treasury state
let treasury_account = banks.get_account(treasury_pda.0).await.unwrap().unwrap();
assert_eq!(treasury_account.owner, ore::id());
let treasury = bytemuck::try_from_bytes::<Treasury>(&treasury_account.data).unwrap();
let treasury = Treasury::try_from_bytes(&treasury_account.data).unwrap();
assert_eq!(treasury.bump as u8, treasury_pda.1);
assert_eq!(
treasury.admin,