def test_account(tmp_path): test_configuration = prepare_conf(tmp_path) WalletAPI.new_wallet(test_configuration, 'my-password') assert len(list( tmp_path.iterdir())) == 2 # one config.yaml and one keystore address, pub_key = WalletAPI.get_wallet(test_configuration) public_key_bytes = decode_hex(pub_key) assert len(public_key_bytes) == 64 assert Web3.isAddress(address) assert Web3.isChecksumAddress(address)
def test_account(tmp_path): test_configuration = prepare_conf(tmp_path) # mocker.patch('eth_wallet.configuration.Configuration.__init__', # return_value=test_config) WalletAPI.new_wallet(test_configuration, 'my-password') assert len(list( tmp_path.iterdir())) == 2 # one config.yaml and one keystore address, pub_key = WalletAPI.get_wallet(test_configuration) public_key_bytes = decode_hex(pub_key) assert len(public_key_bytes) == 64 assert Web3.isAddress(address) assert Web3.isChecksumAddress(address)
class NewWalletPage(Page): def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) self.configuration = None self.api = WalletAPI() self.wallet = None lbl_pswd = Label(self, text='Passphrase:', width=60, font=(None, 20)) lbl_pswd.pack() entry_password = Entry(self, show="*", font=(None, 20), justify=CENTER) entry_password.pack() btn_create_wallet = Button( self, text="Generate", width=60, font=(None, 16), command=lambda: self.create_wallet(btn_create_wallet, entry_password.get())) btn_create_wallet.pack() def create_wallet(self, btn_create_wallet, password): """ Create new wallet :param btn_create_wallet: generate button which change text and functionality :param password: passphrase from the user :return: """ self.configuration = Configuration().load_configuration() self.wallet = self.api.new_wallet(self.configuration, password) lbl_remember_words = Label(self, text='Restore sentence:', width=60) lbl_remember_words.pack() lbl_mnemonic = Message(self, text=self.wallet.get_mnemonic(), justify=CENTER, borderwidth=10, background='light blue') lbl_mnemonic.pack() btn_create_wallet.configure(text="Continue", command=self.navigate_home_page) def navigate_home_page(self): """ Navigate to home page :return: """ info_page = HomePage(self) info_page.place(in_=self, x=0, y=0, relwidth=1, relheight=1) info_page.show()