@@ -3,22 +3,22 @@ import { ANVIL_CHAIN } from "~test/chains.js";
33import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js" ;
44import { TEST_CLIENT } from "~test/test-clients.js" ;
55import { TEST_ACCOUNT_C } from "~test/test-wallets.js" ;
6- import { getContract } from "../../../ contract/contract.js" ;
7- import { delegate } from "../../../extensions/erc20/__generated__/IVotes/write/delegate .js" ;
8- import { mintTo } from "../../../extensions/erc20/ write/mintTo .js" ;
9- import { deployERC20Contract } from "../../../extensions/prebuilts/deploy-erc20 .js" ;
10- import { deployVoteContract } from "../../../extensions/ prebuilts/deploy-vote .js" ;
11- import { sendAndConfirmTransaction } from "../../../transaction/actions/send-and-confirm-transaction .js" ;
12- import { propose } from ".. /__generated__/Vote/write/propose.js" ;
13- import { getAll } from "./getAll.js" ;
14- import { proposalExists } from "./proposalExists.js" ;
6+ import { getContract } from "../../contract/contract.js" ;
7+ import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction .js" ;
8+ import { delegate } from "../erc20/__generated__/IVotes/ write/delegate .js" ;
9+ import { mintTo } from "../erc20/write/mintTo .js" ;
10+ import { deployERC20Contract } from "../prebuilts/deploy-erc20 .js" ;
11+ import { deployVoteContract } from "../prebuilts/deploy-vote .js" ;
12+ import { propose } from "./__generated__/Vote/write/propose.js" ;
13+ import { getAll } from "./read/ getAll.js" ;
14+ import { proposalExists } from "./read/ proposalExists.js" ;
1515
1616const account = TEST_ACCOUNT_C ;
1717const client = TEST_CLIENT ;
1818const chain = ANVIL_CHAIN ;
1919
2020describe . runIf ( process . env . TW_SECRET_KEY ) ( "proposal exists" , ( ) => {
21- it ( "should return false if Vote doesn't have any proposal " , async ( ) => {
21+ it ( "`proposalExists` and `propose` should work " , async ( ) => {
2222 const tokenAddress = await deployERC20Contract ( {
2323 client : TEST_CLIENT ,
2424 chain : ANVIL_CHAIN ,
@@ -42,47 +42,16 @@ describe.runIf(process.env.TW_SECRET_KEY)("proposal exists", () => {
4242 minVoteQuorumRequiredPercent : 51 ,
4343 } ,
4444 } ) ;
45-
46- const contract = getContract ( {
45+ const voteContract = getContract ( {
4746 address,
4847 chain,
4948 client,
5049 } ) ;
51-
52- const result = await proposalExists ( { contract, proposalId : 0n } ) ;
53- expect ( result ) . toBe ( false ) ;
54- } ) ;
55-
56- it ( "should return true if Vote has the proposal (id)" , async ( ) => {
57- const tokenAddress = await deployERC20Contract ( {
58- client : TEST_CLIENT ,
59- chain : ANVIL_CHAIN ,
60- account,
61- type : "TokenERC20" ,
62- params : {
63- name : "Token" ,
64- contractURI : TEST_CONTRACT_URI ,
65- } ,
66- } ) ;
67- const address = await deployVoteContract ( {
68- account,
69- client : TEST_CLIENT ,
70- chain : ANVIL_CHAIN ,
71- params : {
72- name : "" ,
73- contractURI : TEST_CONTRACT_URI ,
74- tokenAddress : tokenAddress ,
75- initialProposalThreshold : "0.5" ,
76- initialVotingPeriod : 10 ,
77- minVoteQuorumRequiredPercent : 51 ,
78- } ,
79- } ) ;
80-
81- const contract = getContract ( {
82- address,
83- chain,
84- client,
50+ const result = await proposalExists ( {
51+ contract : voteContract ,
52+ proposalId : 0n ,
8553 } ) ;
54+ expect ( result ) . toBe ( false ) ;
8655
8756 const tokenContract = getContract ( {
8857 address : tokenAddress ,
@@ -105,19 +74,19 @@ describe.runIf(process.env.TW_SECRET_KEY)("proposal exists", () => {
10574
10675 // step 3: create a proposal
10776 const transaction = propose ( {
108- contract,
77+ contract : voteContract ,
10978 description : "first proposal" ,
110- targets : [ contract . address ] ,
79+ targets : [ voteContract . address ] ,
11180 values : [ 0n ] ,
11281 calldatas : [ "0x" ] ,
11382 } ) ;
11483 await sendAndConfirmTransaction ( { transaction, account } ) ;
115- const allProposals = await getAll ( { contract } ) ;
84+ const allProposals = await getAll ( { contract : voteContract } ) ;
11685 expect ( allProposals . length ) . toBe ( 1 ) ;
117- const result = await proposalExists ( {
118- contract,
86+ const exists = await proposalExists ( {
87+ contract : voteContract ,
11988 proposalId : allProposals [ 0 ] ?. proposalId || - 1n ,
12089 } ) ;
121- expect ( result ) . toBe ( true ) ;
90+ expect ( exists ) . toBe ( true ) ;
12291 } ) ;
12392} ) ;
0 commit comments