refactor(lazytower.sol): rename the task from deploy-ht-test to deploy-lazytower-test

This commit is contained in:
Luoh Ren-Shan (LCamel)
2023-06-16 18:29:56 +08:00
parent d749fbd1fe
commit 51f2632348
5 changed files with 14 additions and 15 deletions

View File

@@ -65,19 +65,19 @@ yarn add @zk-kit/lazytower.sol
pragma solidity ^0.8.4;
import "../LazyTower.sol";
import "../LazyTowerHashChain.sol";
contract LazyTowerTest {
using LazyTower for LazyTowerData;
contract LazyTowerHashChainTest {
using LazyTowerHashChain for LazyTowerHashChainData;
// LazyTower may emit multiple events in a singal add() call
event Add(uint8 indexed level, uint64 indexed lvFullIndex, uint256 value);
event Add(uint256 item);
// map for multiple test cases
mapping(bytes32 => LazyTowerData) public towers;
mapping(bytes32 => LazyTowerHashChainData) public towers;
function add(bytes32 _towerId, uint256 _item) external {
towers[_towerId].add(_item);
emit Add(_item);
}
function getDataForProving(bytes32 _towerId)
@@ -101,7 +101,7 @@ contract LazyTowerTest {
import { Contract } from "ethers"
import { task, types } from "hardhat/config"
task("deploy:ht-test", "Deploy a LazyTowerTest contract")
task("deploy:lazytower-test", "Deploy a LazyTowerHashChainTest contract")
.addOptionalParam<boolean>("logs", "Print the logs", true, types.boolean)
.setAction(async ({ logs }, { ethers }): Promise<Contract> => {
const PoseidonT3Factory = await ethers.getContractFactory("PoseidonT3")
@@ -111,7 +111,7 @@ task("deploy:ht-test", "Deploy a LazyTowerTest contract")
console.info(`PoseidonT3 library has been deployed to: ${PoseidonT3.address}`)
}
const LazyTowerLibFactory = await ethers.getContractFactory("LazyTower", {
const LazyTowerLibFactory = await ethers.getContractFactory("LazyTowerHashChain", {
libraries: {
PoseidonT3: PoseidonT3.address
}
@@ -121,12 +121,12 @@ task("deploy:ht-test", "Deploy a LazyTowerTest contract")
await lazyTowerLib.deployed()
if (logs) {
console.info(`LazyTower library has been deployed to: ${lazyTowerLib.address}`)
console.info(`LazyTowerHashChain library has been deployed to: ${lazyTowerLib.address}`)
}
const ContractFactory = await ethers.getContractFactory("LazyTowerTest", {
const ContractFactory = await ethers.getContractFactory("LazyTowerHashChainTest", {
libraries: {
LazyTower: lazyTowerLib.address
LazyTowerHashChain: lazyTowerLib.address
}
})

View File

@@ -7,7 +7,6 @@ import "../LazyTowerHashChain.sol";
contract LazyTowerHashChainTest {
using LazyTowerHashChain for LazyTowerHashChainData;
// LazyTower may emit multiple events in a singal add() call
event Add(uint256 item);
// map for multiple test cases

View File

@@ -3,7 +3,7 @@ import { config as dotenvConfig } from "dotenv"
import { HardhatUserConfig } from "hardhat/config"
import { resolve } from "path"
import { config } from "./package.json"
import "./tasks/deploy-ht-test"
import "./tasks/deploy-lazytower-test"
dotenvConfig({ path: resolve(__dirname, "./.env") })

View File

@@ -1,7 +1,7 @@
import { Contract } from "ethers"
import { task, types } from "hardhat/config"
task("deploy:ht-test", "Deploy a LazyTowerTest contract")
task("deploy:lazytower-test", "Deploy a LazyTowerHashChainTest contract")
.addOptionalParam<boolean>("logs", "Print the logs", true, types.boolean)
.setAction(async ({ logs }, { ethers }): Promise<Contract> => {
const PoseidonT3Factory = await ethers.getContractFactory("PoseidonT3")

View File

@@ -9,7 +9,7 @@ describe("LazyTowerHashChainTest", () => {
let contract: Contract
before(async () => {
contract = await run("deploy:ht-test", { logs: false })
contract = await run("deploy:lazytower-test", { logs: false })
})
it("Should produce correct levelLengths, digests and digest of digests", async () => {