Compare commits

..

4 Commits

Author SHA1 Message Date
a014622dbd
Fix db migration
migrating all db schemas
integrate app data in migration
fix vm node registration to new architecture
2025-05-20 16:18:27 +05:30
57d3807a17
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 14:07:11 +05:30
929530a4c5
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 14:07:11 +05:30
4c647eef6a
register operator 2025-05-20 14:07:11 +05:30
2 changed files with 3 additions and 21 deletions

@ -239,18 +239,7 @@ impl NewVmReq {
self.price_per_unit
);
//let _: Vec<Self> = db.insert(NEW_VM_REQ).relation(self).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);
}
}
db.query(query).await?;
Ok(())
}
}
@ -287,7 +276,6 @@ impl WrappedMeasurement {
if let Some(args) = args {
return Ok(Self::Args(vm_id.to_string(), args));
}
log::trace!("listening for table: {table}");
tokio::time::timeout(Duration::from_secs(10), async {
loop {

@ -20,17 +20,11 @@ async fn test_vm_creation() {
let key = Key::new();
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
let _ = create_new_vm(&db, &key, &daemon_key, &brain_channel).await;
}
#[tokio::test]
async fn test_timeout_vm_creation() {
async fn test_vm_creation_timeout() {
prepare_test_db().await.unwrap();
// env_logger::builder().filter_level(log::LevelFilter::Error).init();