gent-daemon 0.1.2

Local daemon, storage and synchronization for Gent chat clusters.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
use super::*;
use gent_crypto::succession::journal::{MAX_BYTES, Manifest, PAGE_BYTES};

fn count(pair: &Pair, i: usize, table: &str) -> u64 {
    pair.stores[i]
        .db
        .query_row(&format!("SELECT COUNT(*) FROM {table}"), [], |r| r.get(0))
        .unwrap()
}

fn signed_snapshot(
    pair: &Pair,
    candidate: &SignedOwnerCandidate,
    entries: usize,
    body: &[u8],
) -> (Manifest, SignedOwnerTransition) {
    let manifest = Manifest::new(candidate, entries, body).unwrap();
    let state = pair.stores[0].identity.state(&pair.stores[0].db).unwrap();
    let authorization = state
        .authorize_owner_candidate_with_journal(
            pair.stores[0].identity.owner.as_ref().unwrap(),
            candidate,
            manifest.digest().unwrap(),
            now() as u64,
        )
        .unwrap();
    (manifest, authorization)
}

#[tokio::test]
async fn completed_and_lost_results_transfer_without_applying_edits_or_installing_authority() {
    let mut pair = Pair::new().await;
    let applied = Uuid::new_v4().to_string();
    let rejected = Uuid::new_v4().to_string();
    configure(
        &mut pair,
        1,
        &applied,
        ConfigurationEdit::RenameNode {
            name: "journal-test".into(),
        },
    )
    .unwrap();
    configure(
        &mut pair,
        1,
        &rejected,
        ConfigurationEdit::DeleteGroup {
            name: "does-not-exist".into(),
        },
    )
    .unwrap();
    pair.pump();
    let saved: Vec<u8> = pair.stores[1]
        .db
        .query_row(
            "SELECT result FROM configuration_edits WHERE id=?1",
            [&rejected],
            |r| r.get(0),
        )
        .unwrap();
    assert_eq!(
        serde_json::from_slice::<Value>(&saved).unwrap()["state"],
        "rejected"
    );
    // Model the lost result while retaining its accepted configuration revision.
    pair.stores[1]
        .db
        .execute(
            "UPDATE configuration_edits SET result=NULL WHERE id=?1",
            [&applied],
        )
        .unwrap();
    let candidate = prepare(&mut pair);
    let keys = [credential(&pair, 0), credential(&pair, 1)];
    let before = [
        count(&pair, 1, "configuration_edits"),
        count(&pair, 1, "authority_digests"),
    ];
    let authorization = issue(&mut pair, &candidate);
    let manifest = pair.stores[0]
        .owner_handoff_manifest(&keys[0], &candidate.candidate.id)
        .unwrap();
    let body = pair.stores[0]
        .owner_handoff_page(&keys[0], &candidate.candidate.id, 0)
        .unwrap();
    let decisions: Vec<Value> = serde_json::from_slice(&body).unwrap();
    assert!(
        decisions
            .iter()
            .any(|d| d["id"] == applied && d["result"]["state"] == "applied")
    );
    assert!(
        decisions
            .iter()
            .any(|d| d["id"] == rejected && d["result"]["state"] == "rejected")
    );
    assert_eq!(manifest.entries, decisions.len());
    pair.reopen(1);
    pair.stores[1]
        .accept_owner_handoff(&keys[1], &candidate.candidate.id, &authorization)
        .unwrap();
    assert_eq!(
        before,
        [
            count(&pair, 1, "configuration_edits"),
            count(&pair, 1, "authority_digests")
        ]
    );
    assert!(
        pair.stores[1]
            .db
            .query_row(
                "SELECT result IS NULL FROM configuration_edits WHERE id=?1",
                [&applied],
                |r| r.get::<_, bool>(0)
            )
            .unwrap()
    );
    assert_eq!(
        pair.stores[1]
            .identity
            .state(&pair.stores[1].db)
            .unwrap()
            .checkpoint(),
        &candidate.candidate.base
    );
    assert!(
        !pair.stores[1]
            .identity
            .is_current_owner(&pair.stores[1].identity.state(&pair.stores[1].db).unwrap())
    );
}

