Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Aug 8, 2024
1 parent c659f88 commit 3264d9a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
15 changes: 11 additions & 4 deletions svm/examples/paytube/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ use {
crate::{
loader::PayTubeAccountLoader, settler::PayTubeSettler, transaction::PayTubeTransaction,
},
processor::{create_transaction_batch_processor, get_transaction_check_results},
processor::{
create_transaction_batch_processor, get_transaction_check_results, PayTubeForkGraph,
},
solana_client::rpc_client::RpcClient,
solana_compute_budget::compute_budget::ComputeBudget,
solana_sdk::{
Expand All @@ -73,7 +75,7 @@ use {
solana_svm::transaction_processor::{
TransactionProcessingConfig, TransactionProcessingEnvironment,
},
std::sync::Arc,
std::sync::{Arc, RwLock},
transaction::create_svm_transactions,
};

Expand Down Expand Up @@ -133,8 +135,13 @@ impl PayTubeChannel {
// translated and executed within a provisioned virtual machine, as
// well as offers many of the same functionality as the lower-level
// Solana runtime.
let processor =
create_transaction_batch_processor(&account_loader, &feature_set, &compute_budget);
let fork_graph = Arc::new(RwLock::new(PayTubeForkGraph {}));
let processor = create_transaction_batch_processor(
&account_loader,
&feature_set,
&compute_budget,
Arc::clone(&fork_graph),
);

// The PayTube transaction processing runtime environment.
//
Expand Down
3 changes: 2 additions & 1 deletion svm/examples/paytube/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ pub(crate) fn create_transaction_batch_processor<CB: TransactionProcessingCallba
callbacks: &CB,
feature_set: &FeatureSet,
compute_budget: &ComputeBudget,
fork_graph: Arc<RwLock<PayTubeForkGraph>>,
) -> TransactionBatchProcessor<PayTubeForkGraph> {
let processor = TransactionBatchProcessor::<PayTubeForkGraph>::default();

{
let mut cache = processor.program_cache.write().unwrap();

// Initialize the mocked fork graph.
let fork_graph = Arc::new(RwLock::new(PayTubeForkGraph {}));
// let fork_graph = Arc::new(RwLock::new(PayTubeForkGraph {}));
cache.fork_graph = Some(Arc::downgrade(&fork_graph));

// Initialize a proper cache environment.
Expand Down
4 changes: 3 additions & 1 deletion svm/examples/paytube/src/settler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ impl Ledger {
{
transaction.amount as i128
} else {
transaction.amount.checked_neg().unwrap() as i128
(transaction.amount as i128)
.checked_neg()
.unwrap_or_default()
};
ledger
.entry(LedgerKey { mint, keys })
Expand Down

0 comments on commit 3264d9a

Please sign in to comment.