#![cfg(feature = "test-bpf")] mod test_factory; use test_factory::*; use agsol_gold_contract::pda::*; use agsol_gold_contract::state::*; use agsol_gold_contract::ID as CONTRACT_ID; use agsol_testbench::tokio; use solana_program::pubkey::Pubkey; #[tokio::test] async fn test_process_filter_auction() { let (mut testbench, auction_owner) = test_factory::testbench_setup().await.unwrap().unwrap(); let auction_id = [2; 32]; let auction_config = AuctionConfig { cycle_period: 100, encore_period: 30, minimum_bid_amount: 50_000_000, number_of_cycles: Some(10), }; initialize_new_auction( &mut testbench, &auction_owner.keypair, &auction_config, auction_id, TokenType::Nft, ) .await .unwrap() .unwrap(); // check state account let (auction_root_state_pubkey, _) = Pubkey::find_program_address(&auction_root_state_seeds(&auction_id), &CONTRACT_ID); let auction_root_state = testbench .get_and_deserialize_account_data::(&auction_root_state_pubkey) .await .unwrap(); assert!(!auction_root_state.status.is_filtered); // filter auction let payer = testbench.clone_payer(); filter_auction_transaction(&mut testbench, auction_id, true, &payer) .await .unwrap() .unwrap(); let auction_root_state = testbench .get_and_deserialize_account_data::(&auction_root_state_pubkey) .await .unwrap(); assert!(auction_root_state.status.is_filtered); // unfilter filter_auction_transaction(&mut testbench, auction_id, false, &payer) .await .unwrap() .unwrap(); let auction_root_state = testbench .get_and_deserialize_account_data::(&auction_root_state_pubkey) .await .unwrap(); assert!(!auction_root_state.status.is_filtered); freeze_auction_transaction(&mut testbench, auction_id, &auction_owner.keypair) .await .unwrap() .unwrap(); // filter frozen transaction filter_auction_transaction(&mut testbench, auction_id, true, &payer) .await .unwrap() .unwrap(); let auction_root_state = testbench .get_and_deserialize_account_data::(&auction_root_state_pubkey) .await .unwrap(); assert!(auction_root_state.status.is_filtered); }