@@ -57,10 +57,10 @@ contract('MolochV3 - Ragequit Adapter', async accounts => {
57
57
}
58
58
} )
59
59
60
- it ( "should be possible to a member to ragequit" , async ( ) => {
60
+ it ( "should not be possible to a member to ragequit when the member does not have enough shares " , async ( ) => {
61
61
const myAccount = accounts [ 1 ] ;
62
62
const newMember = accounts [ 2 ] ;
63
-
63
+
64
64
let dao = await createDao ( { } , myAccount ) ;
65
65
66
66
const bankAddress = await dao . getAddress ( sha3 ( "bank" ) ) ;
@@ -82,7 +82,7 @@ contract('MolochV3 - Ragequit Adapter', async accounts => {
82
82
await dao . sendTransaction ( { from : newMember , value : sharePrice . mul ( toBN ( 10 ) ) . add ( remaining ) , gasPrice : toBN ( "0" ) } ) ;
83
83
//Get the new proposal id
84
84
pastEvents = await proposal . getPastEvents ( ) ;
85
- let { proposalId } = pastEvents [ 0 ] . returnValues ;
85
+ let { proposalId } = pastEvents [ 0 ] . returnValues ;
86
86
87
87
//Sponsor the new proposal, vote and process it
88
88
await onboarding . sponsorProposal ( dao . address , proposalId , [ ] , { from : myAccount , gasPrice : toBN ( "0" ) } ) ;
@@ -91,10 +91,8 @@ contract('MolochV3 - Ragequit Adapter', async accounts => {
91
91
await onboarding . processProposal ( dao . address , proposalId , { from : myAccount , gasPrice : toBN ( "0" ) } ) ;
92
92
93
93
//Check Guild Bank Balance
94
-
95
94
let guildBalance = await bank . balanceOf ( dao . address , GUILD , ETH_TOKEN ) ;
96
- let expectedGuildBalance = toBN ( "1200000000000000000" ) ;
97
- assert . equal ( guildBalance . toString ( ) , expectedGuildBalance . toString ( ) ) ;
95
+ assert . equal ( guildBalance . toString ( ) , "1200000000000000000" . toString ( ) ) ;
98
96
99
97
//Check Member Shares
100
98
let shares = await member . nbShares ( dao . address , newMember ) ;
@@ -103,22 +101,88 @@ contract('MolochV3 - Ragequit Adapter', async accounts => {
103
101
//Ragequit
104
102
let ragequitAddress = await dao . getAddress ( sha3 ( 'ragequit' ) ) ;
105
103
let ragequitContract = await RagequitContract . at ( ragequitAddress ) ;
104
+ try {
105
+ //Trying to Ragequit with shares + 1 to burn
106
+ await ragequitContract . ragequit ( dao . address , toBN ( "10000000000000001" ) , { from : newMember , gasPrice : toBN ( "0" ) } ) ;
107
+ } catch ( error ) {
108
+ assert . equal ( error . reason , "insufficient shares" ) ;
109
+ }
110
+
111
+ try {
112
+ //Trying to Ragequit 0 shares to burn
113
+ await ragequitContract . ragequit ( dao . address , toBN ( "0" ) , { from : newMember , gasPrice : toBN ( "0" ) } ) ;
114
+ } catch ( error ) {
115
+ assert . equal ( error . reason , "insufficient shares" ) ;
116
+ }
117
+
118
+ } )
119
+
120
+ it ( "should be possible to a member to ragequit when the member has not voted on any proposals yet" , async ( ) => {
121
+ const myAccount = accounts [ 1 ] ;
122
+ const newMember = accounts [ 2 ] ;
123
+
124
+ let dao = await createDao ( { } , myAccount ) ;
125
+
126
+ const bankAddress = await dao . getAddress ( sha3 ( "bank" ) ) ;
127
+ const bank = await BankContract . at ( bankAddress ) ;
128
+
129
+ const proposalAddress = await dao . getAddress ( sha3 ( "proposal" ) ) ;
130
+ const proposal = await ProposalContract . at ( proposalAddress ) ;
131
+
132
+ //Add funds to the Guild Bank after sposoring a member to join the Guild
133
+ const onboardingAddress = await dao . getAddress ( sha3 ( 'onboarding' ) ) ;
134
+ const onboarding = await OnboardingContract . at ( onboardingAddress ) ;
135
+
136
+ const votingAddress = await dao . getAddress ( sha3 ( "voting" ) ) ;
137
+ const voting = await VotingContract . at ( votingAddress ) ;
138
+
139
+ const memberAddress = await dao . getAddress ( sha3 ( "member" ) ) ;
140
+ const memberContract = await MemberContract . at ( memberAddress ) ;
141
+
142
+ await dao . sendTransaction ( { from : newMember , value : sharePrice . mul ( toBN ( 100 ) ) , gasPrice : toBN ( "0" ) } ) ;
143
+ //Get the new proposal id
144
+ let pastEvents = await proposal . getPastEvents ( ) ;
145
+ let { proposalId } = pastEvents [ 0 ] . returnValues ;
146
+
147
+ //Sponsor the new proposal, vote and process it
148
+ await onboarding . sponsorProposal ( dao . address , proposalId , [ ] , { from : myAccount , gasPrice : toBN ( "0" ) } ) ;
149
+ await voting . submitVote ( dao . address , proposalId , 1 , { from : myAccount , gasPrice : toBN ( "0" ) } ) ;
150
+ await advanceTime ( 10000 ) ;
151
+ await onboarding . processProposal ( dao . address , proposalId , { from : myAccount , gasPrice : toBN ( "0" ) } ) ;
152
+
153
+ //Check Guild Bank Balance
154
+ let guildBalance = await bank . balanceOf ( dao . address , GUILD , ETH_TOKEN ) ;
155
+ assert . equal ( guildBalance . toString ( ) , "12000000000000000000" . toString ( ) ) ;
156
+
157
+ //Check Member Shares
158
+ let shares = await memberContract . nbShares ( dao . address , newMember ) ;
159
+ assert . equal ( shares . toString ( ) , "100000000000000000" ) ;
160
+
161
+ //Ragequit - burn all member shares
162
+ let ragequitAddress = await dao . getAddress ( sha3 ( 'ragequit' ) ) ;
163
+ let ragequitContract = await RagequitContract . at ( ragequitAddress ) ;
106
164
await ragequitContract . ragequit ( dao . address , toBN ( shares ) , { from : newMember , gasPrice : toBN ( "0" ) } ) ;
107
165
108
166
//Check Guild Bank Balance
109
- // guildBalance = await bank.balanceOf(GUILD, token );
110
- // assert.equal(guildBalance.toString(), "0 ");
167
+ guildBalance = await bank . balanceOf ( dao . address , GUILD , ETH_TOKEN ) ;
168
+ assert . equal ( guildBalance . toString ( ) , "240 " ) ; //must be close to 0
111
169
112
- // // Check Member Shares
113
- // shares = await member .nbShares(dao.address, newMember);
114
- // assert.equal(shares .toString(), "0");
170
+ //Check Member Shares
171
+ let newShares = await memberContract . nbShares ( dao . address , newMember ) ;
172
+ assert . equal ( newShares . toString ( ) , "0" ) ;
115
173
116
174
//Check Ragequit Event
117
- // pastEvents = await proposal.getPastEvents();
118
- // proposalId = pastEvents[0].returnValues.proposalId;
119
- // assert.equal(proposalId, 1);
175
+ pastEvents = await ragequitContract . getPastEvents ( ) ;
176
+ let { member, burnedShares} = pastEvents [ 0 ] . returnValues ;
177
+ assert . equal ( member . toString ( ) , newMember . toString ( ) ) ;
178
+ assert . equal ( burnedShares . toString ( ) , shares . toString ( ) ) ;
179
+ } )
180
+
181
+ it ( "should be possible to a member to ragequit even if the member voted YES on a proposal" , async ( ) => {
182
+ //TODO
183
+ } )
120
184
121
- //Check Member Balance for each avaiable token
185
+ it ( "should be possible to a member to ragequit even if the member voted NO on a proposal" , async ( ) => {
122
186
//TODO
123
187
} )
124
188
} ) ;
0 commit comments