Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ping-ke committed Aug 9, 2024
1 parent 5e5551c commit 37d14d2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 25 deletions.
1 change: 0 additions & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
git pull
npm install
git submodule init && git submodule update
npx hardhat run scripts/deployL2-it.js --network qkc_testnet >> deploy.log
echo ES_NODE_CONTRACT_ADDRESS=`cat .caddr` >> "$GITHUB_ENV"
- name: Build and Run Bootnode Node
Expand Down
75 changes: 51 additions & 24 deletions integration_tests/scripts/ituploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,63 @@ const privateKey = process.env.ES_NODE_SIGNER_PRIVATE_KEY;
const contractAddr = process.env.ES_NODE_CONTRACT_ADDRESS;
const RPC = 'http://65.109.20.29:8545';
const contractABI = [
"function lastKvIdx() public view returns (uint40)"
"function lastKvIdx() public view returns (uint40)"
]

const provider = new ethers.JsonRpcProvider(RPC);
const contract = new Contract(contractAddr, contractABI, provider);
const MAX_BLOB = 192n;
const MAX_BLOB = 256n;

async function UploadBlobsForIntegrationTest() {
// put blobs
console.log(contractAddr)
const es = await EthStorage.create({
rpc: RPC,
privateKey,
address: contractAddr
})
while (true) {
const currentIndex = await contract.lastKvIdx();
const totalCount = MAX_BLOB - currentIndex;
console.log("Current Number:", currentIndex, " Total Number:", totalCount);
if (totalCount <= 0) {
return;
}
const buf = crypto.randomBytes(126976);
const cost = await es.estimateCost(buf.subarray(0,32).toString('hex'), buf);
console.log(cost)

// write
let status = await es.write(buf.subarray(0,32).toString('hex'), buf);
console.log(status)
}
// put blobs
console.log(contractAddr)
const es = await EthStorage.create({
rpc: RPC,
privateKey,
address: contractAddr
})
while (true) {
const currentIndex = await contract.lastKvIdx();
const totalCount = MAX_BLOB - currentIndex;
console.log("Current Number:", currentIndex, " Total Number:", totalCount);
if (totalCount <= 0) {
break;
}
const buf = crypto.randomBytes(126976);
const cost = await es.estimateCost(buf.subarray(0,32).toString('hex'), buf);
console.log(cost)

// write
let status = await es.write(buf.subarray(0,32).toString('hex'), buf);
console.log(status)
}

let latestBlock
try {
latestBlock = await provider.getBlock();
console.log("latest block number is", latestBlock.number);
} catch (e) {
console.error(`EthStorage: get latest block failed!`, e.message);
return
}

// wait for blobs finalized
var intervalId = setInterval(async function (){
try {
let finalizedBlock = await provider.getBlock("finalized");
console.log(
"finalized block number is",
finalizedBlock.number,
"at",
new Date().toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", second: "2-digit" })
);
if (latestBlock.number < finalizedBlock.number) {
clearInterval(intervalId);
}
} catch (e) {
console.error(`EthStorage: get finalized block failed!`, e.message);
}
}, 60000);
}

UploadBlobsForIntegrationTest();
Expand Down

0 comments on commit 37d14d2

Please sign in to comment.