const http = require('http');
const port = 34332;

function testArgs(args) {
    return new Promise((resolve) => {
        const req = http.request(`http://127.0.0.1:${port}/test-rpc`, {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' }
        }, (res) => {
            let data = '';
            res.on('data', c => data += c);
            res.on('end', () => {
                console.log(`Args ${JSON.stringify(args)}: ${data.substring(0, 100)}`);
                resolve();
            });
        });
        req.write(JSON.stringify({ method: 'GetCascadeTrajectorySteps', args }));
        req.end();
    });
}

async function run() {
    const id = "370d1a09-1fa8-4aed-90d7-4024e36b3a2d";
    await testArgs({ cascadeId: id, verbosity: 1 });
    await testArgs({ trajectoryId: id, verbosity: 1 });
    await testArgs({ id: id, verbosity: 1 });
    await testArgs({ googleAgentId: id, verbosity: 1 });
}
run();
