Skip to content

Commit

Permalink
stub in ver 1 txn for chain id check
Browse files Browse the repository at this point in the history
  • Loading branch information
yuunlimm committed Oct 21, 2024
1 parent b82f4a2 commit 6873bb8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ impl RawData for MockGrpcServer {
) -> Result<Response<Self::GetTransactionsStream>, Status> {
let request = req.into_inner();
let starting_version = request.starting_version.unwrap_or(0); // Default to 0 if starting_version is not provided
println!( "Starting version: {}", starting_version);
let transactions_count = request.transactions_count.unwrap_or(1); // Default to 1 if transactions_count is not provided

println!( "Transactions count: {}", transactions_count);
let mut collected_transactions = Vec::new();

let mut transaction_map = HashMap::new();
Expand All @@ -48,7 +49,9 @@ impl RawData for MockGrpcServer {
sorted_transactions.sort_by_key(|tx| tx.version);

collected_transactions.extend(sorted_transactions.into_iter().take(transactions_count as usize));

for tx in &collected_transactions {
println!( "Collected transaction: {:?}", tx);
}
let result = if !collected_transactions.is_empty() {
TransactionsResponse {
transactions: collected_transactions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ const SLEEP_DURATION: Duration = Duration::from_millis(250);

impl SdkTestContext {
pub async fn new(txn_bytes: &[&[u8]]) -> anyhow::Result<Self> {
let transaction_batches = txn_bytes
// Create a dummy transaction server.
let transaction = Transaction {
version: 1,
..Transaction::default()
};
let mut transaction_batches = txn_bytes
.iter()
.enumerate()
.map(|(idx, txn)| {
Expand All @@ -49,6 +54,7 @@ impl SdkTestContext {
Ok::<Transaction, anyhow::Error>(transaction) // Explicit type annotation
})
.collect::<Result<Vec<Transaction>, _>>()?;
transaction_batches.append(&mut vec![transaction]);

let mut context = SdkTestContext {
transaction_batches,
Expand Down

0 comments on commit 6873bb8

Please sign in to comment.