simon 1 년 전
부모
커밋
ed44b047b6
4개의 변경된 파일55개의 추가작업 그리고 48개의 파일을 삭제
  1. 2
    1
      .gitignore
  2. 25
    20
      TC4/start.ts
  3. 22
    5
      TC5/start.ts
  4. 6
    22
      inc/calc.ts

+ 2
- 1
.gitignore 파일 보기

node_modules node_modules
blockchain-info blockchain-info
sys-info
sys-info
temp

+ 25
- 20
TC4/start.ts 파일 보기

return nonce; return nonce;
} }


async function transfer(symbol:string, count: number = 10) {
async function transfer(symbol:string,from: Wallet, to: Wallet, amount: number = 1, count: number = 10) {


const proxy = getDeploymentAddresses(symbol).address; const proxy = getDeploymentAddresses(symbol).address;
console.log(`토큰 주소 : ${proxy}`); 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; const token = new SecurityToken__factory(issuer).attach(proxy) as SecurityToken;
await token.connect(admin); await token.connect(admin);
// const ops = await token.operators(); // const ops = await token.operators();
// console.log(ops); // console.log(ops);
let balance1= await token.balanceOf(holder1);
let balance2 = await token.balanceOf(holder2);
const b = await token.isTokenHolderKYC(holder1);
let balance1= await token.balanceOf(from);
let balance2 = await token.balanceOf(to);
const b = await token.isTokenHolderKYC(from);
if(!b) { if(!b) {
console.log('holder kyc error'); console.log('holder kyc error');
return; return;
} }
const partitions = await token.getDefaultPartitions(); const partitions = await token.getDefaultPartitions();
console.log(`holder1(sender) = ${balance1}, holder2(receiver) = ${balance2}`);
console.log(`balance of sender = ${balance1}, balance of receiver = ${balance2}`);
// token.on(token.filters.Transfer, async (...args) => { // token.on(token.filters.Transfer, async (...args) => {
// const lastArg = args[args.length - 1]; // const lastArg = args[args.length - 1];
// console.log(lastArg); // console.log(lastArg);
for(let i = 0; i < count; i++) { for(let i = 0; i < count; i++) {
const tx = await token.operatorTransferByPartition.populateTransaction( const tx = await token.operatorTransferByPartition.populateTransaction(
partitions[0], partitions[0],
holder1.address,
holder2.address,
1,
from.address,
to.address,
amount,
ZeroHash, ZeroHash,
ZeroHash, ZeroHash,
{ {


const firstBlockHash = blockHashes.get(firstTx); const firstBlockHash = blockHashes.get(firstTx);
const lastBlockHash = blockHashes.get(lastTx); const lastBlockHash = blockHashes.get(lastTx);
console.log(`firstBlockHash = ${firstBlockHash} , lastBlockHash = ${lastBlockHash}`);
console.log(`firstBlockHash = ${firstBlockHash} \nlastBlockHash = ${lastBlockHash}`);


const lastB = await getBlockInfo(lastBlockHash); const lastB = await getBlockInfo(lastBlockHash);
console.log(lastB.timestamp);
// console.log(lastB.timestamp);
const lastTimeStamp = parseInt(lastB.timestamp,16); const lastTimeStamp = parseInt(lastB.timestamp,16);


balance1= await token.balanceOf(holder1);
balance2 = await token.balanceOf(holder2);
console.log(`holder1 = ${balance1}, holder2 = ${balance2}`);
balance1= await token.balanceOf(from);
balance2 = await token.balanceOf(to);
console.log(`balance of sender = ${balance1}, balance of receiver = ${balance2}`);


const d = new Date(lastTimeStamp * 1000); const d = new Date(lastTimeStamp * 1000);
console.log(start); console.log(start);
console.log(lastTimeStamp * 1000); console.log(lastTimeStamp * 1000);


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


} }





const calc = new Calulator(); const calc = new Calulator();
const rpcUrl = process.env.RPCURL; const rpcUrl = process.env.RPCURL;
const provider = new JsonRpcProvider(rpcUrl); const provider = new JsonRpcProvider(rpcUrl);
setProvider(provider); setProvider(provider);


const admin = new Wallet('0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3',provider);
const issuer = new Wallet('0x8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63',provider);
const holder1 = new Wallet('0xae6ae8e5ccbfb04590405997ee2d52d2b330726137b875053c36d94e974d162f',provider);
const holder2 = new Wallet('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',provider);

async function main() { async function main() {
transfer('test001',1000);
transfer('test001',holder1, holder2,1, 1000);
// for(let i = 13489; i < 13492; i++ ) { // for(let i = 13489; i < 13492; i++ ) {
// try { // try {
// await send(i); // await send(i);

+ 22
- 5
TC5/start.ts 파일 보기

import * as dotevnv from "dotenv" import * as dotevnv from "dotenv"
import {toUtf8String,parseUnits,ContractFactory, parseEther,JsonRpcProvider, Contract, JsonRpcSigner, Wallet,ContractTransactionResponse, MaxInt256 import {toUtf8String,parseUnits,ContractFactory, parseEther,JsonRpcProvider, Contract, JsonRpcSigner, Wallet,ContractTransactionResponse, MaxInt256
,Transaction,formatEther, ,Transaction,formatEther,
ZeroHash,ethers,keccak256
ZeroHash,ethers,keccak256,
FetchRequest,JsonRpcApiProviderOptions
} from 'ethers' } from 'ethers'
import {Calulator} from "../inc/calc"; import {Calulator} from "../inc/calc";
import { TokenIssuer } from "../inc/TokenIssuer"; import { TokenIssuer } from "../inc/TokenIssuer";






const start = Date.now();
let proms = []; let proms = [];
for(let i = 0; i < count; i++) { for(let i = 0; i < count; i++) {
proms.push(token.balanceOf(holder1)); proms.push(token.balanceOf(holder1));
assert(count == resolved.length); assert(count == resolved.length);


resolved.forEach(balance => { resolved.forEach(balance => {
console.log(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; return 0;
} }


const calc = new Calulator(); const calc = new Calulator();
const rpcUrl = process.env.RPCURL; const rpcUrl = process.env.RPCURL;
const provider = new JsonRpcProvider(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); setProvider(provider);
console.log(`목적 서버 : ${rpcUrl}`); console.log(`목적 서버 : ${rpcUrl}`);


async function main() { async function main() {
await readTest('test001');
await readTest('test001',1000);
} }


main(); main();

+ 6
- 22
inc/calc.ts 파일 보기

export class Calulator { export class Calulator {
// timestamp format input // timestamp format input
CTPS_NUM(count: number, start: number, end: number): number {
CTPS(count: number, start: number, end: number): number {
// Calculate the time difference in milliseconds // Calculate the time difference in milliseconds
const timeDifference = (end - start) / 1000; const timeDifference = (end - start) / 1000;
// Ensure timeDifference is not zero to avoid division by zero // Ensure timeDifference is not zero to avoid division by zero
if (timeDifference === 0) { if (timeDifference === 0) {
throw new Error("Time difference cannot be zero."); throw new Error("Time difference cannot be zero.");
} }

console.log(`time diff = ${timeDifference}`); console.log(`time diff = ${timeDifference}`);

// Calculate CTPS // Calculate CTPS
const CEPS = count / timeDifference; const CEPS = count / timeDifference;
return CEPS; return CEPS;
} }


CTPS(count: number, start: Date, end: Date): number {
CQPS(count: number, start: number, end: number): number {
// Calculate the time difference in milliseconds // Calculate the time difference in milliseconds
const timeDifference = end.getTime() - start.getTime();
const timeDifference = (end - start) / 1000;
// Ensure timeDifference is not zero to avoid division by zero // Ensure timeDifference is not zero to avoid division by zero
if (timeDifference === 0) { if (timeDifference === 0) {
throw new Error("Time difference cannot be zero."); throw new Error("Time difference cannot be zero.");
} }
// Calculate CTPS
console.log(`time diff = ${timeDifference}`);
// Calculate CEPS
const CEPS = count / timeDifference; const CEPS = count / timeDifference;
return CEPS;
}

CEPS(count: number, start: Date, end: Date): number {
// Calculate the time difference in milliseconds
const timeDifference = end.getTime() - start.getTime();

// Ensure timeDifference is not zero to avoid division by zero
if (timeDifference === 0) {
throw new Error("Time difference cannot be zero.");
}

// Calculate CEPS
const CEPS = count / timeDifference;
return CEPS;
return CEPS;
} }
} }



Loading…
취소
저장