test: add upgrade home fixture coverage
This commit is contained in:
parent
1a6d9db913
commit
3fbd64f131
3 changed files with 120 additions and 4 deletions
|
|
@ -207,6 +207,106 @@ fn backup_create_and_restore_use_separate_home_without_private_identity_keys() {
|
|||
assert!(!restore_home.join("identity/agent.ed25519").exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn synthetic_pre_release_home_migrates_forward() {
|
||||
let home = tempfile::tempdir().expect("tempdir");
|
||||
let init = run_geth(home.path(), &["init"]);
|
||||
assert!(
|
||||
init.status.success(),
|
||||
"stderr: {}",
|
||||
String::from_utf8_lossy(&init.stderr)
|
||||
);
|
||||
|
||||
let db_path = home.path().join("geth.sqlite");
|
||||
let conn = rusqlite::Connection::open(&db_path).expect("open metadata");
|
||||
conn.execute(
|
||||
"INSERT OR REPLACE INTO keychain_ops(op_id, op_json, created_at_ms) VALUES (?1, ?2, ?3)",
|
||||
(
|
||||
"keychain-op:upgrade-fixture",
|
||||
r#"{"id":"keychain-op:upgrade-fixture"}"#,
|
||||
10_i64,
|
||||
),
|
||||
)
|
||||
.expect("insert keychain op");
|
||||
conn.execute(
|
||||
"INSERT OR REPLACE INTO auth_ops(op_id, resource_id, op_json, created_at_ms) VALUES (?1, ?2, ?3, ?4)",
|
||||
(
|
||||
"auth-op:upgrade-fixture",
|
||||
"resource:kv:prefs",
|
||||
r#"{"id":"auth-op:upgrade-fixture"}"#,
|
||||
11_i64,
|
||||
),
|
||||
)
|
||||
.expect("insert auth op");
|
||||
conn.execute(
|
||||
"INSERT OR REPLACE INTO cas_objects(hash, size_bytes, path, created_at_ms) VALUES (?1, ?2, ?3, ?4)",
|
||||
(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
4_i64,
|
||||
"cas/blobs/fixture",
|
||||
12_i64,
|
||||
),
|
||||
)
|
||||
.expect("insert cas object");
|
||||
conn.execute(
|
||||
"INSERT OR REPLACE INTO cas_pins(hash, pinned_at_ms) VALUES (?1, ?2)",
|
||||
(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
13_i64,
|
||||
),
|
||||
)
|
||||
.expect("insert cas pin");
|
||||
conn.execute(
|
||||
"INSERT OR REPLACE INTO peer_cards(peer_id, card_json, updated_at_ms) VALUES (?1, ?2, ?3)",
|
||||
(
|
||||
"node:upgrade-peer",
|
||||
r#"{"node_id":"node:upgrade-peer","fixture":true}"#,
|
||||
14_i64,
|
||||
),
|
||||
)
|
||||
.expect("insert peer card");
|
||||
conn.execute(
|
||||
"INSERT INTO meta(key, value) VALUES ('schema_version', '1')
|
||||
ON CONFLICT(key) DO UPDATE SET value = excluded.value",
|
||||
[],
|
||||
)
|
||||
.expect("downgrade schema marker");
|
||||
drop(conn);
|
||||
|
||||
let upgrade = run_geth(home.path(), &["init"]);
|
||||
assert!(
|
||||
upgrade.status.success(),
|
||||
"stderr: {}",
|
||||
String::from_utf8_lossy(&upgrade.stderr)
|
||||
);
|
||||
|
||||
let conn = rusqlite::Connection::open(&db_path).expect("open upgraded metadata");
|
||||
let schema_version: String = conn
|
||||
.query_row(
|
||||
"SELECT value FROM meta WHERE key = 'schema_version'",
|
||||
[],
|
||||
|row| row.get(0),
|
||||
)
|
||||
.expect("schema version");
|
||||
assert_eq!(
|
||||
schema_version,
|
||||
geth_store::CURRENT_SCHEMA_VERSION.to_string()
|
||||
);
|
||||
for (table, column) in [
|
||||
("keychain_ops", "op_id"),
|
||||
("auth_ops", "op_id"),
|
||||
("cas_pins", "hash"),
|
||||
("peer_cards", "peer_id"),
|
||||
] {
|
||||
let count: i64 = conn
|
||||
.query_row(&format!("SELECT COUNT({column}) FROM {table}"), [], |row| {
|
||||
row.get(0)
|
||||
})
|
||||
.expect("fixture count");
|
||||
assert!(count > 0, "{table} fixture row should survive upgrade");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cli_help_documents_owner_init_keys() {
|
||||
let home = tempfile::tempdir().expect("tempdir");
|
||||
|
|
|
|||
Loading…
Reference in a new issue