Simon Lee 1年前
父节点
当前提交
d304499f45
共有 3 个文件被更改,包括 54 次插入11 次删除
  1. 1
    0
      .env
  2. 10
    10
      TC2/start.ts
  3. 43
    1
      TC3/start.ts

+ 1
- 0
.env 查看文件

@@ -8,4 +8,5 @@
RPCURL=http://193.123.252.127:80
CHAINID=1337
GATE_WAY=https://api.stopulse.co.kr/main/v1/
GATE_WAY_RAW=https://api.stopulse.co.kr/
AUTHTOKEN=580c6006687220df84f83d7c345c00ad9829de0694bd00c09e211d8c810b7510

+ 10
- 10
TC2/start.ts 查看文件

@@ -165,18 +165,18 @@ async function transfer(signer: Wallet,symbol:string,from: Wallet, to: Wallet, a

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}`);

}

@@ -199,7 +199,7 @@ const holder2 = new Wallet('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae
console.log(`목적 서버 : ${gateWay}`);

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

main();

+ 43
- 1
TC3/start.ts 查看文件

@@ -32,6 +32,12 @@ async function getBalanceAsc(symbol: string, address: string ): Promise<any> {
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{
return {
headers: {
@@ -42,6 +48,39 @@ function getAuthHeader(token: string) : any{
};
}

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> {

@@ -83,6 +122,7 @@ async function readTest(symbol:string, holder: Wallet, count: number = 100): Pro
const calc = new Calulator();
const rpcUrl = process.env.RPCURL;
const gateWay = process.env.GATE_WAY;
const gateWayRaw=process.env.GATE_WAY_RAW;
const authToken=process.env.AUTHTOKEN;
const fetchRequest = new FetchRequest(rpcUrl);
console.log(rpcUrl)
@@ -98,7 +138,9 @@ const holder2 = new Wallet('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae
console.log(`목적 서버 : ${gateWay}`);

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

main();

正在加载...
取消
保存