-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7168f9d
commit c22377e
Showing
4 changed files
with
380 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
276 changes: 158 additions & 118 deletions
276
integration_tests/tests/tip_router/set_config_fees.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,121 +1,161 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
// use jito_tip_router_core::{error::TipRouterError, ncn_fee_group::NcnFeeGroup}; | ||
// use solana_sdk::{ | ||
// clock::DEFAULT_SLOTS_PER_EPOCH, | ||
// signature::{Keypair, Signer}, | ||
// }; | ||
|
||
// use crate::fixtures::{ | ||
// test_builder::TestBuilder, tip_router_client::assert_tip_router_error, TestResult, | ||
// }; | ||
|
||
// #[tokio::test] | ||
// async fn test_set_config_fees_ok() -> TestResult<()> { | ||
// let mut fixture = TestBuilder::new().await; | ||
// let mut tip_router_client = fixture.tip_router_client(); | ||
// let ncn_root = fixture.setup_ncn().await?; | ||
|
||
// // Initialize config first - note that ncn_admin is now required as signer | ||
// tip_router_client | ||
// .do_initialize_config(ncn_root.ncn_pubkey, &ncn_root.ncn_admin) | ||
// .await?; | ||
|
||
// // Change fees and fee wallet | ||
// let new_fee_wallet = Keypair::new(); | ||
// tip_router_client | ||
// .do_set_config_fees( | ||
// 100, // dao_fee_bps | ||
// 200, // ncn_fee_bps | ||
// 300, // block_engine_fee_bps | ||
// new_fee_wallet.pubkey(), | ||
// &ncn_root, | ||
// ) | ||
// .await?; | ||
|
||
// Ok(()) | ||
// } | ||
|
||
// #[tokio::test] | ||
// async fn test_set_config_fees_exceed_max_fails() -> TestResult<()> { | ||
// let mut fixture = TestBuilder::new().await; | ||
// let mut tip_router_client = fixture.tip_router_client(); | ||
// let ncn_root = fixture.setup_ncn().await?; | ||
|
||
// // Initialize config first | ||
// tip_router_client | ||
// .do_initialize_config(ncn_root.ncn_pubkey, &ncn_root.ncn_admin) | ||
// .await?; | ||
|
||
// // Try to set fees above max | ||
// let transaction_error = tip_router_client | ||
// .do_set_config_fees(10_001, 0, 0, ncn_root.ncn_admin.pubkey(), &ncn_root) | ||
// .await; | ||
|
||
// assert_tip_router_error(transaction_error, TipRouterError::FeeCapExceeded); | ||
// Ok(()) | ||
// } | ||
|
||
// #[tokio::test] | ||
// async fn test_set_config_fees_wrong_admin_fails() -> TestResult<()> { | ||
// let mut fixture = TestBuilder::new().await; | ||
// let mut tip_router_client = fixture.tip_router_client(); | ||
// let mut ncn_root = fixture.setup_ncn().await?; | ||
|
||
// tip_router_client | ||
// .do_initialize_config(ncn_root.ncn_pubkey, &ncn_root.ncn_admin) | ||
// .await?; | ||
|
||
// let wrong_admin = Keypair::new(); | ||
// ncn_root.ncn_admin = wrong_admin; | ||
// let transaction_error = tip_router_client | ||
// .do_set_config_fees(100, 200, 300, ncn_root.ncn_admin.pubkey(), &ncn_root) | ||
// .await; | ||
|
||
// assert_tip_router_error(transaction_error, TipRouterError::IncorrectFeeAdmin); | ||
// Ok(()) | ||
// } | ||
|
||
// #[tokio::test] | ||
// async fn test_set_config_fees_across_epoch() -> TestResult<()> { | ||
// let mut fixture = TestBuilder::new().await; | ||
// let mut tip_router_client = fixture.tip_router_client(); | ||
// let ncn_root = fixture.setup_ncn().await?; | ||
|
||
// // Initialize config first | ||
// tip_router_client | ||
// .do_initialize_config(ncn_root.ncn_pubkey, &ncn_root.ncn_admin) | ||
// .await?; | ||
|
||
// // Set new fees | ||
// let new_fee_wallet = Keypair::new(); | ||
// tip_router_client | ||
// .do_set_config_fees(100, 200, 0, new_fee_wallet.pubkey(), &ncn_root) | ||
// .await?; | ||
|
||
// // Advance epoch | ||
// fixture | ||
// .warp_slot_incremental(2 * DEFAULT_SLOTS_PER_EPOCH) | ||
// .await?; | ||
|
||
// let config = tip_router_client | ||
// .get_ncn_config(ncn_root.ncn_pubkey) | ||
// .await?; | ||
// let clock = fixture.clock().await; | ||
// assert_eq!(config.fee_config.dao_fee_bps(clock.epoch as u64), 100); | ||
// assert_eq!( | ||
// config | ||
// .fee_config | ||
// .ncn_fee_bps(NcnFeeGroup::default(), clock.epoch as u64) | ||
// .unwrap(), | ||
// 200 | ||
// ); | ||
// assert_eq!( | ||
// config.fee_config.block_engine_fee_bps(clock.epoch as u64), | ||
// 0 | ||
// ); | ||
// assert_eq!(config.fee_config.fee_wallet(), new_fee_wallet.pubkey()); | ||
|
||
// Ok(()) | ||
// } | ||
use std::u64; | ||
|
||
use jito_tip_router_core::{base_fee_group::BaseFeeGroup, ncn_fee_group::NcnFeeGroup}; | ||
use solana_sdk::pubkey::Pubkey; | ||
|
||
use crate::fixtures::{test_builder::TestBuilder, TestResult}; | ||
|
||
#[tokio::test] | ||
async fn test_set_config_fees_ok() -> TestResult<()> { | ||
let mut fixture = TestBuilder::new().await; | ||
let mut tip_router_client = fixture.tip_router_client(); | ||
let ncn_root = fixture.setup_ncn().await?; | ||
|
||
const NEW_BLOCK_ENGINE_FEE: u16 = 500; | ||
const NEW_BASE_FEE: u16 = 600; | ||
const NEW_NCN_FEE: u16 = 700; | ||
|
||
let new_base_fee_wallet = Pubkey::new_unique(); | ||
|
||
// Initialize config first - note that ncn_admin is now required as signer | ||
tip_router_client | ||
.do_initialize_config(ncn_root.ncn_pubkey, &ncn_root.ncn_admin) | ||
.await?; | ||
|
||
let base_fee_group = BaseFeeGroup::default(); | ||
let ncn_fee_group = NcnFeeGroup::default(); | ||
|
||
// Change fees and fee wallet | ||
tip_router_client | ||
.do_set_config_fees( | ||
Some(NEW_BLOCK_ENGINE_FEE), | ||
Some(base_fee_group), | ||
Some(new_base_fee_wallet), | ||
Some(NEW_BASE_FEE), | ||
Some(ncn_fee_group), | ||
Some(NEW_NCN_FEE), | ||
&ncn_root, | ||
) | ||
.await?; | ||
|
||
let ncn_config = tip_router_client | ||
.get_ncn_config(ncn_root.ncn_pubkey) | ||
.await?; | ||
|
||
assert_eq!( | ||
ncn_config.fee_config.block_engine_fee_bps(), | ||
NEW_BLOCK_ENGINE_FEE | ||
); | ||
|
||
assert_eq!( | ||
ncn_config | ||
.fee_config | ||
.base_fee_wallet(base_fee_group) | ||
.unwrap(), | ||
new_base_fee_wallet | ||
); | ||
|
||
let current_fees = ncn_config.fee_config.current_fees(u64::MAX); | ||
|
||
assert_eq!( | ||
current_fees.base_fee_bps(base_fee_group).unwrap(), | ||
NEW_BASE_FEE | ||
); | ||
|
||
assert_eq!( | ||
current_fees.ncn_fee_bps(ncn_fee_group).unwrap(), | ||
NEW_NCN_FEE | ||
); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[tokio::test] | ||
async fn test_set_config_all_fees_ok() -> TestResult<()> { | ||
let mut fixture = TestBuilder::new().await; | ||
let mut tip_router_client = fixture.tip_router_client(); | ||
let ncn_root = fixture.setup_ncn().await?; | ||
|
||
const NEW_BLOCK_ENGINE_FEE: u16 = 500; | ||
const NEW_BASE_FEE: u16 = 600; | ||
const NEW_NCN_FEE: u16 = 700; | ||
|
||
let new_base_fee_wallet = Pubkey::new_unique(); | ||
|
||
// Initialize config first - note that ncn_admin is now required as signer | ||
tip_router_client | ||
.do_initialize_config(ncn_root.ncn_pubkey, &ncn_root.ncn_admin) | ||
.await?; | ||
|
||
// Change fees and fee wallet | ||
tip_router_client | ||
.do_set_config_fees( | ||
Some(NEW_BLOCK_ENGINE_FEE), | ||
None, | ||
None, | ||
None, | ||
None, | ||
None, | ||
&ncn_root, | ||
) | ||
.await?; | ||
|
||
for group in BaseFeeGroup::all_groups().iter() { | ||
// Change fees and fee wallet | ||
tip_router_client | ||
.do_set_config_fees( | ||
None, | ||
Some(*group), | ||
Some(new_base_fee_wallet), | ||
Some(NEW_BASE_FEE), | ||
None, | ||
None, | ||
&ncn_root, | ||
) | ||
.await?; | ||
} | ||
|
||
for group in NcnFeeGroup::all_groups().iter() { | ||
// Change fees and fee wallet | ||
tip_router_client | ||
.do_set_config_fees( | ||
None, | ||
None, | ||
None, | ||
None, | ||
Some(*group), | ||
Some(NEW_NCN_FEE), | ||
&ncn_root, | ||
) | ||
.await?; | ||
} | ||
|
||
let ncn_config = tip_router_client | ||
.get_ncn_config(ncn_root.ncn_pubkey) | ||
.await?; | ||
|
||
assert_eq!( | ||
ncn_config.fee_config.block_engine_fee_bps(), | ||
NEW_BLOCK_ENGINE_FEE | ||
); | ||
|
||
let current_fees = ncn_config.fee_config.current_fees(u64::MAX); | ||
|
||
for group in BaseFeeGroup::all_groups().iter() { | ||
assert_eq!( | ||
ncn_config.fee_config.base_fee_wallet(*group).unwrap(), | ||
new_base_fee_wallet | ||
); | ||
|
||
assert_eq!(current_fees.base_fee_bps(*group).unwrap(), NEW_BASE_FEE); | ||
} | ||
|
||
for group in NcnFeeGroup::all_groups().iter() { | ||
assert_eq!(current_fees.ncn_fee_bps(*group).unwrap(), NEW_NCN_FEE); | ||
} | ||
|
||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.