Compare commits

..

5 Commits

Author SHA1 Message Date
933e3cb893
Fix db migration
migrating all db schemas
integrate app data in migration
fix vm node registration to new architecture
2025-05-20 20:34:01 +05:30
952ea971ca
kick contract transaction
one single transaction query to execute all the kick operation
Remove unused fields from deleted_app schema
a basic test for kick and possibilities
2025-05-20 20:34:00 +05:30
dd8710f4a0
kick contract implemented
app pricing calculation
add node in kick schema and type
improved handling
Clone on all app types
handle expected error on kick contract
validate both app and vm contracts
2025-05-20 20:34:00 +05:30
d1e5244a18
register operator 2025-05-20 20:33:02 +05:30
198f43f472
Fix: vm creating error
catching Insufficient fund error from transaction
returning approprate error variant
2025-05-20 20:20:02 +05:30
2 changed files with 21 additions and 3 deletions

@ -239,7 +239,18 @@ impl NewVmReq {
self.price_per_unit self.price_per_unit
); );
//let _: Vec<Self> = db.insert(NEW_VM_REQ).relation(self).await?; //let _: Vec<Self> = db.insert(NEW_VM_REQ).relation(self).await?;
db.query(query).await?; let mut query_resp = db.query(query).await?;
let resp_err = query_resp.take_errors();
if let Some(insufficient_funds_error) = resp_err.get(&1) {
if let surrealdb::Error::Api(surrealdb::error::Api::Query(tx_query_error)) =
insufficient_funds_error
{
log::error!("Transaction error: {}", tx_query_error);
return Err(Error::InsufficientFunds);
}
}
Ok(()) Ok(())
} }
} }
@ -276,6 +287,7 @@ impl WrappedMeasurement {
if let Some(args) = args { if let Some(args) = args {
return Ok(Self::Args(vm_id.to_string(), args)); return Ok(Self::Args(vm_id.to_string(), args));
} }
log::trace!("listening for table: {table}");
tokio::time::timeout(Duration::from_secs(10), async { tokio::time::timeout(Duration::from_secs(10), async {
loop { loop {

@ -20,11 +20,17 @@ async fn test_vm_creation() {
let key = Key::new(); let key = Key::new();
let _ = create_new_vm(&db, &key, &daemon_key, &brain_channel).await; let new_vm_resp = create_new_vm(&db, &key, &daemon_key, &brain_channel).await;
assert!(new_vm_resp.is_err());
let grpc_error_message = new_vm_resp.err().unwrap().to_string();
assert!(grpc_error_message.contains("Insufficient funds"));
// TODO: Airdrop the user and try creating the VM again
} }
#[tokio::test] #[tokio::test]
async fn test_vm_creation_timeout() { async fn test_timeout_vm_creation() {
prepare_test_db().await.unwrap(); prepare_test_db().await.unwrap();
// env_logger::builder().filter_level(log::LevelFilter::Error).init(); // env_logger::builder().filter_level(log::LevelFilter::Error).init();