@@ -3,22 +3,22 @@ import { ANVIL_CHAIN } from "~test/chains.js";
3
3
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js" ;
4
4
import { TEST_CLIENT } from "~test/test-clients.js" ;
5
5
import { 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" ;
15
15
16
16
const account = TEST_ACCOUNT_C ;
17
17
const client = TEST_CLIENT ;
18
18
const chain = ANVIL_CHAIN ;
19
19
20
20
describe . 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 ( ) => {
22
22
const tokenAddress = await deployERC20Contract ( {
23
23
client : TEST_CLIENT ,
24
24
chain : ANVIL_CHAIN ,
@@ -42,47 +42,16 @@ describe.runIf(process.env.TW_SECRET_KEY)("proposal exists", () => {
42
42
minVoteQuorumRequiredPercent : 51 ,
43
43
} ,
44
44
} ) ;
45
-
46
- const contract = getContract ( {
45
+ const voteContract = getContract ( {
47
46
address,
48
47
chain,
49
48
client,
50
49
} ) ;
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 ,
85
53
} ) ;
54
+ expect ( result ) . toBe ( false ) ;
86
55
87
56
const tokenContract = getContract ( {
88
57
address : tokenAddress ,
@@ -105,19 +74,19 @@ describe.runIf(process.env.TW_SECRET_KEY)("proposal exists", () => {
105
74
106
75
// step 3: create a proposal
107
76
const transaction = propose ( {
108
- contract,
77
+ contract : voteContract ,
109
78
description : "first proposal" ,
110
- targets : [ contract . address ] ,
79
+ targets : [ voteContract . address ] ,
111
80
values : [ 0n ] ,
112
81
calldatas : [ "0x" ] ,
113
82
} ) ;
114
83
await sendAndConfirmTransaction ( { transaction, account } ) ;
115
- const allProposals = await getAll ( { contract } ) ;
84
+ const allProposals = await getAll ( { contract : voteContract } ) ;
116
85
expect ( allProposals . length ) . toBe ( 1 ) ;
117
- const result = await proposalExists ( {
118
- contract,
86
+ const exists = await proposalExists ( {
87
+ contract : voteContract ,
119
88
proposalId : allProposals [ 0 ] ?. proposalId || - 1n ,
120
89
} ) ;
121
- expect ( result ) . toBe ( true ) ;
90
+ expect ( exists ) . toBe ( true ) ;
122
91
} ) ;
123
92
} ) ;
0 commit comments