|
|
|
@@ -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(); |