-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* npm version bump * verifreg_deserial. test added * verifreg_deserial. test added
- Loading branch information
Showing
5 changed files
with
88 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DEPLOYER_PK="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ yarn.lock | |
typechain-types | ||
|
||
.openzeppelin/ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { ethers, network } from "hardhat" | ||
import * as utils from "./utils" | ||
|
||
import { VerifRegApiTest, VerifRegApiTest__factory } from "../typechain-types" | ||
import { assert } from "console" | ||
|
||
const DBG_LOG_ON = false | ||
|
||
//RUN using: | ||
//npx hardhat --network calibnet run hh-test/verifreg_deserial.t.ts | ||
|
||
const main = async () => { | ||
const deployerPk = network.config.accounts[0] | ||
|
||
const provider = new ethers.providers.JsonRpcProvider(network.config.url) | ||
|
||
const deployer = new ethers.Wallet(deployerPk, provider) | ||
|
||
console.log(`\nDeploying contracts... (verifreg)\n`) | ||
|
||
const fact = new VerifRegApiTest__factory() | ||
|
||
const verifreg = await fact.connect(deployer).deploy() | ||
|
||
await utils.delay(15_000) | ||
|
||
console.log(`\nCalling: get_claims(...)\n`) | ||
|
||
//fil-sol issue#51 example values | ||
const claimObject = { provider: 33601, claim_ids: [27133] } | ||
|
||
const replicateFirstClaimId = (claimObject, n) => { | ||
const claim_ids = [...new Array(10)].map(() => claimObject.claim_ids[0]) | ||
return { ...claimObject, claim_ids } | ||
} | ||
|
||
//fetch and compare all results with the initial request | ||
const resOne = await verifreg.get_claims(claimObject) | ||
dbgLogRes(`resOne:`, resOne) | ||
|
||
for (let len = 2; len < 10; len += 1) { | ||
const replicatedClaimObject = replicateFirstClaimId(claimObject, len) | ||
const resReplicated = await verifreg.get_claims(replicatedClaimObject) | ||
dbgLogRes(`resReplicated:::${len}:`, resReplicated) | ||
|
||
//check correctness | ||
const bigNumberKeys = ["provider", "client", "size", "term_min", "term_max", "term_start", "sector"] | ||
for (const repClaim of resReplicated.claims) { | ||
for (const bnk of bigNumberKeys) { | ||
assert(repClaim[bnk].eq(resOne.claims[0][bnk]), `ERR: replicated(${len}).claim.${bnk} !== resOne.claim.${bnk}!`) | ||
} | ||
assert(repClaim.data === resOne.claims[0].data, `ERR: replicated(${len}).data !== resOne.data!`) | ||
} | ||
} | ||
|
||
console.log(`----> Verifreg deserialize. test completed!\n`) | ||
} | ||
main().catch((error) => { | ||
console.error(error) | ||
process.exitCode = 1 | ||
}) | ||
|
||
const dbgLogRes = (name, res) => { | ||
if (DBG_LOG_ON === false) return | ||
console.log(`\n---------> `, name) | ||
console.log("success_count", res.batch_info.success_count) | ||
console.log("fail_codes", res.batch_info.fail_codes) | ||
console.log("claims", res.claims) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters