-
-
Save sembrestels/ec0879bce06f02fa7a9e1ce4e5ae1cab to your computer and use it in GitHub Desktop.
Usage of evmcrispr and hardhat to test if a vote is executable and which is the outcome
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
import { ethers, waffle } from "hardhat"; | |
import { Contract } from "ethers"; | |
import { EVMcrispr, evmcl } from "../src/"; | |
import { impersonateAddress } from "../helpers/rpc"; | |
import chai, { expect } from "chai"; | |
// import fetch from "node-fetch"; | |
chai.use(waffle.solidity); | |
const hatchDaoAddress = "0x4625c2c3E1Bc9323CC1A9dc312F3188e8dE83f42"; | |
const chainId = 100; | |
const votingAppId = "dandelion-voting.1hive:0"; | |
export const TX_GAS_LIMIT = 10_000_000; | |
export const TX_GAS_PRICE = 10_000_000_000; // 10 gwei | |
describe("Mint/burn test", () => { | |
let evmcrispr: EVMcrispr; | |
it("Executes all votes properly", async () => { | |
const signer = (await ethers.getSigners())[0]; | |
// For testing with forked chains | |
signer.getChainId = async () => chainId; | |
evmcrispr = await EVMcrispr.create(hatchDaoAddress, signer); | |
const votingApp = evmcrispr.appCache.get(votingAppId)!; | |
const votingSigner = await impersonateAddress(votingApp.address); | |
const actions = await evmcl` | |
grant dandelion-voting.1hive agent TRANSFER_ROLE dandelion-voting.1hive | |
exec agent transfer 0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d 0xc125218f4df091ee40624784caf7f47b9738086f 1000e18 | |
`(evmcrispr); | |
await Promise.all( | |
actions.map((action) => { | |
return votingSigner.sendTransaction({ | |
...action, | |
gasLimit: TX_GAS_LIMIT, | |
gasPrice: TX_GAS_PRICE, | |
}); | |
}) | |
); | |
const voting = new Contract(votingApp.address, votingApp.abiInterface, signer); | |
await voting.executeVote(2); | |
await voting.executeVote(1); | |
const token = new Contract( | |
"0x799844141C2627bD195c89c3A0c71341d0314c55", | |
["function balanceOf(address _owner) public view returns (uint256 balance)"], | |
signer | |
); | |
expect((await token.balanceOf("0xFBC56Be13C23c18B6864D062e413da3c7e0f74Fb")).toString()).to.be.eq("0"); | |
expect((await token.balanceOf("0xFB074ABA249F6a75edA10996c3EFa6d66465B8b3")).toString()).to.be.eq( | |
"2447045542334842592122" | |
); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment