Skip to content

Commit

Permalink
ci fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rwwwx committed Aug 16, 2024
1 parent 7c0eed5 commit f885b5a
Show file tree
Hide file tree
Showing 27 changed files with 67 additions and 82 deletions.
3 changes: 1 addition & 2 deletions programs/voter-stake-registry/src/instructions/claim.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{borsh::BorshDeserialize, cpi_instructions, Registrar};
use crate::{borsh::BorshDeserialize, cpi_instructions, error::MplStakingError, Registrar};
use anchor_lang::prelude::*;
use anchor_spl::token::{Token, TokenAccount};
use crate::error::{MplStakingError};
use solana_program::program::get_return_data;
use spl_governance::state::{
governance::GovernanceV2, proposal::ProposalV2, vote_record::VoteRecordV2,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::cpi_instructions;
use crate::{
cpi_instructions,
error::MplStakingError,
state::{Registrar, Voter},
voter_seeds,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::clock_unix_timestamp;
use crate::{
clock_unix_timestamp,
error::MplStakingError,
state::{DepositEntry, Lockup, LockupKind, LockupPeriod, Registrar, Voter},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::cpi_instructions;
use crate::{error::MplStakingError, state::Registrar};
use crate::{cpi_instructions, error::MplStakingError, state::Registrar};
use anchor_lang::prelude::*;
use anchor_spl::token::{Mint, Token};
use spl_governance::state::realm;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::{cpi_instructions, voter::VoterWeightRecord};
use crate::{
cpi_instructions,
error::MplStakingError,
state::{Registrar, Voter},
voter::VoterWeightRecord,
};
use anchor_lang::{prelude::*, solana_program::sysvar::instructions as tx_instructions};
use std::mem::size_of;
Expand Down
2 changes: 1 addition & 1 deletion programs/voter-stake-registry/src/instructions/deposit.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::clock_unix_timestamp;
use crate::{
clock_unix_timestamp,
error::MplStakingError,
state::{LockupKind, LockupPeriod, Registrar, Voter},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::{clock_unix_timestamp, cpi_instructions, Stake};
use crate::{
clock_unix_timestamp, cpi_instructions,
error::MplStakingError,
state::{LockupKind, LockupPeriod},
Stake,
};
use anchor_lang::prelude::*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::events::*;
use crate::state::{Registrar, Voter};
use crate::{
events::*,
state::{Registrar, Voter},
};
use anchor_lang::prelude::*;

#[derive(Accounts)]
Expand Down
3 changes: 1 addition & 2 deletions programs/voter-stake-registry/src/instructions/stake.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::{cpi_instructions, Stake};
use crate::{error::MplStakingError, state::LockupKind};
use crate::{cpi_instructions, error::MplStakingError, state::LockupKind, Stake};
use anchor_lang::prelude::*;

/// Transfers unlocked tokens from the source deposit entry to the target deposit entry.
Expand Down
10 changes: 7 additions & 3 deletions programs/voter-stake-registry/src/instructions/unlock_tokens.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use crate::state::LockupPeriod;
use crate::{clock_unix_timestamp, cpi_instructions::withdraw_mining, Stake};
use crate::{error::MplStakingError, state::COOLDOWN_SECS};
use crate::{
clock_unix_timestamp,
cpi_instructions::withdraw_mining,
error::MplStakingError,
state::{LockupPeriod, COOLDOWN_SECS},
Stake,
};
use anchor_lang::prelude::*;

pub fn unlock_tokens(ctx: Context<Stake>, deposit_entry_index: u8) -> Result<()> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::state::{Registrar, Voter};
use crate::voter::VoterWeightRecord;
use crate::{
state::{Registrar, Voter},
voter::VoterWeightRecord,
};
use anchor_lang::prelude::*;

#[derive(Accounts)]
Expand Down
4 changes: 1 addition & 3 deletions programs/voter-stake-registry/src/instructions/withdraw.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use crate::{
clock_unix_timestamp,
voter::{load_token_owner_record, VoterWeightRecord},
};
use crate::{
error::MplStakingError,
state::{DepositEntry, LockupKind, LockupPeriod, Registrar, Voter},
voter::{load_token_owner_record, VoterWeightRecord},
voter_seeds,
};
use anchor_lang::prelude::*;
Expand Down
3 changes: 1 addition & 2 deletions programs/voter-stake-registry/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use anchor_lang::prelude::*;
use instructions::*;

pub use error::MplStakingError;
use instructions::*;
pub use state::{
lockup::{LockupKind, LockupPeriod},
DepositEntry, Registrar, Voter,
Expand Down
6 changes: 4 additions & 2 deletions programs/voter-stake-registry/src/state/lockup.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::borsh::{BorshDeserialize, BorshSerialize};
use crate::error::*;
use crate::{
borsh::{BorshDeserialize, BorshSerialize},
error::*,
};
use anchor_lang::prelude::*;
use static_assertions::const_assert;

Expand Down
3 changes: 1 addition & 2 deletions programs/voter-stake-registry/src/voter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::vote_weight_record;
use crate::{error::MplStakingError, state::Registrar};
use crate::{error::MplStakingError, state::Registrar, vote_weight_record};
use anchor_lang::prelude::*;
use spl_governance::state::token_owner_record;

Expand Down
1 change: 1 addition & 0 deletions programs/voter-stake-registry/tests/program_test/addin.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::*;
use anchor_spl::token::TokenAccount;
use mpl_staking::Voter;
use solana_sdk::{
instruction::Instruction,
Expand Down
3 changes: 1 addition & 2 deletions programs/voter-stake-registry/tests/program_test/rewards.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::SolanaCookie;
use anchor_lang::{prelude::*, AnchorDeserialize};
use mpl_staking::cpi_instructions::RewardsInstruction;
use mpl_staking::state::LockupPeriod;
use mpl_staking::{cpi_instructions::RewardsInstruction, state::LockupPeriod};
use solana_program_test::*;
use solana_sdk::{
instruction::{AccountMeta, Instruction},
Expand Down
1 change: 0 additions & 1 deletion programs/voter-stake-registry/tests/test_basic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use anchor_spl::token::TokenAccount;
use assert_custom_on_chain_error::AssertCustomOnChainErr;
use mpl_staking::{
error::MplStakingError,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use anchor_spl::token::TokenAccount;
use assert_custom_on_chain_error::AssertCustomOnChainErr;
use mpl_staking::{
error::MplStakingError,
Expand Down
77 changes: 33 additions & 44 deletions programs/voter-stake-registry/tests/test_claim.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
use std::str::FromStr;
use anchor_spl::token::TokenAccount;
use solana_program::msg;
use solana_program::pubkey::Pubkey;
use mpl_staking::state::{LockupKind, LockupPeriod};
use program_test::*;
use solana_program::pubkey::Pubkey;
use solana_program_test::*;
use solana_sdk::{signature::Keypair, signer::Signer, transport::TransportError};
use spl_governance::state::governance::GovernanceV2;
use spl_governance::state::proposal::ProposalV2;
use spl_governance::state::token_owner_record::get_token_owner_record_address;
use spl_governance::state::vote_record::{get_vote_record_address, VoteRecordV2};
use spl_governance::state::vote_record::get_vote_record_address;
use std::str::FromStr;

mod program_test;

Expand Down Expand Up @@ -187,7 +182,6 @@ async fn successeful_claim() -> Result<(), TransportError> {
.distribute_rewards(&rewards_pool, &distribution_authority)
.await?;


// create proposal `create_proposal`
// vote for this proposal `cast_vote`
let mint_governance = realm
Expand All @@ -197,50 +191,45 @@ async fn successeful_claim() -> Result<(), TransportError> {
&voter,
voter_authority,
payer,
context.addin.update_voter_weight_record_instruction(&registrar, &voter),
context
.addin
.update_voter_weight_record_instruction(&registrar, &voter),
)
.await;

let governance = &Pubkey::from_str("GovernanceProgramTest1111111111111111111111").unwrap();
let proposal = realm.create_proposal(
mint_governance.address,
voter_authority,
&voter,
payer,
context.addin.update_voter_weight_record_instruction(&registrar, &voter),
).await.unwrap();
let _ = realm.cast_vote(
mint_governance.address,
&proposal,
&voter,
voter_authority,
payer,
context.addin.update_voter_weight_record_instruction(&registrar, &voter),
).await.unwrap();
let proposal = realm
.create_proposal(
mint_governance.address,
voter_authority,
&voter,
payer,
context
.addin
.update_voter_weight_record_instruction(&registrar, &voter),
)
.await
.unwrap();
realm
.cast_vote(
mint_governance.address,
&proposal,
&voter,
voter_authority,
payer,
context
.addin
.update_voter_weight_record_instruction(&registrar, &voter),
)
.await
.unwrap();
let vote_record = {
let adrs = get_vote_record_address(
get_vote_record_address(
&Pubkey::from_str("GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw").unwrap(),
&proposal.address,
&proposal.owner_token_owner_record,
);

// let adrs = Pubkey::find_program_address(
// &[
// b"vote-record",
// proposal.address.as_ref(),
// voter_authority.as_ref(),
// ],
// &mint_governance.address, // SPL Governance Program ID
// ).0;
let vote_data = context.solana.get_account_data(adrs).await;
let mut data_slice: &[u8] = &vote_data;
let vote_record: spl_governance::state::vote_record::VoteRecordV2 =
anchor_lang::AnchorDeserialize::deserialize(&mut data_slice).unwrap();
// vote_record.governing_token_owner
adrs
)
};


context
.addin
.claim(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use anchor_spl::token::TokenAccount;
use assert_custom_on_chain_error::AssertCustomOnChainErr;
use mpl_staking::{
error::MplStakingError,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use anchor_spl::token::TokenAccount;
use assert_custom_on_chain_error::AssertCustomOnChainErr;
use mpl_staking::{
error::MplStakingError,
Expand Down
1 change: 0 additions & 1 deletion programs/voter-stake-registry/tests/test_extend_deposit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use anchor_spl::token::TokenAccount;
use assert_custom_on_chain_error::AssertCustomOnChainErr;
use mpl_staking::{
error::MplStakingError,
Expand Down
1 change: 0 additions & 1 deletion programs/voter-stake-registry/tests/test_lockup.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use anchor_spl::token::TokenAccount;
use assert_custom_on_chain_error::AssertCustomOnChainErr;
use mpl_staking::{
error::MplStakingError,
Expand Down
1 change: 0 additions & 1 deletion programs/voter-stake-registry/tests/test_log_voter_info.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use anchor_spl::token::TokenAccount;
use mpl_staking::state::{LockupKind, LockupPeriod};
use program_test::*;
use solana_program_test::*;
Expand Down
1 change: 0 additions & 1 deletion programs/voter-stake-registry/tests/test_stake.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use anchor_spl::token::TokenAccount;
use mpl_staking::state::{LockupKind, LockupPeriod};
use program_test::*;
use solana_program_test::*;
Expand Down
1 change: 0 additions & 1 deletion programs/voter-stake-registry/tests/test_voting.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use anchor_spl::token::TokenAccount;
use mpl_staking::state::{LockupKind, LockupPeriod};
use program_test::*;
use solana_program_test::*;
Expand Down

0 comments on commit f885b5a

Please sign in to comment.