Check live FIR enable state before each analysis
Deploy B9 / deploy (push) Successful in 3m36s

This commit is contained in:
fucheng
2026-11-05 14:33:36 +08:00
parent 4b3b86f256
commit d20d2bb11e
4 changed files with 59 additions and 5 deletions
+33
View File
@@ -237,3 +237,36 @@ test('A/B WAV exports preserve coefficients and signed zero', () => {
}
}
});
test("each FIR analysis rechecks live switch, including enabled then disabled", async () => {
let enabled = 1;
const calls = [];
const coefficients = pair();
const api = {
async getDeviceState() { calls.push("state"); return {fir_enable: enabled}; },
async getFirChannel(channel) { calls.push(channel); return binary(coefficients[channel]); },
};
await fir.readEnabledCurrentFir(api);
assert.deepEqual(calls, ["state", "left", "right"]);
enabled = 0;
calls.length = 0;
await assert.rejects(() => fir.readEnabledCurrentFir(api), /Effect → FIR/);
assert.deepEqual(calls, ["state"]);
});
test("unknown or failed FIR switch reads block all coefficient reads", async () => {
for (const getDeviceState of [async () => ({}), async () => { throw new Error("offline"); }]) {
let reads = 0;
await assert.rejects(() => fir.readEnabledCurrentFir({getDeviceState, async getFirChannel() { reads++; }}));
assert.equal(reads, 0);
}
});
test("proposal prerequisite also checks live switch every time", async () => {
let enabled = 1;
const api = {async getDeviceState() { return {fir_enable: enabled}; }};
await fir.requireFirEnabled(api);
enabled = 0;
await assert.rejects(() => fir.requireFirEnabled(api), /Effect → FIR/);
});