Skip to content

Commit 741239f

Browse files
author
cheezus1
committed
[GH-#83] Fixed test
1 parent dd98470 commit 741239f

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

apps/aecore/lib/aecore/utils/blockchain/block_validation.ex

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ defmodule Aecore.Utils.Blockchain.BlockValidation do
3737
throw({:error, "One or more transactions not valid"})
3838

3939
coinbase_transactions_sum > Miner.coinbase_transaction_value() ->
40-
IO.puts(coinbase_transactions_sum)
4140
throw({:error, "Sum of coinbase transactions values exceeds the maximum coinbase transactions value"})
4241

4342
new_block.header.chain_state_hash != chain_state_hash ->

apps/aecore/test/multiple_transactions_test.exs

+38-3
Original file line numberDiff line numberDiff line change
@@ -254,22 +254,27 @@ defmodule MultipleTransactionsTest do
254254

255255
@tag timeout: 10000000
256256
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()
258258
{account1_pub_key, _account1_priv_key} = account1
259259
{account2_pub_key, _account2_priv_key} = account2
260-
{account3_pub_key, _account3_priv_key} = account3
261260
pubkey = elem(Keys.pubkey(), 1)
262261

262+
Miner.resume()
263+
Miner.suspend()
264+
Pool.get_and_empty_pool()
263265
Miner.resume()
264266
Miner.suspend()
265267
Pool.get_and_empty_pool()
266268
{:ok, tx} = Keys.sign_tx(account1_pub_key, 100,
267269
Map.get(Chain.chain_state, pubkey, %{nonce: 0}).nonce + 1, 0)
268270
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)
269274
Miner.resume()
270275
Miner.suspend()
271276
Pool.get_and_empty_pool()
272-
tx = create_signed_tx(account1, account2, 99,
277+
tx = create_signed_tx(account1, account3, 99,
273278
Map.get(Chain.chain_state, account1_pub_key, %{nonce: 0}).nonce + 1, 1)
274279
assert :ok = Pool.add_transaction(tx)
275280
tx = create_signed_tx(account2, account3, 99,
@@ -278,6 +283,7 @@ defmodule MultipleTransactionsTest do
278283
miner_balance_before_mining = Map.get(Chain.chain_state, pubkey).balance
279284
Miner.resume()
280285
Miner.suspend()
286+
Pool.get_and_empty_pool()
281287
miner_balance_after_mining = Map.get(Chain.chain_state, pubkey).balance
282288
assert miner_balance_after_mining == miner_balance_before_mining + Miner.coinbase_transaction_value() + 2
283289
end
@@ -340,6 +346,35 @@ defmodule MultipleTransactionsTest do
340346
{account1, account2, account3}
341347
end
342348

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+
343378
defp create_signed_tx(from_acc, to_acc, value, nonce, fee) do
344379
{from_acc_pub_key, from_acc_priv_key} = from_acc
345380
{to_acc_pub_key, _to_acc_priv_key} = to_acc

0 commit comments

Comments
 (0)