Skip to content

Commit

Permalink
ready to look at
Browse files Browse the repository at this point in the history
  • Loading branch information
coachchucksol committed Dec 9, 2024
1 parent 15becfe commit 36e246b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 8 deletions.
19 changes: 12 additions & 7 deletions integration_tests/tests/fixtures/test_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use jito_tip_distribution_sdk::jito_tip_distribution;
use jito_tip_router_core::{
base_fee_group::BaseFeeGroup, base_reward_router::BaseRewardRouter, ncn_fee_group::NcnFeeGroup,
};
use jito_vault_core::{vault, vault_ncn_ticket::VaultNcnTicket};
use jito_vault_core::vault_ncn_ticket::VaultNcnTicket;
use solana_program::{
clock::Clock, native_token::sol_to_lamports, pubkey::Pubkey, system_instruction::transfer,
};
use solana_program_test::{processor, BanksClientError, ProgramTest, ProgramTestContext};
use solana_sdk::{
account::Account, commitment_config::CommitmentLevel, epoch_schedule::EpochSchedule, msg,
account::Account, commitment_config::CommitmentLevel, epoch_schedule::EpochSchedule,
native_token::lamports_to_sol, signature::Signer, transaction::Transaction,
};

Expand Down Expand Up @@ -698,11 +698,6 @@ impl TestBuilder {
let vault_rewards = vault_reward_route.rewards();

if vault_rewards > 0 {
// println!(
// "\n\n\n\n\n\n\n\n\n\n\n\n\nPayer: {:?}",
// self.context.payer.pubkey()
// );

tip_router_client
.do_distribute_ncn_vault_rewards(*group, vault, operator, ncn, slot)
.await?;
Expand All @@ -714,4 +709,14 @@ impl TestBuilder {

Ok(())
}

// Intermission 4 - route rewards
pub async fn reward_test_ncn(&mut self, test_ncn: &TestNcn, rewards: u64) -> TestResult<()> {
self.add_routers_for_tests_ncn(test_ncn).await?;
self.route_in_base_rewards_for_test_ncn(test_ncn, rewards)
.await?;
self.route_in_ncn_rewards_for_test_ncn(test_ncn).await?;

Ok(())
}
}
42 changes: 41 additions & 1 deletion integration_tests/tests/tip_router/meta_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mod tests {
fixture.cast_votes_for_test_ncn(&test_ncn).await?;
fixture.add_routers_for_tests_ncn(&test_ncn).await?;
fixture
.route_in_base_rewards_for_test_ncn(&test_ncn, 100)
.route_in_base_rewards_for_test_ncn(&test_ncn, 10_000)
.await?;
fixture.route_in_ncn_rewards_for_test_ncn(&test_ncn).await?;

Expand Down Expand Up @@ -61,6 +61,16 @@ mod tests {

assert!(epoch_snapshot.finalized());

fixture.vote_test_ncn(&test_ncn).await?;

let ballot_box = tip_router_client
.get_ballot_box(test_ncn.ncn_root.ncn_pubkey, ncn_epoch)
.await?;

assert!(ballot_box.has_winning_ballot());

fixture.reward_test_ncn(&test_ncn, 10_000).await?;

Ok(())
}

Expand All @@ -87,6 +97,16 @@ mod tests {

assert!(epoch_snapshot.finalized());

fixture.vote_test_ncn(&test_ncn).await?;

let ballot_box = tip_router_client
.get_ballot_box(test_ncn.ncn_root.ncn_pubkey, ncn_epoch)
.await?;

assert!(ballot_box.has_winning_ballot());

fixture.reward_test_ncn(&test_ncn, 10_000).await?;

Ok(())
}

Expand All @@ -113,6 +133,16 @@ mod tests {

assert!(epoch_snapshot.finalized());

fixture.vote_test_ncn(&test_ncn).await?;

let ballot_box = tip_router_client
.get_ballot_box(test_ncn.ncn_root.ncn_pubkey, ncn_epoch)
.await?;

assert!(ballot_box.has_winning_ballot());

fixture.reward_test_ncn(&test_ncn, 10_000).await?;

Ok(())
}

Expand All @@ -139,6 +169,16 @@ mod tests {

assert!(epoch_snapshot.finalized());

fixture.vote_test_ncn(&test_ncn).await?;

let ballot_box = tip_router_client
.get_ballot_box(test_ncn.ncn_root.ncn_pubkey, ncn_epoch)
.await?;

assert!(ballot_box.has_winning_ballot());

fixture.reward_test_ncn(&test_ncn, 10_000).await?;

Ok(())
}
}

0 comments on commit 36e246b

Please sign in to comment.