const { LSBridge } = require('./extension/out/sdk/ls-bridge');

async function test() {
    const ls = new LSBridge();
    await ls.connect();
    
    console.log("Testing { limit: 5, descending: true }...");
    let start = Date.now();
    const res = await ls._rpc('GetAllCascadeTrajectories', { limit: 5, descending: true });
    let duration = Date.now() - start;
    
    const summaries = res.trajectorySummaries || {};
    const keys = Object.keys(summaries);
    console.log(`Execution time: ${duration}ms`);
    console.log(`Returned entries: ${keys.length}`);
    
    keys.slice(0, 5).forEach((k, idx) => {
        const modT = summaries[k].lastModifiedTime || summaries[k].lastModifiedTimestamp || 'UNKNOWN';
        console.log(`[${idx}] id=${k.substring(0,8)} mod=${modT} status=${summaries[k].status}`);
    });

    console.log("\nTesting { limit: 100, descending: true }...");
    start = Date.now();
    const res100 = await ls._rpc('GetAllCascadeTrajectories', { limit: 100, descending: true });
    duration = Date.now() - start;
    console.log(`Execution time: ${duration}ms`);
    console.log(`Returned entries: ${Object.keys(res100.trajectorySummaries || {}).length}`);

    ls.disconnect();
}
test();
