tests: cover CLI prefix stripping, set-pin gate, paged reply bounds, and ACL write failures

Changelog: -
This commit is contained in:
tth committed 2026-12-02 00:36:05 +01:00
1 parent 0dcc9c6e06
commit 5f31fc8e50
6 files changed
+192 -35

No files matched your search

@@ -187,6 +187,44 @@ TEST(AclReplayFloor, AlternatesSlotsAcrossReboots) {
}
}
TEST(AclReplayFloor, FailedOpenDoesNotRotateSlot) {
Node n;
ClientInfo* c = n.admin(1);
ASSERT_TRUE(n.accept(c, NOW - 30)); // slot 0 -> next slot 1
ASSERT_TRUE(n.accept(c, NOW - 20)); // slot 1 -> next slot 0 (oldest)
n.acl->save(&n.fs);
// Open fails on slot 0: must NOT advance to slot 1 (which holds NOW - 20).
n.fs.fail_next_write_open = true;
ASSERT_TRUE(n.accept(c, NOW - 15));
// Next write is torn; because slot stayed 0, slot 1 (NOW - 20) stays intact.
n.fs.short_next_write = 5;
ASSERT_TRUE(n.accept(c, NOW - 10));
n.boot();
c = n.acl->getClient(idFor(1).pub_key, PUB_KEY_SIZE);
EXPECT_EQ(c->last_timestamp, NOW - 20);
}
TEST(AclReplayFloor, ShortWriteDoesNotRotateSlot) {
Node n;
ClientInfo* c = n.admin(1);
ASSERT_TRUE(n.accept(c, NOW - 30)); // slot 0
ASSERT_TRUE(n.accept(c, NOW - 20)); // slot 1
n.acl->save(&n.fs);
// Two consecutive short writes must both target slot 0 and leave slot 1 intact.
n.fs.short_next_write = 4;
ASSERT_TRUE(n.accept(c, NOW - 15));
n.fs.short_next_write = 4;
ASSERT_TRUE(n.accept(c, NOW - 10));
n.boot();
c = n.acl->getClient(idFor(1).pub_key, PUB_KEY_SIZE);
EXPECT_EQ(c->last_timestamp, NOW - 20);
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();