| import * as dotevnv from "dotenv" | |||||
| import {toUtf8String,parseUnits,ContractFactory, parseEther,JsonRpcProvider, Contract, JsonRpcSigner, Wallet,ContractTransactionResponse, MaxInt256 | |||||
| ,Transaction,formatEther, | |||||
| ZeroHash,ethers,keccak256, | |||||
| FetchRequest,JsonRpcApiProviderOptions | |||||
| } from 'ethers' | |||||
| import {Calulator} from "../inc/calc"; | |||||
| import { TokenIssuer } from "../inc/TokenIssuer"; | |||||
| import { | |||||
| SecurityToken, | |||||
| SecurityToken__factory, | |||||
| } from '../typechain' | |||||
| // import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers"; | |||||
| import {checkReceipt,checkReceipt2, setProvider,getDeploymentAddresses, | |||||
| getElapsed, sleep,getBlockInfo,getNonce} from '../inc/util' | |||||
| import { assert } from "console"; | |||||
| dotevnv.config(); | |||||
| if (!process.env.RPCURL) { | |||||
| console.log(`No rpcur value specified...`) | |||||
| } | |||||
| async function readTest(symbol:string, count: number = 100): Promise<any> { | |||||
| const proxy = getDeploymentAddresses(symbol).address; | |||||
| console.log(`토큰 주소 : ${proxy}`); | |||||
| const admin = new Wallet('0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3',provider); | |||||
| const issuer = new Wallet('0x8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63',provider); | |||||
| const holder1 = new Wallet('0xae6ae8e5ccbfb04590405997ee2d52d2b330726137b875053c36d94e974d162f',provider); | |||||
| const holder2 = new Wallet('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',provider); | |||||
| const token = new SecurityToken__factory(issuer).attach(proxy) as SecurityToken; | |||||
| let balance1= await token.balanceOf(holder1); | |||||
| let balance2 = await token.balanceOf(holder2); | |||||
| console.log(new Date()); | |||||
| const start = Date.now(); | |||||
| let proms = []; | |||||
| for(let i = 0; i < count; i++) { | |||||
| proms.push(token.balanceOf(holder1)); | |||||
| } | |||||
| let resolved = await Promise.all(proms); | |||||
| console.log(resolved.length); | |||||
| assert(count == resolved.length); | |||||
| resolved.forEach(balance => { | |||||
| // console.log(balance); | |||||
| if(balance != balance1) { | |||||
| console.log(balance); | |||||
| } | |||||
| }); | |||||
| const end = Date.now(); | |||||
| const elapsed = getElapsed(start,1000); | |||||
| console.log(`all tx sent in ${elapsed} seconds`); | |||||
| const CEPS = calc.CQPS(count,start,end); | |||||
| console.log(`CQPS = ${CEPS}`); | |||||
| return 0; | |||||
| } | |||||
| const calc = new Calulator(); | |||||
| const rpcUrl = process.env.RPCURL; | |||||
| const fetchRequest = new FetchRequest(rpcUrl); | |||||
| console.log(rpcUrl) | |||||
| fetchRequest.timeout = 10000; | |||||
| // const provider = new JsonRpcProvider(fetchRequest,null,{batchMaxSize: 5, batchMaxCount: 100}); | |||||
| const provider = new JsonRpcProvider(fetchRequest); | |||||
| setProvider(provider); | |||||
| console.log(`목적 서버 : ${rpcUrl}`); | |||||
| async function main() { | |||||
| await readTest('test001',4000); | |||||
| } | |||||
| main(); | |||||