17
17
package suspension
18
18
19
19
import (
20
- "fmt"
21
20
"path/filepath"
22
21
"testing"
23
22
"time"
@@ -65,15 +64,15 @@ func TestWhaleJoin(t *testing.T) {
65
64
accounts , err := fixture .GetNodeWalletsSortedByBalance (c )
66
65
a .NoError (err )
67
66
a .Len (accounts , 1 )
68
- fmt . Printf ("Client %s is %v\n " , name , accounts [0 ].Address )
67
+ t . Logf ("Client %s is %v\n " , name , accounts [0 ].Address )
69
68
return c , accounts [0 ]
70
69
}
71
70
72
71
c15 , account15 := clientAndAccount ("Node15" )
73
72
c01 , account01 := clientAndAccount ("Node01" )
74
73
75
74
// 1. take wallet15 offline
76
- keys := offline (& fixture , a , c15 , account15 .Address )
75
+ keys := offline (a , c15 , account15 .Address )
77
76
78
77
// 2. c01 starts with 100M, so burn 99.9M to get total online stake down
79
78
burn , err := c01 .SendPaymentFromUnencryptedWallet (account01 .Address , basics.Address {}.String (),
@@ -87,7 +86,7 @@ func TestWhaleJoin(t *testing.T) {
87
86
a .NoError (err )
88
87
89
88
// 4. rejoin, with 1.5B against the paltry 100k that's currently online
90
- online (& fixture , a , c15 , account15 .Address , keys )
89
+ online (a , c15 , account15 .Address , keys )
91
90
92
91
// 5. wait for agreement balances to kick in (another lookback's worth, plus some slack)
93
92
_ , err = c01 .WaitForRound (* receipt .ConfirmedRound + 2 * lookback + 5 )
@@ -139,20 +138,20 @@ func TestBigJoin(t *testing.T) {
139
138
accounts , err := fixture .GetNodeWalletsSortedByBalance (c )
140
139
a .NoError (err )
141
140
a .Len (accounts , 1 )
142
- fmt . Printf ("Client %s is %v\n " , name , accounts [0 ].Address )
141
+ t . Logf ("Client %s is %v\n " , name , accounts [0 ].Address )
143
142
return c , accounts [0 ]
144
143
}
145
144
146
145
c01 , account01 := clientAndAccount ("Node01" )
147
146
148
147
// 1. take wallet01 offline
149
- keys := offline (& fixture , a , c01 , account01 .Address )
148
+ keys := offline (a , c01 , account01 .Address )
150
149
151
150
// 2. Wait lookback rounds
152
151
wait (& fixture , a , lookback )
153
152
154
153
// 4. rejoin, with 1/16 of total stake
155
- onRound := online (& fixture , a , c01 , account01 .Address , keys )
154
+ onRound := online (a , c01 , account01 .Address , keys )
156
155
157
156
// 5. wait for enough rounds to pass, during which c01 can't vote, that is
158
157
// could get knocked off.
@@ -162,7 +161,7 @@ func TestBigJoin(t *testing.T) {
162
161
a .Equal (basics .Online , data .Status )
163
162
164
163
// 5a. just to be sure, do a zero pay to get it "noticed"
165
- zeroPay (& fixture , a , c01 , account01 .Address )
164
+ zeroPay (a , c01 , account01 .Address )
166
165
data , err = c01 .AccountData (account01 .Address )
167
166
a .NoError (err )
168
167
a .Equal (basics .Online , data .Status )
@@ -175,7 +174,7 @@ func TestBigJoin(t *testing.T) {
175
174
a .NoError (err )
176
175
a .Equal (basics .Online , data .Status )
177
176
178
- zeroPay (& fixture , a , c01 , account01 .Address )
177
+ zeroPay (a , c01 , account01 .Address )
179
178
data , err = c01 .AccountData (account01 .Address )
180
179
a .NoError (err )
181
180
a .Equal (basics .Online , data .Status )
@@ -215,7 +214,7 @@ func TestBigIncrease(t *testing.T) {
215
214
accounts , err := fixture .GetNodeWalletsSortedByBalance (c )
216
215
a .NoError (err )
217
216
a .Len (accounts , 1 )
218
- fmt . Printf ("Client %s is %v\n " , name , accounts [0 ].Address )
217
+ t . Logf ("Client %s is %v\n " , name , accounts [0 ].Address )
219
218
return c , accounts [0 ]
220
219
}
221
220
@@ -226,14 +225,14 @@ func TestBigIncrease(t *testing.T) {
226
225
// certainly will not have proposed by pure luck just before the critical
227
226
// round. If we don't do that, 1/16 of stake is enough that it will probably
228
227
// have a fairly recent proposal, and not get knocked off.
229
- pay (& fixture , a , c1 , account01 .Address , account15 .Address , 99 * account01 .Amount / 100 )
228
+ pay (a , c1 , account01 .Address , account15 .Address , 99 * account01 .Amount / 100 )
230
229
231
- rekeyreg (& fixture , a , c1 , account01 .Address , true )
230
+ rekeyreg (a , c1 , account01 .Address , true )
232
231
233
232
// 2. Wait lookback rounds
234
233
wait (& fixture , a , lookback )
235
234
236
- tx := pay (& fixture , a , c15 , account15 .Address , account01 .Address , 50 * account15 .Amount / 100 )
235
+ tx := pay (a , c15 , account15 .Address , account01 .Address , 50 * account15 .Amount / 100 )
237
236
data , err := c15 .AccountData (account01 .Address )
238
237
a .NoError (err )
239
238
a .EqualValues (* tx .ConfirmedRound + lookback , data .LastHeartbeat )
@@ -252,22 +251,21 @@ func wait(f *fixtures.RestClientFixture, a *require.Assertions, count uint64) {
252
251
a .NoError (f .WaitForRoundWithTimeout (round ))
253
252
}
254
253
255
- func pay (f * fixtures. RestClientFixture , a * require. Assertions ,
256
- c libgoal. Client , from string , to string , amount uint64 ) v2.PreEncodedTxInfo {
254
+ func pay (a * require. Assertions , c libgoal. Client ,
255
+ from string , to string , amount uint64 ) v2.PreEncodedTxInfo {
257
256
pay , err := c .SendPaymentFromUnencryptedWallet (from , to , 1000 , amount , nil )
258
257
a .NoError (err )
259
- tx , err := f .WaitForConfirmedTxn (uint64 (pay .LastValid ), pay .ID ().String ())
258
+ tx , err := c .WaitForConfirmedTxn (uint64 (pay .LastValid ), pay .ID ().String ())
260
259
a .NoError (err )
261
260
return tx
262
261
}
263
262
264
- func zeroPay (f * fixtures.RestClientFixture , a * require.Assertions ,
265
- c libgoal.Client , address string ) {
266
- pay (f , a , c , address , address , 0 )
263
+ func zeroPay (a * require.Assertions , c libgoal.Client , address string ) {
264
+ pay (a , c , address , address , 0 )
267
265
}
268
266
269
267
// Go offline, but return the key material so it's easy to go back online
270
- func offline (f * fixtures. RestClientFixture , a * require.Assertions , client libgoal.Client , address string ) transactions.KeyregTxnFields {
268
+ func offline (a * require.Assertions , client libgoal.Client , address string ) transactions.KeyregTxnFields {
271
269
offTx , err := client .MakeUnsignedGoOfflineTx (address , 0 , 0 , 100_000 , [32 ]byte {})
272
270
a .NoError (err )
273
271
@@ -286,7 +284,7 @@ func offline(f *fixtures.RestClientFixture, a *require.Assertions, client libgoa
286
284
a .NoError (err )
287
285
onlineTxID , err := client .SignAndBroadcastTransaction (wh , nil , offTx )
288
286
a .NoError (err )
289
- txn , err := f .WaitForConfirmedTxn (uint64 (offTx .LastValid ), onlineTxID )
287
+ txn , err := client .WaitForConfirmedTxn (uint64 (offTx .LastValid ), onlineTxID )
290
288
a .NoError (err )
291
289
// sync up with the network
292
290
_ , err = client .WaitForRound (* txn .ConfirmedRound )
@@ -298,7 +296,7 @@ func offline(f *fixtures.RestClientFixture, a *require.Assertions, client libgoa
298
296
}
299
297
300
298
// Go online with the supplied key material
301
- func online (f * fixtures. RestClientFixture , a * require.Assertions , client libgoal.Client , address string , keys transactions.KeyregTxnFields ) uint64 {
299
+ func online (a * require.Assertions , client libgoal.Client , address string , keys transactions.KeyregTxnFields ) uint64 {
302
300
// sanity check that we start offline
303
301
data , err := client .AccountData (address )
304
302
a .NoError (err )
@@ -313,7 +311,7 @@ func online(f *fixtures.RestClientFixture, a *require.Assertions, client libgoal
313
311
a .NoError (err )
314
312
onlineTxID , err := client .SignAndBroadcastTransaction (wh , nil , onTx )
315
313
a .NoError (err )
316
- receipt , err := f .WaitForConfirmedTxn (uint64 (onTx .LastValid ), onlineTxID )
314
+ receipt , err := client .WaitForConfirmedTxn (uint64 (onTx .LastValid ), onlineTxID )
317
315
a .NoError (err )
318
316
data , err = client .AccountData (address )
319
317
a .NoError (err )
0 commit comments