Skip to content

Commit

Permalink
test: Print transaction and contract insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
WillPapper committed Jan 6, 2025
1 parent d60f063 commit 6d3b591
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,29 @@ mod tests {
}

#[test]
fn test_insert_transaction() {
let mut conn = initialize_db().unwrap();
fn test_insert_transaction() -> Result<(), Box<dyn std::error::Error>> {
let mut conn = initialize_db()?;
let transaction = Transactions {
id: 0,
sender: AddressSqlite::from(Address::from_str("0x0000000000000000000000000000000000000001").unwrap()),
transaction_type: TransactionType::CreateToken,
data: "0x".as_bytes().to_vec(),
timestamp: 1715136000,
};
insert_transaction(&mut conn, &transaction).unwrap();
insert_transaction(&mut conn, &transaction)?;

// Run queries to confirm that the transaction was inserted
let transaction_id = conn.query_row("SELECT * FROM transactions", [], |row| {
row.get::<usize, i32>(0)
})?;
println!("Transaction inserted: {}", transaction_id);

// Run queries to confirm that the contract was created
let contract_id = conn.query_row("SELECT * FROM contracts", [], |row| {
row.get::<usize, i32>(0)
})?;
println!("Contract created: {}", contract_id);

Ok(())
}
}

0 comments on commit 6d3b591

Please sign in to comment.