mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-12-01 20:05:43 +03:00
Fix more tests
This commit is contained in:
parent
1d59fee788
commit
4ec019411a
@ -104,10 +104,10 @@ export const get_puzzle_hash = wallet_id => {
|
||||
return action;
|
||||
};
|
||||
|
||||
export const farm_block = () => {
|
||||
export const farm_block = puzzle_hash => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "farm_block";
|
||||
action.message.data = {};
|
||||
action.message.data = { puzzle_hash: puzzle_hash };
|
||||
return action;
|
||||
};
|
||||
|
||||
|
@ -443,7 +443,10 @@ const SendCard = props => {
|
||||
}
|
||||
|
||||
function farm() {
|
||||
dispatch(farm_block());
|
||||
var address = address_input.value;
|
||||
if (address !== "") {
|
||||
dispatch(farm_block(address));
|
||||
}
|
||||
}
|
||||
|
||||
function send() {
|
||||
|
@ -349,7 +349,10 @@ const SendCard = props => {
|
||||
}
|
||||
|
||||
function farm() {
|
||||
dispatch(farm_block());
|
||||
var address = address_input.value;
|
||||
if (address !== "") {
|
||||
dispatch(farm_block(address));
|
||||
}
|
||||
}
|
||||
|
||||
function send() {
|
||||
|
@ -24,7 +24,7 @@ def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description="Chia plot checking script.")
|
||||
parser.add_argument(
|
||||
"-n", "--num", help="Number of challenges", type=int, default=100
|
||||
"-n", "--num", help="Number of challenges", type=int, default=30
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import blspy
|
||||
|
||||
from src.types.sized_bytes import bytes32
|
||||
from src.util.ints import uint64
|
||||
from src.util.ints import uint64, uint32
|
||||
from src.types.coin import Coin
|
||||
from src.types.BLSSignature import BLSSignature, BLSPublicKey
|
||||
from src.wallet.puzzles.p2_delegated_puzzle import puzzle_for_pk
|
||||
@ -23,11 +23,11 @@ def sign_coinbase_coin(coin: Coin, private_key: blspy.PrivateKey):
|
||||
return signature_for_coinbase(coin, private_key)
|
||||
|
||||
|
||||
def create_coinbase_coin(block_index: int, puzzle_hash: bytes32, reward: uint64):
|
||||
def create_coinbase_coin(block_index: uint32, puzzle_hash: bytes32, reward: uint64):
|
||||
block_index_as_hash = bytes32(block_index.to_bytes(32, "big"))
|
||||
return Coin(block_index_as_hash, puzzle_hash, reward)
|
||||
|
||||
|
||||
def create_fees_coin(block_index: int, puzzle_hash: bytes32, reward: uint64):
|
||||
block_index_as_hash = std_hash(std_hash(bytes32(block_index.to_bytes(32, "big"))))
|
||||
def create_fees_coin(block_index: uint32, puzzle_hash: bytes32, reward: uint64):
|
||||
block_index_as_hash = std_hash(std_hash(block_index.to_bytes(4, "big")))
|
||||
return Coin(block_index_as_hash, puzzle_hash, reward)
|
||||
|
@ -2067,16 +2067,7 @@ class FullNode:
|
||||
coins_map: List[Tuple[bytes32, List[Coin]]] = []
|
||||
proofs_map: List[Tuple[bytes32, bytes, Optional[bytes]]] = []
|
||||
|
||||
if block.transactions_generator is None:
|
||||
proofs: Optional[List]
|
||||
if request.puzzle_hashes is None:
|
||||
proofs = None
|
||||
else:
|
||||
proofs = []
|
||||
response = wallet_protocol.RespondAdditions(
|
||||
block.height, block.header_hash, [], proofs
|
||||
)
|
||||
elif request.puzzle_hashes is None:
|
||||
if request.puzzle_hashes is None:
|
||||
for puzzle_hash, coins in puzzlehash_coins_map.items():
|
||||
coins_map.append((puzzle_hash, coins))
|
||||
response = wallet_protocol.RespondAdditions(
|
||||
|
@ -174,7 +174,8 @@ class WalletRpcApi:
|
||||
return response
|
||||
|
||||
async def farm_block(self, request):
|
||||
request = FarmNewBlockProtocol()
|
||||
puzzle_hash = bytes.fromhex(request["puzzle_hash"])
|
||||
request = FarmNewBlockProtocol(puzzle_hash)
|
||||
msg = OutboundMessage(
|
||||
NodeType.FULL_NODE, Message("farm_new_block", request), Delivery.BROADCAST,
|
||||
)
|
||||
|
@ -137,6 +137,7 @@ class FullNodeSimulator(FullNode):
|
||||
1,
|
||||
current_block,
|
||||
10,
|
||||
reward_puzzlehash=request.puzzle_hash,
|
||||
transaction_data_at_height=dict_h,
|
||||
seed=token_bytes(),
|
||||
fees=uint64(fees),
|
||||
@ -151,6 +152,7 @@ class FullNodeSimulator(FullNode):
|
||||
async def reorg_from_index_to_new_index(self, request: ReorgProtocol):
|
||||
new_index = request.new_index
|
||||
old_index = request.old_index
|
||||
coinbase_ph = request.puzzle_hash
|
||||
top_tip = self.get_tip()
|
||||
|
||||
current_blocks = await self.get_current_blocks(top_tip)
|
||||
@ -162,6 +164,7 @@ class FullNodeSimulator(FullNode):
|
||||
current_blocks[:old_index],
|
||||
10,
|
||||
seed=token_bytes(),
|
||||
reward_puzzlehash=coinbase_ph,
|
||||
transaction_data_at_height={},
|
||||
)
|
||||
assert self.server is not None
|
||||
|
@ -1,5 +1,6 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
from src.types.sized_bytes import bytes32
|
||||
from src.util.cbor_message import cbor_message
|
||||
from src.util.ints import uint32
|
||||
|
||||
@ -7,7 +8,7 @@ from src.util.ints import uint32
|
||||
@dataclass(frozen=True)
|
||||
@cbor_message
|
||||
class FarmNewBlockProtocol:
|
||||
pass
|
||||
puzzle_hash: bytes32
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@ -15,3 +16,4 @@ class FarmNewBlockProtocol:
|
||||
class ReorgProtocol:
|
||||
old_index: uint32
|
||||
new_index: uint32
|
||||
puzzle_hash: bytes32
|
||||
|
@ -652,28 +652,6 @@ class WalletStateManager:
|
||||
fast sync). If validation succeeds, block is adedd to DB. If it's a new TIP, transactions are
|
||||
reorged accordingly.
|
||||
"""
|
||||
cb_and_fees_additions = []
|
||||
if header_block is not None:
|
||||
coinbase_coin = header_block.get_coinbase()
|
||||
fees_coin = header_block.get_fees_coin()
|
||||
|
||||
if await self.is_addition_relevant(coinbase_coin):
|
||||
cb_and_fees_additions.append(coinbase_coin)
|
||||
if await self.is_addition_relevant(fees_coin):
|
||||
cb_and_fees_additions.append(fees_coin)
|
||||
assert block.additions is not None
|
||||
if len(cb_and_fees_additions) > 0:
|
||||
block = BlockRecord(
|
||||
block.header_hash,
|
||||
block.prev_header_hash,
|
||||
block.height,
|
||||
block.weight,
|
||||
block.additions + cb_and_fees_additions,
|
||||
block.removals,
|
||||
block.total_iters,
|
||||
block.new_challenge_hash,
|
||||
)
|
||||
|
||||
assert block.additions is not None
|
||||
assert block.removals is not None
|
||||
|
||||
@ -720,7 +698,14 @@ class WalletStateManager:
|
||||
await self.wallet_store.add_block_to_path(block.header_hash)
|
||||
self.lca = block.header_hash
|
||||
for coin in block.additions:
|
||||
await self.coin_added(coin, block.height, False)
|
||||
is_coinbase = False
|
||||
if (
|
||||
bytes32((block.height).to_bytes(32, "big"))
|
||||
== coin.parent_coin_info
|
||||
or std_hash(std_hash(block.height)) == coin.parent_coin_info
|
||||
):
|
||||
is_coinbase = True
|
||||
await self.coin_added(coin, block.height, is_coinbase)
|
||||
for coin in block.removals:
|
||||
await self.coin_removed(coin, block.height)
|
||||
self.height_to_hash[uint32(0)] = block.header_hash
|
||||
@ -755,11 +740,10 @@ class WalletStateManager:
|
||||
)
|
||||
for coin in path_block.additions:
|
||||
is_coinbase = False
|
||||
|
||||
if (
|
||||
bytes32((path_block.height).to_bytes(32, "big"))
|
||||
== coin.parent_coin_info
|
||||
or std_hash(std_hash(path_block.height))
|
||||
or std_hash(std_hash(path_block.height.to_bytes(4, "big")))
|
||||
== coin.parent_coin_info
|
||||
):
|
||||
is_coinbase = True
|
||||
|
@ -683,12 +683,10 @@ if __name__ == "__main__":
|
||||
print(
|
||||
bytes(
|
||||
bt.create_genesis_block(
|
||||
consensus_constants,
|
||||
{},
|
||||
bytes([2] * 32),
|
||||
b"0",
|
||||
bytes.fromhex(
|
||||
"a4259182b4d8e0af21331fc5be2681f953400b6726fa4095e3b91ae8f005a836"
|
||||
),
|
||||
"30944219616695e48f7a9b54b38877104a1f5fbe85c61da2fbe35275418a64bc",
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -64,7 +64,7 @@ class TestWalletSimulator:
|
||||
|
||||
await server_2.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
for i in range(1, 4):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
funds = sum(
|
||||
[
|
||||
@ -80,7 +80,7 @@ class TestWalletSimulator:
|
||||
)
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
await time_out_assert(15, cc_wallet.get_confirmed_balance, 100)
|
||||
await time_out_assert(15, cc_wallet.get_unconfirmed_balance, 100)
|
||||
@ -101,7 +101,7 @@ class TestWalletSimulator:
|
||||
await server_3.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
|
||||
for i in range(1, 4):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
funds = sum(
|
||||
[
|
||||
@ -117,7 +117,7 @@ class TestWalletSimulator:
|
||||
)
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
await time_out_assert(15, cc_wallet.get_confirmed_balance, 100)
|
||||
await time_out_assert(15, cc_wallet.get_unconfirmed_balance, 100)
|
||||
@ -135,7 +135,7 @@ class TestWalletSimulator:
|
||||
await cc_wallet.cc_spend(uint64(60), cc_2_hash)
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
await time_out_assert(15, cc_wallet.get_confirmed_balance, 40)
|
||||
await time_out_assert(15, cc_wallet.get_unconfirmed_balance, 40)
|
||||
@ -147,7 +147,7 @@ class TestWalletSimulator:
|
||||
await cc_wallet_2.cc_spend(uint64(15), cc_hash)
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
await time_out_assert(15, cc_wallet.get_confirmed_balance, 55)
|
||||
await time_out_assert(15, cc_wallet.get_unconfirmed_balance, 55)
|
||||
@ -165,7 +165,7 @@ class TestWalletSimulator:
|
||||
await server_2.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
|
||||
for i in range(1, 4):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
funds = sum(
|
||||
[
|
||||
@ -181,7 +181,7 @@ class TestWalletSimulator:
|
||||
)
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
colour = await cc_wallet.get_colour()
|
||||
assert (
|
||||
@ -204,7 +204,7 @@ class TestWalletSimulator:
|
||||
await server_2.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
await server_3.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
for i in range(1, 4):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
funds = sum(
|
||||
[
|
||||
@ -220,7 +220,7 @@ class TestWalletSimulator:
|
||||
|
||||
ph = await wallet2.get_new_puzzlehash()
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
await time_out_assert(15, cc_wallet.get_confirmed_balance, 100)
|
||||
await time_out_assert(15, cc_wallet.get_unconfirmed_balance, 100)
|
||||
@ -237,7 +237,7 @@ class TestWalletSimulator:
|
||||
await cc_wallet_2.generate_zero_val_coin()
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
unspent: List[WalletCoinRecord] = list(
|
||||
await cc_wallet_2.wallet_state_manager.get_spendable_coins_for_wallet(
|
||||
@ -264,7 +264,7 @@ class TestWalletSimulator:
|
||||
await server_3.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
|
||||
for i in range(1, 4):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
funds = sum(
|
||||
[
|
||||
@ -280,7 +280,7 @@ class TestWalletSimulator:
|
||||
)
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
await time_out_assert(15, cc_wallet.get_confirmed_balance, 100)
|
||||
await time_out_assert(15, cc_wallet.get_unconfirmed_balance, 100)
|
||||
@ -294,9 +294,9 @@ class TestWalletSimulator:
|
||||
|
||||
assert cc_wallet.cc_info.my_core == cc_wallet_2.cc_info.my_core
|
||||
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph2))
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
trade_manager_1 = await TradeManager.create(wallet_node.wallet_state_manager)
|
||||
trade_manager_2 = await TradeManager.create(wallet_node_2.wallet_state_manager)
|
||||
@ -333,7 +333,7 @@ class TestWalletSimulator:
|
||||
assert success is True
|
||||
|
||||
for i in range(0, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(token_bytes()))
|
||||
|
||||
await time_out_assert(15, cc_wallet_2.get_confirmed_balance, 30)
|
||||
await time_out_assert(15, cc_wallet_2.get_unconfirmed_balance, 30)
|
||||
@ -354,7 +354,7 @@ class TestWalletSimulator:
|
||||
await server_3.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
|
||||
for i in range(1, 4):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
funds = sum(
|
||||
[
|
||||
@ -370,7 +370,7 @@ class TestWalletSimulator:
|
||||
)
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
await time_out_assert(15, cc_wallet.get_confirmed_balance, 100)
|
||||
await time_out_assert(15, cc_wallet.get_unconfirmed_balance, 100)
|
||||
@ -388,7 +388,7 @@ class TestWalletSimulator:
|
||||
await cc_wallet.cc_spend(uint64(60), cc_2_hash)
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
await time_out_assert(15, cc_wallet.get_confirmed_balance, 40)
|
||||
await time_out_assert(15, cc_wallet.get_unconfirmed_balance, 40)
|
||||
@ -403,7 +403,7 @@ class TestWalletSimulator:
|
||||
await wallet.wallet_state_manager.main_wallet.push_transaction(spend_bundle)
|
||||
|
||||
for i in range(0, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(token_bytes()))
|
||||
|
||||
id = cc_wallet_2.wallet_info.id
|
||||
wsm = cc_wallet_2.wallet_state_manager
|
||||
@ -428,7 +428,7 @@ class TestWalletSimulator:
|
||||
await server_3.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
funds = sum(
|
||||
[
|
||||
@ -444,7 +444,7 @@ class TestWalletSimulator:
|
||||
)
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
await time_out_assert(15, red_wallet.get_confirmed_balance, 100)
|
||||
await time_out_assert(15, red_wallet.get_unconfirmed_balance, 100)
|
||||
@ -452,15 +452,15 @@ class TestWalletSimulator:
|
||||
assert red_wallet.cc_info.my_core is not None
|
||||
red = cc_wallet_puzzles.get_genesis_from_core(red_wallet.cc_info.my_core)
|
||||
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph2))
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph2))
|
||||
|
||||
blue_wallet_2: CCWallet = await CCWallet.create_new_cc(
|
||||
wallet_node_2.wallet_state_manager, wallet2, uint64(150)
|
||||
)
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
assert blue_wallet_2.cc_info.my_core is not None
|
||||
blue = cc_wallet_puzzles.get_genesis_from_core(blue_wallet_2.cc_info.my_core)
|
||||
@ -472,7 +472,7 @@ class TestWalletSimulator:
|
||||
assert red_wallet.cc_info.my_core == red_wallet_2.cc_info.my_core
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
blue_wallet: CCWallet = await CCWallet.create_wallet_for_cc(
|
||||
wallet_node.wallet_state_manager, wallet, blue
|
||||
@ -491,7 +491,7 @@ class TestWalletSimulator:
|
||||
|
||||
await blue_wallet.generate_zero_val_coin()
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
offer_dict = {1: -1000, 2: -30, 3: 50}
|
||||
|
||||
@ -517,7 +517,7 @@ class TestWalletSimulator:
|
||||
|
||||
assert success is True
|
||||
for i in range(0, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(token_bytes()))
|
||||
|
||||
await time_out_assert(15, red_wallet_2.get_confirmed_balance, 30)
|
||||
await time_out_assert(15, red_wallet_2.get_unconfirmed_balance, 30)
|
||||
@ -548,7 +548,7 @@ class TestWalletSimulator:
|
||||
await server_3.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
|
||||
for i in range(1, 4):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
funds = sum(
|
||||
[
|
||||
@ -564,7 +564,7 @@ class TestWalletSimulator:
|
||||
)
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
await time_out_assert(15, cc_wallet.get_unconfirmed_balance, 100)
|
||||
await time_out_assert(15, cc_wallet.get_confirmed_balance, 100)
|
||||
@ -578,9 +578,9 @@ class TestWalletSimulator:
|
||||
|
||||
assert cc_wallet.cc_info.my_core == cc_wallet_2.cc_info.my_core
|
||||
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph2))
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
trade_manager_1 = await TradeManager.create(wallet_node.wallet_state_manager)
|
||||
trade_manager_2 = await TradeManager.create(wallet_node_2.wallet_state_manager)
|
||||
@ -617,7 +617,7 @@ class TestWalletSimulator:
|
||||
assert success is True
|
||||
|
||||
for i in range(0, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(token_bytes()))
|
||||
|
||||
await time_out_assert(15, cc_wallet_2.get_confirmed_balance, 30)
|
||||
await time_out_assert(15, cc_wallet_2.get_confirmed_balance, 30)
|
||||
|
@ -1176,7 +1176,7 @@ class TestWalletProtocol:
|
||||
assert len(msgs) == 1
|
||||
assert isinstance(msgs[0].message.data, wallet_protocol.RejectAdditionsRequest)
|
||||
|
||||
# If there are no transactions, empty proof and coins
|
||||
# If there are no transactions, only cb and fees additions
|
||||
blocks_new = bt.get_consecutive_blocks(
|
||||
test_constants, 10, block_list=blocks_list,
|
||||
)
|
||||
@ -1192,7 +1192,7 @@ class TestWalletProtocol:
|
||||
]
|
||||
assert len(msgs) == 1
|
||||
assert isinstance(msgs[0].message.data, wallet_protocol.RespondAdditions)
|
||||
assert len(msgs[0].message.data.coins) == 0
|
||||
assert len(msgs[0].message.data.coins) == 2
|
||||
assert msgs[0].message.data.proofs is None
|
||||
|
||||
# Add a block with transactions
|
||||
|
@ -8,7 +8,7 @@ from src.protocols import full_node_protocol
|
||||
from src.simulator.simulator_protocol import FarmNewBlockProtocol
|
||||
from src.types.peer_info import PeerInfo
|
||||
from src.util.ints import uint16, uint32
|
||||
from tests.setup_nodes import setup_simulators_and_wallets, test_constants, bt
|
||||
from tests.setup_nodes import setup_simulators_and_wallets
|
||||
from tests.time_out_assert import time_out_assert
|
||||
from src.consensus.block_rewards import calculate_base_fee, calculate_block_reward
|
||||
|
||||
@ -22,9 +22,7 @@ def event_loop():
|
||||
class TestTransactions:
|
||||
@pytest.fixture(scope="function")
|
||||
async def wallet_node(self):
|
||||
async for _ in setup_simulators_and_wallets(
|
||||
1, 1, {"COINBASE_FREEZE_PERIOD": 0}
|
||||
):
|
||||
async for _ in setup_simulators_and_wallets(1, 1, {}):
|
||||
yield _
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
@ -50,24 +48,18 @@ class TestTransactions:
|
||||
wallet = wallet_node.wallet_state_manager.main_wallet
|
||||
ph = await wallet.get_new_puzzlehash()
|
||||
|
||||
wallet_a = bt.get_farmer_wallet_tool()
|
||||
blocks = bt.get_consecutive_blocks(test_constants, 3, [], 10, b"")
|
||||
spend_bundle = wallet_a.generate_signed_transaction(
|
||||
blocks[-1].get_fees_coin().amount, ph, blocks[0].get_fees_coin()
|
||||
)
|
||||
assert spend_bundle is not None
|
||||
tx: full_node_protocol.RespondTransaction = full_node_protocol.RespondTransaction(
|
||||
spend_bundle
|
||||
)
|
||||
async for outbound in full_node_1.respond_transaction(tx):
|
||||
assert outbound.message.function == "new_transaction"
|
||||
|
||||
await server_2.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
funds = calculate_base_fee(uint32(i))
|
||||
await asyncio.sleep(3)
|
||||
funds = sum(
|
||||
[
|
||||
calculate_base_fee(uint32(i)) + calculate_block_reward(uint32(i))
|
||||
for i in range(1, num_blocks - 2)
|
||||
]
|
||||
)
|
||||
await asyncio.sleep(2)
|
||||
print(await wallet.get_confirmed_balance(), funds)
|
||||
await time_out_assert(10, wallet.get_confirmed_balance, funds)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@ -96,22 +88,15 @@ class TestTransactions:
|
||||
PeerInfo("localhost", uint16(server_2._port)), None
|
||||
)
|
||||
|
||||
wallet_a = bt.get_farmer_wallet_tool()
|
||||
blocks = bt.get_consecutive_blocks(test_constants, 3, [], 10, b"")
|
||||
spend_bundle = wallet_a.generate_signed_transaction(
|
||||
blocks[-1].get_fees_coin().amount, ph, blocks[0].get_fees_coin()
|
||||
)
|
||||
assert spend_bundle is not None
|
||||
rt: full_node_protocol.RespondTransaction = full_node_protocol.RespondTransaction(
|
||||
spend_bundle
|
||||
)
|
||||
async for outbound in full_node_1.respond_transaction(rt):
|
||||
assert outbound.message.function == "new_transaction"
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_0.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
for i in range(1, 4):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
|
||||
funds = calculate_base_fee(uint32(0))
|
||||
funds = sum(
|
||||
[
|
||||
calculate_base_fee(uint32(i)) + calculate_block_reward(uint32(i))
|
||||
for i in range(1, num_blocks - 2)
|
||||
]
|
||||
)
|
||||
await time_out_assert(
|
||||
10, wallet_0.wallet_state_manager.main_wallet.get_confirmed_balance, funds
|
||||
)
|
||||
@ -133,7 +118,13 @@ class TestTransactions:
|
||||
|
||||
# Farm another block
|
||||
for i in range(1, 8):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(token_bytes()))
|
||||
funds = sum(
|
||||
[
|
||||
calculate_base_fee(uint32(i)) + calculate_block_reward(uint32(i))
|
||||
for i in range(1, num_blocks)
|
||||
]
|
||||
)
|
||||
await time_out_assert(
|
||||
10,
|
||||
wallet_0.wallet_state_manager.main_wallet.get_confirmed_balance,
|
||||
@ -161,32 +152,24 @@ class TestTransactions:
|
||||
PeerInfo("localhost", uint16(server_0._port)), None
|
||||
)
|
||||
await server_0.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
await server_1.start_client(PeerInfo("localhost", uint16(server_2._port)), None)
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_0.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
all_blocks = await full_node_0.get_current_blocks(full_node_0.get_tip())
|
||||
wallet_a = bt.get_farmer_wallet_tool()
|
||||
all_blocks = bt.get_consecutive_blocks(test_constants, 3, all_blocks, 10, b"")
|
||||
|
||||
for block in all_blocks:
|
||||
async for _ in full_node_2.respond_block(
|
||||
full_node_protocol.RespondBlock(block)
|
||||
):
|
||||
pass
|
||||
|
||||
funds = sum(
|
||||
[
|
||||
_
|
||||
async for _ in full_node_1.respond_block(
|
||||
full_node_protocol.RespondBlock(block)
|
||||
)
|
||||
calculate_base_fee(uint32(i)) + calculate_block_reward(uint32(i))
|
||||
for i in range(1, num_blocks - 2)
|
||||
]
|
||||
spend_bundle = wallet_a.generate_signed_transaction(
|
||||
all_blocks[2].get_fees_coin().amount, ph, all_blocks[2].get_fees_coin()
|
||||
)
|
||||
assert spend_bundle is not None
|
||||
rt: full_node_protocol.RespondTransaction = full_node_protocol.RespondTransaction(
|
||||
spend_bundle
|
||||
)
|
||||
async for outbound in full_node_1.respond_transaction(rt):
|
||||
assert outbound.message.function == "new_transaction"
|
||||
|
||||
for i in range(1, 4):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
|
||||
funds = calculate_base_fee(uint32(i))
|
||||
await time_out_assert(
|
||||
10, wallet_0.wallet_state_manager.main_wallet.get_confirmed_balance, funds
|
||||
)
|
||||
@ -194,8 +177,6 @@ class TestTransactions:
|
||||
tx = await wallet_0.wallet_state_manager.main_wallet.generate_signed_transaction(
|
||||
10, token_bytes(), 0
|
||||
)
|
||||
server_2.global_connections.close_all_connections()
|
||||
await asyncio.sleep(2)
|
||||
await wallet_0.wallet_state_manager.main_wallet.push_transaction(tx)
|
||||
|
||||
await time_out_assert(
|
||||
|
@ -12,6 +12,15 @@ from tests.time_out_assert import time_out_assert, time_out_assert_custom_interv
|
||||
|
||||
bt = BlockTools()
|
||||
|
||||
test_constants: Dict[str, Any] = consensus_constants.copy()
|
||||
test_constants.update(
|
||||
{
|
||||
"DIFFICULTY_STARTING": 500,
|
||||
"MIN_ITERS_STARTING": 500,
|
||||
"NUMBER_ZERO_BITS_CHALLENGE_SIG": 1,
|
||||
}
|
||||
)
|
||||
|
||||
test_constants = make_test_constants_with_genesis({"DIFFICULTY_STARTING": 500, "MIN_ITERS_STARTING": 500})
|
||||
|
||||
|
||||
|
@ -56,7 +56,7 @@ class TestWalletSimulator:
|
||||
|
||||
await server_2.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
funds = sum(
|
||||
[
|
||||
@ -79,7 +79,7 @@ class TestWalletSimulator:
|
||||
await server_2.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
|
||||
for i in range(0, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
funds = sum(
|
||||
[
|
||||
@ -102,7 +102,7 @@ class TestWalletSimulator:
|
||||
await time_out_assert(5, wallet.get_unconfirmed_balance, funds - 10)
|
||||
|
||||
for i in range(0, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
new_funds = sum(
|
||||
[
|
||||
@ -124,7 +124,7 @@ class TestWalletSimulator:
|
||||
|
||||
await server_2.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
funds = sum(
|
||||
[
|
||||
@ -136,7 +136,7 @@ class TestWalletSimulator:
|
||||
await time_out_assert(5, wallet.get_confirmed_balance, funds)
|
||||
|
||||
await full_node_1.reorg_from_index_to_new_index(
|
||||
ReorgProtocol(uint32(5), uint32(num_blocks + 3))
|
||||
ReorgProtocol(uint32(5), uint32(num_blocks + 3), token_bytes())
|
||||
)
|
||||
|
||||
funds = sum(
|
||||
@ -166,7 +166,7 @@ class TestWalletSimulator:
|
||||
)
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_0.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_0.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
all_blocks = await full_node_0.get_current_blocks(full_node_0.get_tip())
|
||||
|
||||
@ -238,7 +238,7 @@ class TestWalletSimulator:
|
||||
)
|
||||
|
||||
for i in range(0, num_blocks):
|
||||
await full_node_0.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_0.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
funds = sum(
|
||||
[
|
||||
@ -266,7 +266,7 @@ class TestWalletSimulator:
|
||||
await time_out_assert(5, wallet_0.get_unconfirmed_balance, funds - 10)
|
||||
|
||||
for i in range(0, 4):
|
||||
await full_node_0.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_0.farm_new_block(FarmNewBlockProtocol(token_bytes()))
|
||||
|
||||
new_funds = sum(
|
||||
[
|
||||
@ -286,7 +286,7 @@ class TestWalletSimulator:
|
||||
await wallet_1.push_transaction(tx)
|
||||
|
||||
for i in range(0, 4):
|
||||
await full_node_0.farm_new_block(FarmNewBlockProtocol())
|
||||
await full_node_0.farm_new_block(FarmNewBlockProtocol(token_bytes()))
|
||||
|
||||
confirmed_balance = await wallet_0.get_confirmed_balance()
|
||||
unconfirmed_balance = await wallet_0.get_unconfirmed_balance()
|
||||
@ -309,7 +309,7 @@ class TestWalletSimulator:
|
||||
# await server_2.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
|
||||
# for i in range(0, num_blocks):
|
||||
# await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
# await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
# funds = sum(
|
||||
# [
|
||||
@ -342,7 +342,7 @@ class TestWalletSimulator:
|
||||
# )
|
||||
|
||||
# for i in range(0, num_blocks):
|
||||
# await full_node_1.farm_new_block(FarmNewBlockProtocol())
|
||||
# await full_node_1.farm_new_block(FarmNewBlockProtocol(token_bytes()))
|
||||
|
||||
# new_funds = sum(
|
||||
# [
|
||||
|
@ -5,7 +5,7 @@ import pytest
|
||||
|
||||
from src.types.peer_info import PeerInfo
|
||||
from src.protocols import full_node_protocol
|
||||
from src.util.ints import uint16, uint64
|
||||
from src.util.ints import uint16, uint64, uint32
|
||||
from tests.setup_nodes import setup_two_nodes, setup_node_and_wallet, test_constants
|
||||
from src.types.spend_bundle import SpendBundle
|
||||
from src.util.bundle_tools import best_solution_program
|
||||
@ -44,71 +44,71 @@ class TestWalletSync:
|
||||
async for _ in setup_node_and_wallet(starting_height=100):
|
||||
yield _
|
||||
|
||||
# @pytest.mark.asyncio
|
||||
# async def test_basic_sync_wallet(self, wallet_node):
|
||||
# num_blocks = 300 # This must be greater than the short_sync in wallet_node
|
||||
# bt = BlockTools()
|
||||
# blocks = bt.get_consecutive_blocks(test_constants, num_blocks, [])
|
||||
# full_node_1, wallet_node, server_1, server_2 = wallet_node
|
||||
@pytest.mark.asyncio
|
||||
async def test_basic_sync_wallet(self, wallet_node):
|
||||
num_blocks = 300 # This must be greater than the short_sync in wallet_node
|
||||
bt = BlockTools()
|
||||
blocks = bt.get_consecutive_blocks(test_constants, num_blocks, [])
|
||||
full_node_1, wallet_node, server_1, server_2 = wallet_node
|
||||
|
||||
# for i in range(1, len(blocks)):
|
||||
# async for _ in full_node_1.respond_block(
|
||||
# full_node_protocol.RespondBlock(blocks[i])
|
||||
# ):
|
||||
# pass
|
||||
for i in range(1, len(blocks)):
|
||||
async for _ in full_node_1.respond_block(
|
||||
full_node_protocol.RespondBlock(blocks[i])
|
||||
):
|
||||
pass
|
||||
|
||||
# await server_2.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
await server_2.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
|
||||
# # The second node should eventually catch up to the first one, and have the
|
||||
# # same tip at height num_blocks - 1.
|
||||
# await time_out_assert(
|
||||
# 200, wallet_height_at_least, True, wallet_node, num_blocks - 6
|
||||
# )
|
||||
# The second node should eventually catch up to the first one, and have the
|
||||
# same tip at height num_blocks - 1.
|
||||
await time_out_assert(
|
||||
200, wallet_height_at_least, True, wallet_node, num_blocks - 6
|
||||
)
|
||||
|
||||
# # Tests a reorg with the wallet
|
||||
# blocks_reorg = bt.get_consecutive_blocks(test_constants, 15, blocks[:-5])
|
||||
# for i in range(1, len(blocks_reorg)):
|
||||
# async for msg in full_node_1.respond_block(
|
||||
# full_node_protocol.RespondBlock(blocks_reorg[i])
|
||||
# ):
|
||||
# server_1.push_message(msg)
|
||||
# Tests a reorg with the wallet
|
||||
blocks_reorg = bt.get_consecutive_blocks(test_constants, 15, blocks[:-5])
|
||||
for i in range(1, len(blocks_reorg)):
|
||||
async for msg in full_node_1.respond_block(
|
||||
full_node_protocol.RespondBlock(blocks_reorg[i])
|
||||
):
|
||||
server_1.push_message(msg)
|
||||
|
||||
# await time_out_assert(200, wallet_height_at_least, True, wallet_node, 33)
|
||||
await time_out_assert(200, wallet_height_at_least, True, wallet_node, 33)
|
||||
|
||||
# @pytest.mark.asyncio
|
||||
# async def test_fast_sync_wallet(self, wallet_node_starting_height):
|
||||
# num_blocks = 25 # This must be greater than the short_sync in wallet_node
|
||||
# bt = BlockTools()
|
||||
# blocks = bt.get_consecutive_blocks(test_constants, num_blocks, [])
|
||||
# full_node_1, wallet_node, server_1, server_2 = wallet_node_starting_height
|
||||
@pytest.mark.asyncio
|
||||
async def test_fast_sync_wallet(self, wallet_node_starting_height):
|
||||
num_blocks = 25 # This must be greater than the short_sync in wallet_node
|
||||
bt = BlockTools()
|
||||
blocks = bt.get_consecutive_blocks(test_constants, num_blocks, [])
|
||||
full_node_1, wallet_node, server_1, server_2 = wallet_node_starting_height
|
||||
|
||||
# for i in range(1, len(blocks)):
|
||||
# async for _ in full_node_1.respond_block(
|
||||
# full_node_protocol.RespondBlock(blocks[i])
|
||||
# ):
|
||||
# pass
|
||||
for i in range(1, len(blocks)):
|
||||
async for _ in full_node_1.respond_block(
|
||||
full_node_protocol.RespondBlock(blocks[i])
|
||||
):
|
||||
pass
|
||||
|
||||
# await server_2.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
await server_2.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
|
||||
# await time_out_assert(
|
||||
# 60, wallet_height_at_least, True, wallet_node, num_blocks - 6
|
||||
# )
|
||||
await time_out_assert(
|
||||
60, wallet_height_at_least, True, wallet_node, num_blocks - 6
|
||||
)
|
||||
|
||||
# @pytest.mark.asyncio
|
||||
# async def test_short_sync_wallet(self, wallet_node):
|
||||
# num_blocks = 5 # This must be lower than the short_sync in wallet_node
|
||||
# bt = BlockTools()
|
||||
# blocks = bt.get_consecutive_blocks(test_constants, num_blocks, [], 10)
|
||||
# full_node_1, wallet_node, server_1, server_2 = wallet_node
|
||||
@pytest.mark.asyncio
|
||||
async def test_short_sync_wallet(self, wallet_node):
|
||||
num_blocks = 5 # This must be lower than the short_sync in wallet_node
|
||||
bt = BlockTools()
|
||||
blocks = bt.get_consecutive_blocks(test_constants, num_blocks, [], 10)
|
||||
full_node_1, wallet_node, server_1, server_2 = wallet_node
|
||||
|
||||
# for i in range(1, len(blocks)):
|
||||
# async for _ in full_node_1.respond_block(
|
||||
# full_node_protocol.RespondBlock(blocks[i])
|
||||
# ):
|
||||
# pass
|
||||
for i in range(1, len(blocks)):
|
||||
async for _ in full_node_1.respond_block(
|
||||
full_node_protocol.RespondBlock(blocks[i])
|
||||
):
|
||||
pass
|
||||
|
||||
# await server_2.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
# await time_out_assert(60, wallet_height_at_least, True, wallet_node, 3)
|
||||
await server_2.start_client(PeerInfo("localhost", uint16(server_1._port)), None)
|
||||
await time_out_assert(60, wallet_height_at_least, True, wallet_node, 3)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_short_sync_with_transactions_wallet(self, wallet_node):
|
||||
@ -116,11 +116,15 @@ class TestWalletSync:
|
||||
wallet_a = wallet_node.wallet_state_manager.main_wallet
|
||||
wallet_a_dummy = WalletTool()
|
||||
wallet_b = WalletTool()
|
||||
coinbase_puzzlehash = await wallet_a.get_new_puzzlehash()
|
||||
coinbase_puzzlehash_rest = wallet_b.get_new_puzzlehash()
|
||||
puzzle_hashes = [await wallet_a.get_new_puzzlehash() for _ in range(10)]
|
||||
puzzle_hashes.append(wallet_b.get_new_puzzlehash())
|
||||
|
||||
bt = BlockTools()
|
||||
blocks = bt.get_consecutive_blocks(test_constants, 3, [], 10, b"")
|
||||
blocks = bt.get_consecutive_blocks(
|
||||
test_constants, 3, [], 10, b"", coinbase_puzzlehash
|
||||
)
|
||||
for block in blocks:
|
||||
[
|
||||
_
|
||||
@ -147,7 +151,9 @@ class TestWalletSync:
|
||||
prev_coin = Coin(prev_coin.name(), puzzle_hashes[i], uint64(1000))
|
||||
dic_h[i + 4] = (program, aggsig)
|
||||
|
||||
blocks = bt.get_consecutive_blocks(test_constants, 13, blocks, 10, b"", dic_h)
|
||||
blocks = bt.get_consecutive_blocks(
|
||||
test_constants, 13, blocks, 10, b"", coinbase_puzzlehash_rest, dic_h
|
||||
)
|
||||
# Move chain to height 16, with consecutive transactions in blocks 4 to 14
|
||||
for block in blocks:
|
||||
async for _ in full_node_1.respond_block(
|
||||
@ -189,7 +195,13 @@ class TestWalletSync:
|
||||
dic_h[i + 4] = (program, aggsig)
|
||||
|
||||
blocks = bt.get_consecutive_blocks(
|
||||
test_constants, 31, blocks[:4], 10, b"this is a reorg", dic_h,
|
||||
test_constants,
|
||||
31,
|
||||
blocks[:4],
|
||||
10,
|
||||
b"this is a reorg",
|
||||
coinbase_puzzlehash_rest,
|
||||
dic_h,
|
||||
)
|
||||
|
||||
# Move chain to height 34, with consecutive transactions in blocks 4 to 14
|
||||
@ -224,7 +236,7 @@ class TestWalletSync:
|
||||
dic_h = {}
|
||||
pk, sk = await wallet_a.wallet_state_manager.get_keys(new_coinbase_puzzlehash)
|
||||
coinbase_coin = create_coinbase_coin(
|
||||
25, new_coinbase_puzzlehash, uint64(14000000000000)
|
||||
uint32(25), new_coinbase_puzzlehash, uint64(14000000000000)
|
||||
)
|
||||
transaction_unsigned = wallet_a_dummy.generate_unsigned_transaction(
|
||||
7000000000000, another_puzzlehash, coinbase_coin, {}, 0, secretkey=sk
|
||||
@ -237,7 +249,12 @@ class TestWalletSync:
|
||||
|
||||
# Farm a block (25) to ourselves
|
||||
blocks = bt.get_consecutive_blocks(
|
||||
test_constants, 1, blocks[:25], 10, b"this is yet another reorg",
|
||||
test_constants,
|
||||
1,
|
||||
blocks[:25],
|
||||
10,
|
||||
b"this is yet another reorg",
|
||||
new_coinbase_puzzlehash,
|
||||
)
|
||||
|
||||
# Brings height up to 40, with block 31 having half our reward spent to us
|
||||
@ -247,6 +264,7 @@ class TestWalletSync:
|
||||
blocks,
|
||||
10,
|
||||
b"this is yet another reorg more blocks",
|
||||
coinbase_puzzlehash_rest,
|
||||
dic_h,
|
||||
)
|
||||
for block in blocks:
|
||||
@ -270,6 +288,7 @@ class TestWalletSync:
|
||||
)
|
||||
# Fee and coinbase
|
||||
assert len(records) == 2
|
||||
print(records)
|
||||
assert records[0].spent != records[1].spent
|
||||
assert records[0].coinbase == records[1].coinbase
|
||||
records = await wallet_node.wallet_state_manager.wallet_store.get_coin_records_by_puzzle_hash(
|
||||
|
Loading…
Reference in New Issue
Block a user