def __init__(self, name, creator): key_owner = pyteos.CreateKey("key_owner") key_active = pyteos.CreateKey("key_active") sess.wallet.import_key(key_owner) sess.wallet.import_key(key_active) super().__init__(creator, name, key_owner, key_active)
def __init__( self, contract_dir, wast_file="", abi_file="", permission="", expiration_sec=30, skip_signature=0, dont_broadcast=0, forceUnique=0, max_cpu_usage=0, max_net_usage=0, is_verbose=True): contract_dir = self.wslMapWindowsLinux(contract_dir) account_name = pathlib.Path(contract_dir).parts[-1] pattern = re.compile("^[a-z, ., 1-5]*$") if len(account_name) > 12 or not pattern.match(account_name): letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', \ 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', \ 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', \ 'y', 'z', '.', '1', '2', '3', '4', '5'] account_name = "" for i in range(0, 11): account_name += letters[random.randint(0, 31)] while True: last_letter = letters[random.randint(0, 31)] if last_letter != '.': account_name += last_letter break self.name = account_name account = pyteos.GetAccount( self.name, is_verbose=False, suppress_error_msg=True) if not account.error: self.account = account else: key_owner = pyteos.CreateKey("key_owner") key_active = pyteos.CreateKey("key_active") sess.wallet.import_key(key_owner) sess.wallet.import_key(key_active) self.account = pyteos.Account( sess.eosio, self.name, key_owner, key_active) if not permission: permission = account super().__init__( self.account, contract_dir, wast_file, abi_file, permission, expiration_sec, skip_signature, dont_broadcast, forceUnique, max_cpu_usage, max_net_usage, is_verbose)
def init(): """ Initialise a test session. - **global variables** eosio: Primary EOSIO account predefined in the genesis file. wallet: The wallet holding keys. alice, bob, carol: Prefabricated demo accounts. key_owner, key_active: Cryptographic keys. """ global eosio eosio = pyteos.AccountEosio(is_verbose=False) global wallet wallet = pyteos.Wallet(is_verbose=False) contract_eosio_bios = pyteos.SetContract(eosio, "eosio.bios", permission=eosio, is_verbose=False) global key_owner key_owner = pyteos.CreateKey("key_owner", is_verbose=False) global key_active key_active = pyteos.CreateKey("key_active", is_verbose=False) wallet.import_key(key_owner) wallet.import_key(key_active) global alice alice = pyteos.Account(eosio, "alice", key_owner, key_active, is_verbose=False) global bob bob = pyteos.Account(eosio, "bob", key_owner, key_active, is_verbose=False) global carol carol = pyteos.Account(eosio, "carol", key_owner, key_active, is_verbose=False)
def init(): """ Initialise a test session. - **global variables**:: eosio: The primary EOSIO account predefined in the genesis file. alice, bob, carol: Prefabricated demo accounts. key_owner, key_active: Cryptographic keys. wallet: The wallet holding keys. On error, return False. """ global eosio eosio = pyteos.AccountEosio() if eosio.error: print("AccountEosio error.") return False global wallet wallet = pyteos.Wallet() if wallet.error: print("Wallet error.") return False contract_eosio_bios = pyteos.SetContract(eosio, "eosio.bios", permission=eosio) if contract_eosio_bios.error: print("eosio.bios set contract error.") return False global key_owner key_owner = pyteos.CreateKey("key_owner") if key_owner.error: print("key_owner error.") return False global key_active key_active = pyteos.CreateKey("key_active", ) if key_active.error: print("key_active error.") return False ok = wallet.import_key(key_owner) and wallet.import_key(key_active) if not ok: print("wallet.import_key error.") return False global alice alice = pyteos.Account(eosio, "alice", key_owner, key_active) if alice.error: print("alice account error.") return False global bob bob = pyteos.Account(eosio, "bob", key_owner, key_active) if bob.error: print("bob account error.") return False global carol carol = pyteos.Account(eosio, "carol", key_owner, key_active) if carol.error: print("carol account error.") return False if pyteos.is_verbose(): print("# Available test accounts: " + eosio.name + ", " + alice.name + ", " + carol.name + ", " + bob.name + "\n") return True