extend initial freeze test (#7580)

This commit is contained in:
Arvid Norberg 2021-07-27 10:30:48 -07:00 committed by GitHub
parent b593f55dcd
commit c6bf1910d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ import multiprocessing
import time
from dataclasses import replace
from secrets import token_bytes
from typing import Optional
import pytest
from blspy import AugSchemeMPL, G2Element
@ -1813,7 +1814,10 @@ class TestBodyValidation:
assert err == Err.INVALID_REWARD_COINS
@pytest.mark.asyncio
async def test_initial_freeze(self, empty_blockchain):
# each block is 10 seconds, we pull 3 blocks and the test freeze time is
# 1000
@pytest.mark.parametrize("genesis_time,expected_error", [(970, Err.INITIAL_TRANSACTION_FREEZE), (971, None)])
async def test_initial_freeze(self, empty_blockchain, genesis_time: int, expected_error: Optional[Err]):
# 6
b = empty_blockchain
blocks = bt.get_consecutive_blocks(
@ -1821,23 +1825,25 @@ class TestBodyValidation:
guarantee_transaction_block=True,
pool_reward_puzzle_hash=bt.pool_ph,
farmer_reward_puzzle_hash=bt.pool_ph,
genesis_timestamp=0,
genesis_timestamp=uint64(genesis_time),
time_per_block=10,
)
assert (await b.receive_block(blocks[0]))[0] == ReceiveBlockResult.NEW_PEAK
assert (await b.receive_block(blocks[1]))[0] == ReceiveBlockResult.NEW_PEAK
assert (await b.receive_block(blocks[2]))[0] == ReceiveBlockResult.NEW_PEAK
wt: WalletTool = bt.get_pool_wallet_tool()
tx: SpendBundle = wt.generate_signed_transaction(
10, wt.get_new_puzzlehash(), list(blocks[2].get_included_reward_coins())[0]
uint64(10), wt.get_new_puzzlehash(), list(blocks[2].get_included_reward_coins())[0]
)
blocks = bt.get_consecutive_blocks(
1,
block_list_input=blocks,
guarantee_transaction_block=True,
transaction_data=tx,
time_per_block=10,
)
err = (await b.receive_block(blocks[-1]))[1]
assert err == Err.INITIAL_TRANSACTION_FREEZE
assert err == expected_error
@pytest.mark.asyncio
async def test_invalid_transactions_generator_hash(self, empty_blockchain):