@@ -254,22 +254,27 @@ defmodule MultipleTransactionsTest do
254
254
255
255
@ tag timeout: 10000000
256
256
test "in one block, miner collects all the fees from the transactions" do
257
- { account1 , account2 , account3 } = get_accounts_one_block ( )
257
+ { account1 , account2 , account3 } = get_accounts_miner_fees ( )
258
258
{ account1_pub_key , _account1_priv_key } = account1
259
259
{ account2_pub_key , _account2_priv_key } = account2
260
- { account3_pub_key , _account3_priv_key } = account3
261
260
pubkey = elem ( Keys . pubkey ( ) , 1 )
262
261
262
+ Miner . resume ( )
263
+ Miner . suspend ( )
264
+ Pool . get_and_empty_pool ( )
263
265
Miner . resume ( )
264
266
Miner . suspend ( )
265
267
Pool . get_and_empty_pool ( )
266
268
{ :ok , tx } = Keys . sign_tx ( account1_pub_key , 100 ,
267
269
Map . get ( Chain . chain_state , pubkey , % { nonce: 0 } ) . nonce + 1 , 0 )
268
270
assert :ok = Pool . add_transaction ( tx )
271
+ { :ok , tx } = Keys . sign_tx ( account2_pub_key , 100 ,
272
+ Map . get ( Chain . chain_state , pubkey , % { nonce: 0 } ) . nonce + 2 , 0 )
273
+ assert :ok = Pool . add_transaction ( tx )
269
274
Miner . resume ( )
270
275
Miner . suspend ( )
271
276
Pool . get_and_empty_pool ( )
272
- tx = create_signed_tx ( account1 , account2 , 99 ,
277
+ tx = create_signed_tx ( account1 , account3 , 99 ,
273
278
Map . get ( Chain . chain_state , account1_pub_key , % { nonce: 0 } ) . nonce + 1 , 1 )
274
279
assert :ok = Pool . add_transaction ( tx )
275
280
tx = create_signed_tx ( account2 , account3 , 99 ,
@@ -278,6 +283,7 @@ defmodule MultipleTransactionsTest do
278
283
miner_balance_before_mining = Map . get ( Chain . chain_state , pubkey ) . balance
279
284
Miner . resume ( )
280
285
Miner . suspend ( )
286
+ Pool . get_and_empty_pool ( )
281
287
miner_balance_after_mining = Map . get ( Chain . chain_state , pubkey ) . balance
282
288
assert miner_balance_after_mining == miner_balance_before_mining + Miner . coinbase_transaction_value ( ) + 2
283
289
end
@@ -340,6 +346,35 @@ defmodule MultipleTransactionsTest do
340
346
{ account1 , account2 , account3 }
341
347
end
342
348
349
+ defp get_accounts_miner_fees ( ) do
350
+ account1 = {
351
+ << 4 , 231 , 192 , 96 , 22 , 175 , 115 , 58 , 27 , 93 , 216 , 187 , 43 , 116 , 150 , 164 , 153 ,
352
+ 80 , 134 , 135 , 12 , 127 , 173 , 196 , 198 , 181 , 84 , 119 , 225 , 204 , 150 , 176 , 26 ,
353
+ 119 , 103 , 128 , 201 , 93 , 131 , 7 , 169 , 48 , 28 , 60 , 16 , 112 , 65 , 8 , 46 , 212 , 32 ,
354
+ 251 , 135 , 81 , 99 , 146 , 67 , 139 , 42 , 151 , 183 , 210 , 45 , 195 , 8 >> ,
355
+ << 129 , 187 , 237 , 185 , 104 , 21 , 152 , 221 , 22 , 1 , 87 , 152 , 137 , 25 , 107 , 214 , 19 ,
356
+ 227 , 128 , 210 , 180 , 224 , 113 , 196 , 232 , 254 , 249 , 247 , 230 , 252 , 242 , 32 >>
357
+ }
358
+ account2 = {
359
+ << 4 , 176 , 20 , 135 , 174 , 148 , 149 , 10 , 132 , 176 , 41 , 79 , 141 , 161 , 151 , 96 , 65 ,
360
+ 70 , 198 , 93 , 25 , 11 , 90 , 105 , 57 , 41 , 39 , 255 , 197 , 140 , 163 , 9 , 180 , 126 ,
361
+ 111 , 71 , 178 , 86 , 250 , 177 , 170 , 211 , 70 , 146 , 111 , 201 , 137 , 230 , 98 , 8 ,
362
+ 205 , 109 , 234 , 51 , 50 , 140 , 9 , 177 , 130 , 222 , 196 , 54 , 98 , 55 , 243 >> ,
363
+ << 3 , 213 , 65 , 255 , 170 , 53 , 52 , 113 , 72 , 39 , 215 , 55 , 3 , 120 , 107 , 138 , 229 , 5 ,
364
+ 32 , 56 , 255 , 130 , 166 , 97 , 131 , 94 , 156 , 186 , 57 , 55 , 189 , 228 >>
365
+ }
366
+ account3 = {
367
+ << 4 , 163 , 213 , 138 , 149 , 50 , 37 , 22 , 21 , 221 , 239 , 158 , 126 , 245 , 61 , 146 , 7 ,
368
+ 15 , 86 , 26 , 224 , 169 , 46 , 191 , 199 , 39 , 172 , 189 , 146 , 10 , 111 , 160 , 51 , 7 ,
369
+ 33 , 236 , 50 , 4 , 211 , 92 , 192 , 17 , 134 , 144 , 168 , 106 , 126 , 235 , 101 , 133 ,
370
+ 156 , 66 , 66 , 39 , 248 , 210 , 14 , 251 , 91 , 86 , 59 , 29 , 153 , 150 , 190 >> ,
371
+ << 147 , 131 , 218 , 194 , 163 , 243 , 40 , 42 , 172 , 5 , 190 , 120 , 23 , 16 , 43 , 0 , 249 ,
372
+ 175 , 101 , 170 , 182 , 11 , 49 , 209 , 39 , 253 , 111 , 114 , 182 , 253 , 131 , 31 >>
373
+ }
374
+
375
+ { account1 , account2 , account3 }
376
+ end
377
+
343
378
defp create_signed_tx ( from_acc , to_acc , value , nonce , fee ) do
344
379
{ from_acc_pub_key , from_acc_priv_key } = from_acc
345
380
{ to_acc_pub_key , _to_acc_priv_key } = to_acc
0 commit comments