[Fix] Connection Management

This commit is contained in:
Alex Emmet 2026-09-13 20:58:41 +02:00
commit 3f2ac18333
No known key found for this signature in database
122 changed files with 19970 additions and 5263 deletions

View file

@ -59,12 +59,7 @@ async fn reconnect_uses_the_injected_client() {
let fake = Arc::new(FakeOmikron {
reconnects: AtomicUsize::new(0),
});
let services = Arc::new(DaemonServices {
omikron: fake.clone(),
users: Default::default(),
config: Default::default(),
active: true,
});
let services = DaemonServices::with_centralized_client(fake.clone());
let router = CommandRouter::new(
Arc::new(DaemonRuntime::new()),
services,
@ -85,12 +80,7 @@ async fn identity_rotation_is_available_while_omikron_is_offline() {
let fake = Arc::new(FakeOmikron {
reconnects: AtomicUsize::new(0),
});
let services = Arc::new(DaemonServices {
omikron: fake.clone(),
users: Default::default(),
config: Default::default(),
active: true,
});
let services = DaemonServices::with_centralized_client(fake.clone());
let router = CommandRouter::new(
Arc::new(DaemonRuntime::new()),
services,
@ -111,12 +101,7 @@ async fn read_role_cannot_execute_an_administrative_request() {
let fake = Arc::new(FakeOmikron {
reconnects: AtomicUsize::new(0),
});
let services = Arc::new(DaemonServices {
omikron: fake.clone(),
users: Default::default(),
config: Default::default(),
active: true,
});
let services = DaemonServices::with_centralized_client(fake.clone());
let router = CommandRouter::new(
Arc::new(DaemonRuntime::new()),
services,

View file

@ -182,12 +182,7 @@ impl OmikronClient for TestOmikron {
}
fn active_services() -> Arc<DaemonServices> {
Arc::new(DaemonServices {
omikron: Arc::new(TestOmikron),
users: Default::default(),
config: Default::default(),
active: true,
})
DaemonServices::with_centralized_client(Arc::new(TestOmikron))
}
#[tokio::test]

View file

@ -0,0 +1,57 @@
use iota_daemon_lib::accounts::{AccountAuthority, CreateUserRequest, LocalIotaAccountAuthority};
use iota_identity::{LocalNodeIdentity, LocalUserId, PrincipalStore};
use iota_storage::identity::SqlitePrincipalStore;
#[tokio::test]
async fn standalone_accounts_survive_identity_reload_and_do_not_reuse_deleted_ids() {
let root = tempfile::tempdir().unwrap();
let storage = root.path().join("storage");
iota_util::file_util::configure_storage_directory(storage);
iota_storage::util::db::initialize_database().unwrap();
let identity_path = root.path().join("identity/iota.mk");
let identity = LocalNodeIdentity::load_or_create(&identity_path, None).unwrap();
let authority = LocalIotaAccountAuthority::new(identity.clone());
let alice = authority
.create_user(CreateUserRequest {
username: "alice".into(),
})
.await
.unwrap();
let alice_principal = SqlitePrincipalStore
.principal_for_local_user(alice.user)
.unwrap()
.and_then(|handle| SqlitePrincipalStore.get_principal(handle).unwrap())
.unwrap();
let credential = iota_util::file_util::read_user_credential("alice")
.unwrap()
.unwrap();
let restarted_identity = LocalNodeIdentity::load_or_create(&identity_path, None).unwrap();
assert_eq!(restarted_identity.node_id(), identity.node_id());
let restarted = LocalIotaAccountAuthority::new(restarted_identity);
let restored_principal = SqlitePrincipalStore
.principal_for_local_user(LocalUserId(alice.user.0))
.unwrap()
.and_then(|handle| SqlitePrincipalStore.get_principal(handle).unwrap())
.unwrap();
assert_eq!(restored_principal.principal, alice_principal.principal);
restarted
.delete_user(alice.user, credential.as_bytes())
.await
.unwrap();
let bob = restarted
.create_user(CreateUserRequest {
username: "bob".into(),
})
.await
.unwrap();
assert!(bob.user.0 > alice.user.0);
assert!(
SqlitePrincipalStore
.get_by_canonical_id(&alice_principal.principal)
.unwrap()
.is_some()
);
}