token-consumer / test-token-rotation.js
qwen2api's picture
Upload 13 files
5815428 verified
Raw
History Blame Contribute Delete
1.17 kB
const { getNextToken } = require('./executor');
// Test token rotation
function testTokenRotation() {
console.log('Testing token rotation...');
// Test with multiple tokens
const config = {
token: 'token1, token2, token3'
};
console.log('Testing with tokens:', config.token);
// Get tokens multiple times to test rotation
for (let i = 0; i < 10; i++) {
const { token, index, total } = getNextToken(config);
console.log(`Request ${i+1}: Using token: ${token} (Key: ${index+1}/${total})`);
}
// Test with single token
const singleTokenConfig = {
token: 'single-token'
};
console.log('\nTesting with single token:', singleTokenConfig.token);
for (let i = 0; i < 3; i++) {
const { token, index, total } = getNextToken(singleTokenConfig);
console.log(`Request ${i+1}: Using token: ${token} (Key: ${index+1}/${total})`);
}
// Test with empty token
const emptyTokenConfig = {
token: ''
};
console.log('\nTesting with empty token:');
const { token, index, total } = getNextToken(emptyTokenConfig);
console.log(`Using token: ${token} (Key: ${index+1}/${total})`);
}
testTokenRotation();