def on_set_delegation(self, _context: 'IconScoreContext', updated_accounts: List['Account']): assert len(updated_accounts) == 21 for i, account in enumerate(updated_accounts): assert isinstance(account, Account) address = account.address assert address == Address.from_prefix_and_int(AddressPrefix.EOA, i) if i == 0: # sender_account assert account.delegated_amount == 0 assert len(account.delegations) == 10 assert account.delegation_part.delegations_amount == sum(range(11, 21)) for j, item in enumerate(account.delegations): address: 'Address' = item[0] value: int = item[1] _id = j + 11 assert address == Address.from_prefix_and_int(AddressPrefix.EOA, _id) assert value == _id else: assert account.delegations_amount == 0 if i <= 10: assert account.delegated_amount == 0 else: assert account.delegated_amount == i
def test__calc_delegations(self): cached_accounts: Dict['Address', Tuple['Account', int]] = OrderedDict() context = Mock() context.storage.icx.get_account = Mock(side_effect=get_account) new_delegations: List[Tuple['Address', int]] = [] for i in range(10): value: int = i + 11 address = Address.from_prefix_and_int(AddressPrefix.EOA, value) new_delegations.append((address, value)) sender_account = context.storage.icx.get_account(context, SENDER_ADDRESS, Intent.ALL) cached_accounts[SENDER_ADDRESS] = sender_account, 0 # Prepare old delegations for i in range(10): value: int = i + 1 address = Address.from_prefix_and_int(AddressPrefix.EOA, value) account = context.storage.icx.get_account(context, address, Intent.DELEGATED) cached_accounts[address] = account, -value IISSEngine._calc_delegations(context, new_delegations, cached_accounts) # 0: sender_account, 1~10: old_accounts 11~20: new_accounts for i, address in enumerate(cached_accounts): account, delegated_offset = cached_accounts[address] assert account.address == address if i == 0: assert address == SENDER_ADDRESS assert delegated_offset == 0 elif 1 <= i <= 10: assert delegated_offset == -i else: # 11 <= i <= 20 assert delegated_offset == i
def test_prefix_and_int(self): self.assertEqual(Address.from_prefix_and_int(AddressPrefix.CONTRACT, 0), ZERO_SCORE_ADDRESS) self.assertEqual(Address.from_prefix_and_int(AddressPrefix.CONTRACT, 1), GOVERNANCE_SCORE_ADDRESS) self.assertEqual(str(Address.from_prefix_and_int(AddressPrefix.EOA, 10)), "hx000000000000000000000000000000000000000a") self.assertEqual(str(Address.from_prefix_and_int(AddressPrefix.CONTRACT, 1024)), "cx0000000000000000000000000000000000000400")
def on_set_delegation(self, _context: 'IconScoreContext', updated_accounts: List['Account']): # sender_account(1) + updated_delegated_account(10) assert len(updated_accounts) == 11 delegated_address = Address.from_prefix_and_int(AddressPrefix.EOA, 1) for i, account in enumerate(updated_accounts): assert isinstance(account, Account) address = account.address if i == 0: # sender_account assert account.delegated_amount == 0 assert len(account.delegations) == 1 assert account.delegation_part.delegations_amount == 100 item = account.delegations[0] assert item[0] == Address.from_prefix_and_int(AddressPrefix.EOA, 1) assert item[1] == 100 else: assert account.delegations_amount == 0 if address == delegated_address: assert account.delegated_amount == 100 else: assert account.delegated_amount == 0
def test_put_delegation_to_state_db(self): cached_accounts: Dict['Address', Tuple['Account', int]] = OrderedDict() context = Mock() context.revision = Revision.DECENTRALIZATION.value context.storage.icx.get_account = Mock(side_effect=get_account) total_delegating = 0 new_delegations: List[Tuple['Address', int]] = [] for i in range(10): value: int = i + 11 address = Address.from_prefix_and_int(AddressPrefix.EOA, value) new_delegations.append((address, value)) total_delegating += value sender_account = context.storage.icx.get_account(context, SENDER_ADDRESS, Intent.ALL) cached_accounts[SENDER_ADDRESS] = sender_account, 0 # Put old delegations to cached_accounts for address, value in sender_account.delegations: account = context.storage.icx.get_account(context, address, Intent.DELEGATED) cached_accounts[address] = account, -value # Put new delegations to cached_accounts for i in range(10): value: int = i + 11 address = Address.from_prefix_and_int(AddressPrefix.EOA, value) account = context.storage.icx.get_account(context, address, Intent.DELEGATED) cached_accounts[address] = account, value updated_accounts: List['Account'] = IISSEngine._put_delegation_to_state_db( context, SENDER_ADDRESS, new_delegations, cached_accounts) # sender_account(1) + old_delegated_accounts(10) + new_delegated_accounts(10) assert len(updated_accounts) == len(cached_accounts) == 21 assert len(context.storage.icx.put_account.call_args_list) == len(cached_accounts) for i, address in enumerate(cached_accounts): call_args = context.storage.icx.put_account.call_args_list[i] account = call_args[0][1] assert isinstance(account, Account) assert address == account.address assert account == updated_accounts[i] if i == 0: assert account.address == SENDER_ADDRESS assert account.delegated_amount == 0 assert account.delegations == new_delegations assert account.delegations_amount == total_delegating else: # Assume that all delegated accounts do not delegate any other accounts assert account.delegations_amount == 0 if i <= 10: # old delegations assert account.delegated_amount == 0 else: assert account.delegated_amount == cached_accounts[address][1]
def test__convert_params_of_set_delegation_with_value_0(self): params = {} delegations = [] total_delegating = 0 for i in range(IISS_MAX_DELEGATIONS): address = Address.from_prefix_and_int(AddressPrefix.EOA, i + 1) value = 0 if i < 5 else i + 1 delegations.append({ "address": str(address), "value": hex(value) }) total_delegating += value params[ConstantKeys.DELEGATIONS] = delegations ret_total_delegating, ret_delegations = IISSEngine._convert_params_of_set_delegation(params) assert ret_total_delegating == total_delegating == (6 + 7 + 8 + 9 + 10) assert len(ret_delegations) == 5 i = 5 # 5 delegations including 0 value were dropped. for address, value in ret_delegations: delegation: Dict[str, Optional[str, int]] = delegations[i] assert str(address) == delegation["address"] assert hex(value) == delegation["value"] i += 1
def test__convert_params_of_set_delegation_ok(self): params = {} delegations = [] total_delegating = 0 for i in range(IISS_MAX_DELEGATIONS): address = Address.from_prefix_and_int(AddressPrefix.EOA, i + 1) value = random.randint(1, 10_000) delegations.append({ "address": str(address), "value": hex(value) }) total_delegating += value params[ConstantKeys.DELEGATIONS] = delegations ret_total_delegating, ret_delegations = IISSEngine._convert_params_of_set_delegation(params) assert ret_total_delegating == total_delegating for i in range(len(delegations)): item: Tuple['Address', int] = ret_delegations[i] address: 'Address' = item[0] value: int = item[1] assert str(address) == delegations[i]["address"] assert hex(value) == delegations[i]["value"]
def create_dummy_preps(size: int, main_preps: int, elected_preps: int) -> 'PRepContainer': assert elected_preps <= size <= 1000 preps = PRepContainer() # Create dummy preps for i in range(size): address = Address.from_prefix_and_int(AddressPrefix.EOA, i) delegated = icx_to_loop(1000 - i) if i < main_preps: grade = PRepGrade.MAIN elif i < elected_preps: grade = PRepGrade.SUB else: grade = PRepGrade.CANDIDATE prep = PRep(address, grade=grade, block_height=i, delegated=delegated) prep.freeze() assert prep.grade == grade assert prep.delegated == delegated assert prep.block_height == i preps.add(prep) assert preps.size(active_prep_only=True) == size assert preps.size(active_prep_only=False) == size return preps
def test_run(self, tx_collector): address = Address.from_prefix_and_int(AddressPrefix.EOA, 0) tx_filter = TransactionFilterByAddress(address) tx_collector.run(start_block_height=0, end_block_height=10, tx_filter=tx_filter) assert isinstance(tx_collector.transactions, list)
def test_convert_params_of_set_delegation_with_duplicate_address(self, context): delegations = [] for i in range(2): address = Address.from_prefix_and_int(AddressPrefix.EOA, 1) value = random.randint(1, 100) delegations.append({"address": address, "value": value}) with pytest.raises(InvalidParamsException): IISSEngine._convert_params_of_set_delegation(context, delegations)
def test_deposit_nonexistent_score(self): # give icx to tester self.transfer_icx(from_=self._admin, to_=self._accounts[0], value=10000 * ICX_IN_LOOP) # deposit icx in nonexistent SCORE with self.assertRaises(InvalidRequestException) as e: self.deposit_icx(score_address=Address.from_prefix_and_int(AddressPrefix.CONTRACT, 3), amount=MIN_DEPOSIT_AMOUNT, period=MIN_DEPOSIT_TERM)
def test_convert_params_of_set_delegation_with_value_less_than_0(self, context): delegations = [] values = [1, 2, 3, 4, -100] for i in range(5): address = Address.from_prefix_and_int(AddressPrefix.EOA, i + 1) value = values[i] delegations.append({"address": address, "value": value}) with pytest.raises(InvalidParamsException): IISSEngine._convert_params_of_set_delegation(context, delegations)
def create_delegations_param() -> Tuple[int, List]: max_delegations: int = 10 delegations = [] total_delegating = 0 for i in range(max_delegations): _id = i + 11 address = Address.from_prefix_and_int(AddressPrefix.EOA, _id) value = _id delegations.append({"address": address, "value": value}) total_delegating += value return total_delegating, delegations
def test_convert_params_of_set_delegation_with_too_many_delegations(self, context): max_delegations: int = self._get_expected_max_delegations(context) delegations = [] for i in range(max_delegations + 1): address = Address.from_prefix_and_int(AddressPrefix.EOA, i + 1) value = random.randint(1, 10_000) delegations.append({ "address": str(address), "value": hex(value) }) with pytest.raises(InvalidParamsException): IISSEngine._convert_params_of_set_delegation(context, delegations)
def create_sender_account(stake: int): total_delegating = 0 old_delegations: List[Tuple['Address', int], ...] = [] for i in range(IISS_MAX_DELEGATIONS): value = i + 1 address = Address.from_prefix_and_int(AddressPrefix.EOA, value) old_delegations.append((address, value)) total_delegating += value sender_address = SENDER_ADDRESS return create_account( address=sender_address, balance=icx_to_loop(10), stake=stake, unstake=0, unstake_block_height=0, delegated_amount=0, delegations=old_delegations)
def test__convert_params_of_set_delegation_with_too_many_delegations(self): params = {} delegations = [] for i in range(IISS_MAX_DELEGATIONS + 1): address = Address.from_prefix_and_int(AddressPrefix.EOA, i + 1) value = random.randint(1, 10_000) delegations.append({ "address": str(address), "value": hex(value) }) params[ConstantKeys.DELEGATIONS] = delegations with pytest.raises(InvalidParamsException): IISSEngine._convert_params_of_set_delegation(params)
def _create_preps(size: int): preps = PRepContainer() # Create dummy preps for i in range(size): address = Address.from_prefix_and_int(AddressPrefix.EOA, i) delegated = icx_to_loop(1000 - i) prep = PRep(address, block_height=i, delegated=delegated) prep.freeze() assert prep.grade == PRepGrade.CANDIDATE assert prep.delegated == delegated assert prep.block_height == i preps.add(prep) return preps
def test_handle_set_delegation_with_1_account(self): context = Mock() context.tx.origin = SENDER_ADDRESS context.storage.icx.get_account = Mock(side_effect=get_account) params = {} new_delegations = [{ "address": str(Address.from_prefix_and_int(AddressPrefix.EOA, 1)), "value": hex(100) }] params[ConstantKeys.DELEGATIONS] = new_delegations class IISSEngineListenerImpl(IISSEngineListener): def on_set_stake(self, _context: 'IconScoreContext', account: 'Account'): assert False def on_set_delegation(self, _context: 'IconScoreContext', updated_accounts: List['Account']): # sender_account(1) + updated_delegated_account(10) assert len(updated_accounts) == 11 delegated_address = Address.from_prefix_and_int(AddressPrefix.EOA, 1) for i, account in enumerate(updated_accounts): assert isinstance(account, Account) address = account.address if i == 0: # sender_account assert account.delegated_amount == 0 assert len(account.delegations) == 1 assert account.delegation_part.delegations_amount == 100 item = account.delegations[0] assert item[0] == Address.from_prefix_and_int(AddressPrefix.EOA, 1) assert item[1] == 100 else: assert account.delegations_amount == 0 if address == delegated_address: assert account.delegated_amount == 100 else: assert account.delegated_amount == 0 engine = IISSEngine() engine.add_listener(IISSEngineListenerImpl()) engine.handle_set_delegation(context, params)
def test_invalid_owner(self): params = {'serviceFlag': hex(IconServiceFlag.audit)} tx = self._make_score_call_tx(Address.from_prefix_and_int( AddressPrefix.CONTRACT, 2), GOVERNANCE_SCORE_ADDRESS, 'updateServiceConfig', params=params) raise_exception_start_tag("test_invalid_owner") prev_block, tx_results = self._make_and_req_block([tx]) raise_exception_end_tag("test_invalid_owner") self._write_precommit_state(prev_block) self.assertEqual(tx_results[0].status, int(False)) self.assertEqual(tx_results[0].failure.code, ExceptionCode.SCORE_ERROR) self.assertEqual(tx_results[0].failure.message, f'Invalid sender: not owner')
def create_delegations_param() -> Tuple[int, Dict]: params = {} delegations = [] total_delegating = 0 for i in range(IISS_MAX_DELEGATIONS): _id = i + 11 address = Address.from_prefix_and_int(AddressPrefix.EOA, _id) value = _id delegations.append({ "address": str(address), "value": hex(value) }) total_delegating += value params[ConstantKeys.DELEGATIONS] = delegations return total_delegating, params
def test__convert_params_of_set_delegation_with_value_less_than_0(self): params = {} delegations = [] values = [1, 2, 3, 4, -100] for i in range(5): address = Address.from_prefix_and_int(AddressPrefix.EOA, i + 1) value = values[i] delegations.append({ "address": str(address), "value": hex(value) }) params[ConstantKeys.DELEGATIONS] = delegations with pytest.raises(InvalidParamsException): IISSEngine._convert_params_of_set_delegation(params)
def _get_iiss_tx_type(cls, transaction: dict) -> "IISSTXType": iiss_tx_methods = { "setDelegation": IISSTXType.DELEGATION, "registerPRep": IISSTXType.REGISTER_PREP, "unregisterPRep": IISSTXType.UNREGISTER_PREP, } try: data_type: str = transaction["dataType"] if data_type == "call": to: "Address" = Address.from_string(transaction["to"]) if to == Address.from_prefix_and_int(AddressPrefix.CONTRACT, 0): data: dict = transaction["data"] method: str = data["method"] return iiss_tx_methods.get(method, IISSTXType.NONE) except: pass return IISSTXType.NONE
def test_deploy_command_with_score_params(self): # start self.cmd.cmdServer.start(self.start_conf) self.assertTrue(self.cmd.cmdServer.is_service_running()) project_name = os.path.join(TEST_DIRECTORY, "simpleScore2") # deploy - install with scoreParams deploy_args = { "mode": "install", "from": "hxef73db5d0ad02eb1fadb37d0041be96bfa56d4e6", "scoreParams": { "score_address": str(Address.from_prefix_and_int(AddressPrefix.CONTRACT, 123)) } } conf = self.cmd.cmdScore.get_icon_conf(command='deploy', project=project_name, args=deploy_args) deploy_response = self.deploy_cmd(conf=conf) self.assertEqual(deploy_response.get('error', False), False) # check result tx_hash = deploy_response['result'] conf = self.cmd.cmdWallet.get_icon_conf('txbyhash', {'hash': tx_hash}) conf = self.cmd.cmdWallet.get_icon_conf('txresult', {'hash': tx_hash}) transaction_result_response = self.cmd.cmdWallet.txresult(conf) score_address = transaction_result_response['result']['scoreAddress'] self.assertFalse(transaction_result_response.get('error', False)) # deploy - update with scoreParams deploy_args["mode"] = "update" deploy_args["to"] = score_address deploy_args["scoreParams"] = { "value": "test_value"} conf = self.cmd.cmdScore.get_icon_conf(command='deploy', project=project_name, args=deploy_args) deploy_response = self.deploy_cmd(conf=conf) self.assertEqual(deploy_response.get('error', False), False) # check result tx_hash = deploy_response['result'] conf = self.cmd.cmdWallet.get_icon_conf('txresult', {'hash': tx_hash}) transaction_result_response = self.cmd.cmdWallet.txresult(conf) score_address = transaction_result_response['result']['scoreAddress'] self.assertFalse(transaction_result_response.get('error', False))
def test_convert_params_of_set_delegation_ok(self, context): max_delegations: int = self._get_expected_max_delegations(context) delegations = [] total_delegating = 0 for i in range(max_delegations): address = Address.from_prefix_and_int(AddressPrefix.EOA, i + 1) value = random.randint(1, 10_000) delegations.append({"address": address, "value": value}) total_delegating += value ret_total_delegating, ret_delegations = IISSEngine._convert_params_of_set_delegation(context, delegations) assert ret_total_delegating == total_delegating for i in range(len(delegations)): item: Tuple['Address', int] = ret_delegations[i] address: 'Address' = item[0] value: int = item[1] assert address == delegations[i]["address"] assert value == delegations[i]["value"]
def setUp(self) -> None: self.sequence = random.randint(0, 1000) self.start_block_height = random.randint(0, 1000) self.period = TERM_PERIOD self.irep = random.randint(10000, 50000) self.total_supply = 800_600_000 self.total_delegated = 2000 * 10**18 self.term = Term(sequence=self.sequence, start_block_height=self.start_block_height, period=self.period, irep=self.irep, total_supply=self.total_supply, total_delegated=self.total_delegated) assert not self.term.is_frozen() assert not self.term.is_dirty() _check_prep_snapshots_in_term(self.term) keys = "sequence", "start_block_height", "period", "irep", "total_supply", "total_delegated" for key in keys: assert getattr(self.term, key) == getattr(self, key) self.preps = [] self.total_elected_prep_delegated = 0 for i in range(PREP_MAIN_AND_SUB_PREPS + 10): delegated = 100 * 10**18 - i self.preps.append( PRep(Address.from_prefix_and_int(AddressPrefix.EOA, i), delegated=delegated)) if i < PREP_MAIN_AND_SUB_PREPS: self.total_elected_prep_delegated += delegated self.term.set_preps(self.preps, PREP_MAIN_PREPS, PREP_MAIN_AND_SUB_PREPS) assert not self.term.is_dirty()
def test_convert_params_of_set_delegation_with_value_0(self, context): max_delegations: int = self._get_expected_max_delegations(context) delegations = [] total_delegating = 0 zero_value_cnt: int = 5 for i in range(max_delegations): address = Address.from_prefix_and_int(AddressPrefix.EOA, i + 1) value = 0 if i < zero_value_cnt else i + 1 delegations.append({"address": address, "value": value}) total_delegating += value ret_total_delegating, ret_delegations = IISSEngine._convert_params_of_set_delegation(context, delegations) assert ret_total_delegating == total_delegating == sum([i + 1 for i in range(5, max_delegations)]) assert len(ret_delegations) == max_delegations - zero_value_cnt i = zero_value_cnt # 5 delegations including 0 value were dropped. for address, value in ret_delegations: delegation: Dict[str, Optional[str, int]] = delegations[i] assert address == delegation["address"] assert value == delegation["value"] i += 1
def test_handle_get_prep_term_with_penalized_preps(self): block_height = 200 sequence = 78 period = 43120 start_block_height = 200 end_block_height = 200 + period - 1 irep = icx_to_loop(40000) total_supply = icx_to_loop(800_460_000) total_delegated = icx_to_loop(1000) params = {} context = Mock() context.block.height = block_height main_prep_count = 22 elected_prep_count = 100 total_prep_count = 106 term = Term(sequence=sequence, start_block_height=start_block_height, period=period, irep=irep, total_supply=total_supply, total_delegated=total_delegated) preps = PRepContainer() for i in range(total_prep_count): address = Address.from_prefix_and_int(AddressPrefix.EOA, i) delegated = icx_to_loop(1000 - i) penalty = PenaltyReason.NONE status = PRepStatus.ACTIVE if 0 <= i <= 4: # block validation penalty preps: 5 penalty: 'PenaltyReason' = PenaltyReason.BLOCK_VALIDATION elif i == 5: # unregistered preps: 1 status = PRepStatus.UNREGISTERED elif 6 <= i <= 7: # low productivity preps: 2 status = PRepStatus.DISQUALIFIED penalty = PenaltyReason.LOW_PRODUCTIVITY elif 8 <= i <= 10: # disqualified preps: 3 status = PRepStatus.DISQUALIFIED penalty = PenaltyReason.PREP_DISQUALIFICATION prep = PRep(address, block_height=i, delegated=delegated, penalty=penalty, status=status) prep.freeze() preps.add(prep) preps.freeze() assert preps.size(active_prep_only=False) == total_prep_count electable_preps = filter(lambda x: x.is_electable(), preps) term.set_preps(electable_preps, main_prep_count=main_prep_count, elected_prep_count=elected_prep_count) engine = PRepEngine() engine.term = term engine.preps = preps ret: dict = engine.handle_get_prep_term(context) assert ret["blockHeight"] == block_height assert ret["sequence"] == sequence assert ret["startBlockHeight"] == start_block_height assert ret["endBlockHeight"] == end_block_height assert ret["totalSupply"] == total_supply assert ret["totalDelegated"] == total_delegated assert ret["irep"] == irep prep_list: List[Dict[str, Union[int, str, 'Address']]] = ret["preps"] assert len(prep_list) == elected_prep_count for i, prep_snapshot in enumerate(term.preps): prep_item: Dict[str, Union[int, str, 'Address']] = prep_list[i] assert prep_item["address"] == prep_snapshot.address assert prep_item["status"] == PRepStatus.ACTIVE.value assert prep_item["penalty"] == PenaltyReason.NONE.value # The P-Reps which got penalized for consecutive 660 block validation failure # are located at the end of the P-Rep list prev_delegated = -1 for i, prep_item in enumerate(prep_list[-5:]): assert prep_item["address"] == Address.from_prefix_and_int(AddressPrefix.EOA, i) assert prep_item["status"] == PRepStatus.ACTIVE.value assert prep_item["penalty"] == PenaltyReason.BLOCK_VALIDATION.value delegated: int = prep_item["delegated"] if prev_delegated >= 0: assert prev_delegated >= delegated prev_delegated = delegated
verify_score_flag(ScoreFlag.PAYABLE, allow_payable_only=True) @pytest.mark.parametrize("type_hint,default,success", [ (bool, 0, False), (bytes, "hello", False), (int, "world", False), (int, False, False), (str, True, False), (Address, 1, False), (str, None, True), (bool, False, True), (bytes, b"hello", True), (int, 1, True), (str, "hello", True), (Address, Address.from_prefix_and_int(AddressPrefix.EOA, 1), True), (str, None, True), (Union[int, None], None, True), (Union[None, int], 0, False), (Person, None, True), (List[int], None, True), (Union[List[Person], None], None, True), (Dict[str, int], None, True), (Union[Dict[str, int], None], None, True), (Optional[bool], None, True), (Optional[bytes], None, True), (Optional[int], None, True), (Optional[str], None, True), (Optional[Address], None, True), ]) def test_check_parameter_default_type(type_hint, default, success):
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from enum import IntEnum, auto from typing import List, Iterable, Tuple, Dict, Optional import sys from iconservice.base.address import AddressPrefix, Address from ..data.transaction import Transaction from ..data.transaction_result import TransactionResult from ..utils.convert_type import bytes_to_hex, str_to_int ICON_SERVICE_ADDRESS = Address.from_prefix_and_int(AddressPrefix.CONTRACT, 0) class StakeInfo(object): def __init__(self): self.stake = 0 self.unstake = 0 self.block_height = 0 self.block_hash: Optional[bytes] = None self.tx_hash: Optional[bytes] = None def __str__(self) -> str: return (f"stake={self.stake} " f"unstake={self.unstake} " f"block_height={self.block_height} " f"block_hash={bytes_to_hex(self.block_hash)} "
335020, 327218, 319680, 312407, 305398, 298653, 292173, 285958, 280007, 274320, 268898, 263740, 258847, 254219, 249855, 245755, 241920, 238349, 235043, 232002, 229224, 226712, 224464, 222480, 220761, 219306, 218116, 217190, 216529, 216132, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000 ] SENDER_ADDRESS = Address.from_prefix_and_int(AddressPrefix.EOA, 0) def create_account( address: 'Address', balance: int, stake: int, unstake: int, unstake_block_height: int, delegated_amount: int, delegations: List[Tuple[Address, int]]) -> 'Account': coin_part = CoinPart(balance=balance) stake_part = StakePart(stake, unstake, unstake_block_height) delegation_part = DelegationPart(delegated_amount, delegations) return Account( address, 1024, coin_part=coin_part, stake_part=stake_part, delegation_part=delegation_part)