#[tokio::test]
async fn partial_out_of_order_transfer_survives_restart_and_authenticates_every_retry() {
    let mut pair = Pair::new().await;
    let origin = pair.stores[0].identity.node.id().to_owned();
    let result = serde_json::to_vec(&crate::messages::EditResult::Rejected {
        reason: "r".repeat(1024),
    })
    .unwrap();
    let fingerprint = hash(&serde_json::to_string(&ConfigurationEdit::Renew).unwrap());
    // Many independently keyed, completed decisions exercise a multi-page journal.
    pair.stores[0].db.execute("WITH RECURSIVE n(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM n WHERE x<600) INSERT INTO configuration_edits SELECT ?1,printf('00000000-0000-4000-8000-%012x',x),?1,?2,?3,?4,1 FROM n", params![origin, fingerprint, br#"{"op":"renew"}"#.as_slice(), result]).unwrap();
    let candidate = prepare(&mut pair);
    let id = &candidate.candidate.id;
    let keys = [credential(&pair, 0), credential(&pair, 1)];
    prepare_readiness(&mut pair, &candidate);
    let authorization = pair.stores[0]
        .authorize_owner_handoff(&keys[0], &candidate)
        .unwrap();
    let manifest = pair.stores[0].owner_handoff_manifest(&keys[0], id).unwrap();
    assert!(manifest.pages.len() >= 3);
    assert!(
        pair.stores[1]
            .accept_owner_handoff(&keys[1], id, &authorization)
            .is_err()
    );
    let initial = pair.stores[1]
        .begin_owner_handoff_import(&keys[1], id, &authorization, &manifest)
        .unwrap();
    assert_eq!(initial["received"], 0);
    for index in (1..manifest.pages.len()).rev() {
        let page = pair.stores[0]
            .owner_handoff_page(&keys[0], id, index)
            .unwrap();
        let mut damaged = page.clone();
        damaged[0] ^= 1;
        assert!(
            pair.stores[1]
                .import_owner_handoff_page(&keys[1], id, index, &damaged)
                .is_err()
        );
        let progress = pair.stores[1]
            .import_owner_handoff_page(&keys[1], id, index, &page)
            .unwrap();
        assert_eq!(progress["pages_complete"], false);
        pair.reopen(1);
        assert_eq!(
            pair.stores[1]
                .import_owner_handoff_page(&keys[1], id, index, &page)
                .unwrap(),
            progress
        );
        assert!(
            pair.stores[1]
                .accept_owner_handoff(&keys[1], id, &authorization)
                .is_err()
        );
    }
    pair.reopen(0);
    assert_eq!(
        pair.stores[0].owner_handoff_manifest(&keys[0], id).unwrap(),
        manifest
    );
    let progress = pair.stores[1]
        .begin_owner_handoff_import(&keys[1], id, &authorization, &manifest)
        .unwrap();
    assert_eq!(progress["missing"], json!([0]));
    let page = pair.stores[0].owner_handoff_page(&keys[0], id, 0).unwrap();
    assert!(
        pair.stores[1]
            .import_owner_handoff_page(&keys[1], id, manifest.pages.len(), &page)
            .is_err()
    );
    pair.stores[1].db.execute_batch("CREATE TRIGGER fail_page BEFORE INSERT ON owner_journal_pages BEGIN SELECT RAISE(ABORT,'journal failure'); END;").unwrap();
    assert!(
        pair.stores[1]
            .import_owner_handoff_page(&keys[1], id, 0, &page)
            .is_err()
    );
    assert_eq!(
        pair.stores[1]
            .owner_handoff_import_status(&keys[1], id)
            .unwrap(),
        progress
    );
    pair.stores[1]
        .db
        .execute_batch("DROP TRIGGER fail_page;")
        .unwrap();
    assert_eq!(
        pair.stores[1]
            .import_owner_handoff_page(&keys[1], id, 0, &page)
            .unwrap()["pages_complete"],
        true
    );
    let complete = pair.stores[1]
        .accept_owner_handoff(&keys[1], id, &authorization)
        .unwrap();
    pair.reopen(1);
    assert_eq!(
        pair.stores[1]
            .accept_owner_handoff(&keys[1], id, &authorization)
            .unwrap()
            .encode()
            .unwrap(),
        complete.encode().unwrap()
    );
    assert!(
        pair.stores[1]
            .identity
            .apply(&pair.stores[1].db, complete)
            .is_err()
    );
}

#[tokio::test]
async fn signed_but_conflicting_or_malformed_journals_roll_back_the_final_page() {
    let mut pair = Pair::new().await;
    let request = Uuid::new_v4().to_string();
    configure(
        &mut pair,
        1,
        &request,
        ConfigurationEdit::RenameNode {
            name: "known-result".into(),
        },
    )
    .unwrap();
    pair.pump();
    let state = pair.stores[0].identity.state(&pair.stores[0].db).unwrap();
    let (entries, body) = crate::store::configuration::storage::handoff::snapshot(
        &pair.stores[0].db,
        state.checkpoint(),
    )
    .unwrap();
    let original: Vec<Value> = serde_json::from_slice(&body).unwrap();
    let index = original.iter().position(|d| d["id"] == request).unwrap();
    let key = credential(&pair, 1);
    for change in 0..10 {
        let candidate = prepare(&mut pair);
        let id = &candidate.candidate.id;
        let mut changed = original.clone();
        match change {
            0 => changed[index]["writer"] = json!(Uuid::new_v4().to_string()),
            1 => changed[index]["fingerprint"] = json!("f".repeat(64)),
            2 => changed[index]["summary"] = json!({"op":"renew"}),
            3 => changed[index]["result"] = json!({"state":"rejected","reason":"different"}),
            4 => {
                let byte = changed[index]["result"]["checkpoint"]["state_hash"][0]
                    .as_u64()
                    .unwrap();
                changed[index]["result"]["checkpoint"]["state_hash"][0] = json!(byte ^ 1);
            }
            5 => changed.push(changed[index].clone()),
            6 => {
                changed[index]["result"]["checkpoint"]["revision"] =
                    json!(state.checkpoint().revision + 1)
            }
            7 => changed[index]["summary"]["extra"] = json!(true),
            8 => changed.reverse(),
            _ => {}
        }
        let mut changed = serde_jcs::to_vec(&changed).unwrap();
        if change == 9 {
            changed.push(b' ');
        }
        let count = if change == 5 { entries + 1 } else { entries };
        let (manifest, authorization) = signed_snapshot(&pair, &candidate, count, &changed);
        pair.stores[1]
            .begin_owner_handoff_import(&key, id, &authorization, &manifest)
            .unwrap();
        assert!(
            pair.stores[1]
                .import_owner_handoff_page(&key, id, 0, &changed)
                .is_err(),
            "mutation {change}"
        );
        assert_eq!(
            pair.stores[1]
                .owner_handoff_import_status(&key, id)
                .unwrap()["received"],
            0
        );
        assert!(
            pair.stores[1]
                .accept_owner_handoff(&key, id, &authorization)
                .is_err()
        );
    }
    assert_eq!(count(&pair, 1, "owner_journal_pages"), 0);
    assert_eq!(status(&mut pair, 1)["completed_candidates"], 0);
}

#[tokio::test]
async fn authorization_and_page_storage_commit_together_or_leave_the_owner_unfrozen() {
    let mut pair = Pair::new().await;
    let key = credential(&pair, 0);
    let candidate = prepare(&mut pair);
    prepare_readiness(&mut pair, &candidate);
    for table in ["owner_journals", "owner_journal_pages"] {
        pair.stores[0].db.execute_batch(&format!("CREATE TRIGGER fail_journal BEFORE INSERT ON {table} BEGIN SELECT RAISE(ABORT,'journal failure'); END;")).unwrap();
        assert!(
            pair.stores[0]
                .authorize_owner_handoff(&key, &candidate)
                .is_err()
        );
        assert_eq!(status(&mut pair, 0)["signing_frozen"], false);
        for table in ["owner_handoffs", "owner_journals", "owner_journal_pages"] {
            assert_eq!(count(&pair, 0, table), 0);
        }
        pair.stores[0]
            .identity
            .signing_owner(&pair.stores[0].db)
            .unwrap();
        pair.stores[0]
            .db
            .execute_batch("DROP TRIGGER fail_journal;")
            .unwrap();
        pair.reopen(0);
    }
    issue(&mut pair, &candidate);
    assert_eq!(status(&mut pair, 0)["signing_frozen"], true);
}

#[tokio::test]
async fn legacy_decisions_allow_missing_old_digests_but_never_overwrite_known_evidence() {
    let mut pair = Pair::new().await;
    let id = Uuid::new_v4().to_string();
    configure(&mut pair, 0, &id, ConfigurationEdit::Renew).unwrap();
    let checkpoint = pair.stores[0]
        .identity
        .state(&pair.stores[0].db)
        .unwrap()
        .checkpoint()
        .clone();
    configure(
        &mut pair,
        0,
        &Uuid::new_v4().to_string(),
        ConfigurationEdit::Renew,
    )
    .unwrap();
    pair.pump();
    pair.stores[0]
        .db
        .execute(
            "UPDATE configuration_edits SET edit=?1,compact=0 WHERE id=?2",
            params![serde_json::to_vec(&ConfigurationEdit::Renew).unwrap(), id],
        )
        .unwrap();
    // A later-enrolled successor may have no pre-enrollment digest evidence.
    pair.stores[1]
        .db
        .execute(
            "DELETE FROM authority_history WHERE revision=?1",
            [checkpoint.revision],
        )
        .unwrap();
    pair.stores[1]
        .db
        .execute(
            "DELETE FROM authority_digests WHERE revision=?1",
            [checkpoint.revision],
        )
        .unwrap();
    let before = count(&pair, 1, "authority_digests");
    let candidate = prepare(&mut pair);
    let authorization = issue(&mut pair, &candidate);
    let key = credential(&pair, 1);
    assert_eq!(count(&pair, 1, "authority_digests"), before);
    let conflict = [17u8; 32];
    pair.stores[1]
        .db
        .execute(
            "INSERT INTO authority_digests(revision,digest) VALUES(?1,?2)",
            params![checkpoint.revision, conflict.as_slice()],
        )
        .unwrap();
    assert!(
        pair.stores[1]
            .accept_owner_handoff(&key, &candidate.candidate.id, &authorization)
            .unwrap_err()
            .to_string()
            .contains("accepted authority")
    );
    assert_eq!(
        pair.stores[1]
            .db
            .query_row(
                "SELECT digest FROM authority_digests WHERE revision=?1",
                [checkpoint.revision],
                |r| r.get::<_, Vec<u8>>(0)
            )
            .unwrap(),
        conflict
    );
    assert_eq!(status(&mut pair, 1)["completed_candidates"], 0);
    pair.stores[1]
        .db
        .execute(
            "UPDATE authority_digests SET digest=?1 WHERE revision=?2",
            params![checkpoint.state_hash.as_slice(), checkpoint.revision],
        )
        .unwrap();
    pair.stores[1]
        .accept_owner_handoff(&key, &candidate.candidate.id, &authorization)
        .unwrap();
}

#[tokio::test]
async fn import_reserves_full_byte_budget_and_rejects_agents_and_changed_manifests() {
    let mut pair = Pair::new().await;
    let key = credential(&pair, 1);
    let mut first = None;
    for iteration in 0..3 {
        let candidate = prepare(&mut pair);
        let mut manifest = Manifest::new(&candidate, 0, b"[]").unwrap();
        manifest.bytes = MAX_BYTES;
        manifest.pages = vec![
            gent_crypto::succession::journal::Page {
                bytes: PAGE_BYTES,
                digest: [1; 32]
            };
            MAX_BYTES / PAGE_BYTES
        ];
        let state = pair.stores[0].identity.state(&pair.stores[0].db).unwrap();
        let authorization = state
            .authorize_owner_candidate_with_journal(
                pair.stores[0].identity.owner.as_ref().unwrap(),
                &candidate,
                manifest.digest().unwrap(),
                now() as u64,
            )
            .unwrap();
        assert!(
            pair.stores[1]
                .begin_owner_handoff_import(
                    &pair.keys[1],
                    &candidate.candidate.id,
                    &authorization,
                    &manifest
                )
                .is_err()
        );
        let result = pair.stores[1].begin_owner_handoff_import(
            &key,
            &candidate.candidate.id,
            &authorization,
            &manifest,
        );
        if iteration < 2 {
            result.unwrap();
        } else {
            assert!(result.unwrap_err().to_string().contains("budget exhausted"));
        }
        if first.is_none() {
            first = Some((candidate, manifest, authorization));
        }
    }
    let (candidate, manifest, authorization) = first.unwrap();
    let id = &candidate.candidate.id;
    pair.reopen(1);
    pair.stores[1]
        .begin_owner_handoff_import(&key, id, &authorization, &manifest)
        .unwrap();
    assert_eq!(
        status(&mut pair, 1)["journal_transfer"]["reserved_bytes"],
        2 * MAX_BYTES
    );
    assert_eq!(count(&pair, 1, "owner_journal_pages"), 0);
    assert!(
        pair.stores[1]
            .import_owner_handoff_page(&pair.keys[1], id, 0, b"[]")
            .is_err()
    );
    assert!(
        pair.stores[1]
            .owner_handoff_import_status(&pair.keys[1], id)
            .is_err()
    );
    let (changed, auth) = signed_snapshot(&pair, &candidate, 0, b"[]");
    assert!(
        pair.stores[1]
            .begin_owner_handoff_import(&key, id, &auth, &changed)
            .is_err()
    );
    let other = prepare(&mut pair);
    assert!(
        pair.stores[1]
            .begin_owner_handoff_import(&key, &other.candidate.id, &authorization, &manifest)
            .is_err()
    );
}

#[tokio::test]
async fn source_corruption_blocks_export_without_restoring_signing() {
    let mut pair = Pair::new().await;
    let candidate = prepare(&mut pair);
    let id = &candidate.candidate.id;
    let key = credential(&pair, 0);
    issue(&mut pair, &candidate);
    assert!(
        pair.stores[0]
            .owner_handoff_manifest(&pair.keys[0], id)
            .is_err()
    );
    assert!(
        pair.stores[0]
            .owner_handoff_page(&pair.keys[0], id, 0)
            .is_err()
    );
    pair.stores[0]
        .db
        .execute(
            "UPDATE owner_journal_pages SET body=x'00' WHERE id=?1",
            [id],
        )
        .unwrap();
    assert!(pair.stores[0].owner_handoff_page(&key, id, 0).is_err());
    assert!(
        pair.stores[0]
            .identity
            .signing_owner(&pair.stores[0].db)
            .is_err()
    );
    pair.stores[0]
        .db
        .execute("DELETE FROM owner_journal_pages WHERE id=?1", [id])
        .unwrap();
    assert!(pair.stores[0].owner_handoff_page(&key, id, 0).is_err());
    pair.stores[0]
        .db
        .execute("DELETE FROM owner_journals WHERE id=?1", [id])
        .unwrap();
    assert!(Store::open(pair.homes[0].path()).is_err());
    assert!(
        pair.stores[0]
            .identity
            .signing_owner(&pair.stores[0].db)
            .is_err()
    );
}

#[tokio::test]
async fn schema_eighteen_migration_preserves_legacy_fence_keys_and_completed_candidate() {
    let mut pair = Pair::new().await;
    let candidate = prepare(&mut pair);
    let keys = [credential(&pair, 0), credential(&pair, 1)];
    let identity = pair
        .homes
        .each_ref()
        .map(|h| std::fs::read(h.path().join("identity.key")).unwrap());
    let state = pair.stores[0].identity.state(&pair.stores[0].db).unwrap();
    let authorization = state
        .authorize_owner_candidate(
            pair.stores[0].identity.owner.as_ref().unwrap(),
            &candidate,
            now() as u64,
        )
        .unwrap();
    pair.stores[0]
        .db
        .execute(
            "INSERT INTO owner_handoffs VALUES(?1,?2,?3,?4)",
            params![
                candidate.candidate.id,
                state.signed().encode().unwrap(),
                candidate.encode().unwrap(),
                authorization.encode().unwrap()
            ],
        )
        .unwrap();
    pair.stores[0]
        .db
        .execute(
            "UPDATE owner_handoff_control SET issued=?1",
            [&candidate.candidate.id],
        )
        .unwrap();
    let complete = pair.stores[1]
        .accept_owner_handoff(&keys[1], &candidate.candidate.id, &authorization)
        .unwrap();
    for (i, identity) in identity.iter().enumerate() {
        pair.stores[i].db.execute_batch("DROP TABLE owner_journal_pages; DROP TABLE owner_journals; PRAGMA user_version=18;").unwrap();
        pair.reopen(i);
        assert_eq!(
            std::fs::read(pair.homes[i].path().join("identity.key")).unwrap(),
            *identity
        );
        assert_eq!(
            pair.stores[i]
                .identity
                .state(&pair.stores[i].db)
                .unwrap()
                .checkpoint(),
            state.checkpoint()
        );
        assert_eq!(count(&pair, i, "owner_journals"), 0);
        assert_eq!(
            pair.stores[i]
                .db
                .pragma_query_value(None, "user_version", |r| r.get::<_, u32>(0))
                .unwrap(),
            26
        );
    }
    assert_eq!(status(&mut pair, 0)["signing_frozen"], true);
    assert_eq!(
        pair.stores[0]
            .authorize_owner_handoff(&keys[0], &candidate)
            .unwrap(),
        authorization
    );
    assert_eq!(
        pair.stores[1]
            .accept_owner_handoff(&keys[1], &candidate.candidate.id, &authorization)
            .unwrap()
            .encode()
            .unwrap(),
        complete.encode().unwrap()
    );
    assert!(
        pair.stores[1]
            .identity
            .apply(&pair.stores[1].db, complete)
            .is_err()
    );
}