Simon Lee 1 year ago
parent
commit
d304499f45
3 changed files with 54 additions and 11 deletions
  1. 1
    0
      .env
  2. 10
    10
      TC2/start.ts
  3. 43
    1
      TC3/start.ts

+ 1
- 0
.env View File

RPCURL=http://193.123.252.127:80 RPCURL=http://193.123.252.127:80
CHAINID=1337 CHAINID=1337
GATE_WAY=https://api.stopulse.co.kr/main/v1/ GATE_WAY=https://api.stopulse.co.kr/main/v1/
GATE_WAY_RAW=https://api.stopulse.co.kr/
AUTHTOKEN=580c6006687220df84f83d7c345c00ad9829de0694bd00c09e211d8c810b7510 AUTHTOKEN=580c6006687220df84f83d7c345c00ad9829de0694bd00c09e211d8c810b7510

+ 10
- 10
TC2/start.ts View File



console.log(firstTx); console.log(firstTx);


// const lastB = await getBlockInfo(lastBlockHash);
// const lastTimeStamp = parseInt(lastB.timestamp,16);
// console.log(`eth_getBlockByHash(${lastBlockHash}).timestamp = ${lastTimeStamp}`)
const lastB = await getBlockInfo(lastBlockHash);
const lastTimeStamp = parseInt(lastB.timestamp,16);
console.log(`eth_getBlockByHash(${lastBlockHash}).timestamp = ${lastTimeStamp}`)


// const d = new Date(lastTimeStamp * 1000);
// console.log(chalk.cyan(`전송종료 시간(블록완결시간) : ${d.toUTCString()}`));
const d = new Date(lastTimeStamp * 1000);
console.log(chalk.cyan(`전송종료 시간(블록완결시간) : ${d.toUTCString()}`));


// console.log(chalk.yellow(`start timestamp = ${start}`));
// console.log(chalk.yellow(`end timestamp = ${lastTimeStamp * 1000}`));
console.log(chalk.yellow(`start timestamp = ${start}`));
console.log(chalk.yellow(`end timestamp = ${lastTimeStamp * 1000}`));


// const tps = calc.CTPS(count,start,lastTimeStamp * 1000);
// console.log(`CTPS = ${tps}`);
const tps = calc.CTPS(count,start,lastTimeStamp * 1000);
console.log(`CTPS = ${tps}`);


} }


console.log(`목적 서버 : ${gateWay}`); console.log(`목적 서버 : ${gateWay}`);


async function main() { async function main() {
transfer(holder1,'BCG_TEST',holder1, holder2,1, 1);
transfer(holder1,'BCG_TEST',holder1, holder2,1, 1000);
} }


main(); main();

+ 43
- 1
TC3/start.ts View File

return axios.get(gateWay + path, getAuthHeader(authToken)); return axios.get(gateWay + path, getAuthHeader(authToken));
} }



async function health() : Promise<any> {
const path = `health`;
return axios.get(gateWayRaw + path, getAuthHeader(authToken));
}

function getAuthHeader(token: string) : any{ function getAuthHeader(token: string) : any{
return { return {
headers: { headers: {
}; };
} }


async function readHealth(symbol:string, holder: Wallet, count: number = 100): Promise<any> {

const proxy = getDeploymentAddresses(symbol).address;
console.log(`토큰 주소 : ${proxy}`);
// const balance = await getBalance(symbol,holder.address);
// console.log(chalk.blue(`잔고(${holder.address}) = ${balance}`));
const start = Date.now();
console.log(chalk.cyan(`조회시작 시간 : ${new Date(start).toUTCString()}`));
console.log(chalk.yellow(`reading balance ${count} times`));

let proms = [];
for(let i = 0; i < count; i++) {
proms.push(health());
}
let resolved = await Promise.all(proms);
assert(count == resolved.length);
resolved.forEach(b => {
//console.log(b.data);
console.log(b);
});

const end = Date.now();
const elapsed = getElapsed(start,1000);
console.log(`request finished in ${elapsed} seconds`);

const CEPS = calc.CQPS(count,start,end);
console.log(`CQPS = ${CEPS}`);

return 0;
}


async function readTest(symbol:string, holder: Wallet, count: number = 100): Promise<any> { async function readTest(symbol:string, holder: Wallet, count: number = 100): Promise<any> {


const calc = new Calulator(); const calc = new Calulator();
const rpcUrl = process.env.RPCURL; const rpcUrl = process.env.RPCURL;
const gateWay = process.env.GATE_WAY; const gateWay = process.env.GATE_WAY;
const gateWayRaw=process.env.GATE_WAY_RAW;
const authToken=process.env.AUTHTOKEN; const authToken=process.env.AUTHTOKEN;
const fetchRequest = new FetchRequest(rpcUrl); const fetchRequest = new FetchRequest(rpcUrl);
console.log(rpcUrl) console.log(rpcUrl)
console.log(`목적 서버 : ${gateWay}`); console.log(`목적 서버 : ${gateWay}`);


async function main() { async function main() {
await readTest('BCG_TEST',holder1,1000);
await readHealth('BCG_TEST',holder1,10);
//await readTest('BCG_TEST',holder1,1000);
} }


main(); main();

Loading…
Cancel
Save