def _test_transfer_qa(self): chain.set_active_chain(chain.TestNet) account = Account(address="b50c2404e699fd985f71b2c3f032059f13d6543b") print(account) print("Account1 balance", repr(account.get_balance())) account2 = Account.from_keystore("zxcvbnm,", path_join("crypto", "zilliqa_keystore.json")) print(account2) balance = account2.get_balance() print("Account2 balance", repr(balance)) assert balance > 0 txn_info = account2.transfer(account.bech32_address, Qa(123456789)) pprint(txn_info) txn_details = account2.wait_txn_confirm(txn_info["TranID"], timeout=240) pprint(txn_details) assert txn_details print("Account1 balance", repr(account.get_balance())) print("Account1 balance", repr(account.get_balance_qa())) account = Account(private_key="d0b47febbef2bd0c4a4ee04aa20b60d61eb02635e8df5e7fd62409a2b1f5ddf8") txn_info = account.transfer(account2.checksum_address, Qa(123456789), confirm=True) pprint(txn_info)
def _test_transfer_confirm(self): chain.set_active_chain(chain.TestNet) account = Account(address="b50c2404e699fd985f71b2c3f032059f13d6543b") print(account) balance1 = account.get_balance() print("Account1 balance", balance1) with pytest.raises(RuntimeError): account.transfer("to_addr", 1) account2 = Account.from_keystore("zxcvbnm,", path_join("crypto", "zilliqa_keystore.json")) print(account2) balance = account2.get_balance() print("Account2 balance", balance) assert balance > 0 result = account2.transfer(account.checksum_address, Zil(10.3), confirm=True, timeout=300, sleep=20) print("Transfer Result", result) pprint(account2.last_params) pprint(account2.last_txn_info) pprint(account2.last_txn_details) balance2 = account.get_balance() print("Account1 balance", balance2) assert balance2 >= balance1 + 10.299 account = Account(private_key="d0b47febbef2bd0c4a4ee04aa20b60d61eb02635e8df5e7fd62409a2b1f5ddf8") result = account.transfer(account2.bech32_address, 10.3, confirm=True, timeout=600, sleep=20) print("Transfer Result", result) pprint(account2.last_params) pprint(account2.last_txn_info) pprint(account2.last_txn_details)
def login_with_password(self, add_account): account = Account(add_account=add_account).count_account() #print(account+'-') num_account = int(account) % 6 account_numb = Account(num_account=num_account).give_me_account() inputElement = self.driver.find_elements_by_tag_name('input') input_username = self.driver.find_element_by_css_selector('#mobile') input_username.send_keys(account_numb) input_passwoard = self.driver.find_element_by_css_selector('#password') input_passwoard.send_keys('Exo983106(*') try: text_found = None i = 0 while text_found == None: i = i + 1 self.driver.find_element_by_css_selector( 'div > div.body.-scorll-fix.modal-scroll > div > div > div.module.module1.module2.loginmodule.collapse.in > div.sign-in > div.modulein.modulein1.mobile_box.f-base.collapse.in > div.btn.-xl.btn-primary.-block' ).click() src = self.driver.page_source time.sleep(1) text_found = re.search(r'请先完成下方验证', src) time.sleep(1) if i == 5: self.driver.refresh() #print('inside the login_with_password') Login.login(self, False) Login.autologin(self) except: time.sleep(3) driver = Login.autologin(self) return driver
def initialiseAccounts(self): account1 = Account("root", "root", self) account1.deposit(100) account2 = Account("Alan", "password", self) account2.deposit(200) return [account1, account2]
def test_fee(self): account1 = Account("12345", 500) checking_init = Checking("12345", 500, 5) print("Checking inherit fee: ", checking_init.fee) self.assertEqual( checking_init.fee, 5) # check to see if both inheritance and balance works
def test_call_other_account(self): contract = Contract.load_from_address("45dca9586598c8af78b191eaa28daf2b0a0b4f43") print(contract) print(contract.status) print(contract.code) pprint(contract.init) pprint(contract.state) account2 = Account(private_key="d0b47febbef2bd0c4a4ee04aa20b60d61eb02635e8df5e7fd62409a2b1f5ddf8") print("Account2 balance", account2.get_balance()) contract.account = account2 resp = contract.call(method="setHello", params=[ Contract.value_dict("msg", "String", "hello from another account") ]) print(resp) pprint(contract.last_receipt) assert contract.last_receipt["success"] assert contract.last_receipt["event_logs"][0]["params"][0]["vname"] == "code" assert contract.last_receipt["event_logs"][0]["params"][0]["value"] == "1" resp = contract.call(method="getHello", params=[]) print(resp) pprint(contract.last_receipt) assert contract.last_receipt["success"] assert contract.last_receipt["event_logs"][0]["_eventname"] == "getHello()" assert contract.last_receipt["event_logs"][0]["params"][0]["vname"] == "msg" assert contract.last_receipt["event_logs"][0]["params"][0]["type"] == "String" assert contract.last_receipt["event_logs"][0]["params"][0]["value"] == "hi contract."
def get_accounts_from_json(self, path_to_json): accounts_info = dict() users_info = list() new_accounts = 0 # Check configuration server try: file_accounts = open(path_to_json, "rb") accounts_info = json.load(file_accounts) file_accounts.close() except Exception as ex: LogSystem.LogSystem.CRITICAL(str(ex)) if "Users" in accounts_info: users_info = accounts_info["Users"] else: LogSystem.LogSystem.CRITICAL("'Users' is not set in " + path_to_json) for account_info in users_info: if self.check_new_account(account_info): self.accounts.append(Account.Account(account_info)) if self.accounts[-1].disk is None: self.accounts.pop() else: new_accounts += 1 return new_accounts
def startKairiSim(self, start_ind, end_ind, kairi_term, kairi_kijun, pt, lc): ac = Account.Account() for i in range(end_ind - start_ind): tdd = Strategy.Startegy.contrarian_kairi(i + start_ind, ac, kairi_term, kairi_kijun, pt, lc)
def main(): winsound.Beep(500, 100) printWithTime("警告:请务必使用'管理员权限'运行!") accountCount = int(inputWithTimePrompt("账户数:")) while accountCount: accountCount -= 1 gameMode = int( inputWithTimePrompt( "游戏类型:\n(0.实时活动 1.多人御魂/觉醒 2.章节探索 3.单人御魂/业原火/御灵 4.结界突破 5.道馆 6.妖气封印 7.邀请寮成员 8.阴阳寮突破 9.结界卡合成 10.百鬼夜行):" )) count = int(inputWithTimePrompt("局数:")) startX = int(inputWithTimePrompt("窗口起始位置X:")) startY = int(inputWithTimePrompt("窗口起始位置Y:")) windowWidth = int(inputWithTimePrompt("窗口宽度:")) windowHeight = int(inputWithTimePrompt("窗口高度:")) isCaptainChar = inputWithTimePrompt("是否为房主(Y/N):") feedbackerName = inputWithTimePrompt("QQ反馈者名称:") isCaptain = False if isCaptainChar == 'y' or isCaptainChar == "Y": isCaptain = True else: isCaptain = False accounts.append( Account(gameMode, count, startX, startY, windowWidth, windowHeight, isCaptain, feedbackerName)) for account in accounts: account.start()
def addAccount(self, client_name): newAccount = Account.Account((len(self.accounts) + 1, { "client_name": client_name, "cards": [] })) self.accounts.append(newAccount) return newAccount
def login(self, up_date): #print('initial login') trying = self.driver.find_elements_by_class_name('nav-item ') WebDriverWait(self.driver, 2) Account(up_date).count_account() try: i = 0 for each in trying: i = i + 1 if each.text == '登录/注册': each.click() password_login = self.driver.find_elements_by_xpath( '//div[contains(@class, "title")]') for each_link in password_login: if each_link.get_attribute( 'onclick') == 'loginObj.changeCurrent(1);': each_link.click() #print('start login') time.sleep(1) Login.login_with_password(self, up_date) return self.driver #print(i) #if i ==len(trying): #time.sleep(1) #self.driver.refresh() #Login.login(self, False) except: self.driver.refresh() Login.login(self, False)
def __init__(self, databaseFile): self.databaseFile = databaseFile self.accounts = [] if not os.path.exists(databaseFile): return with open(databaseFile, 'r') as db: for client in json.load(db).items(): self.accounts.append(Account.Account(client))
def main(): user_interface() # Set global time variables trading_day = 0 # Initialize performance data frame performance = [] # Start back-test account = acc.Account(INITIAL_CAPITAL) while trading_day <= DAYS: performance.append(daily_execution(trading_day, account)) trading_day = trading_day + 1 # Calculate net values and save back-test result to files print('****** Back-test finished, generating output data ******') columns = ['Account', 'HS300'] performance = pd.DataFrame(performance, columns=columns) performance_return = strt.get_return_data(performance) net_value = pd.DataFrame(np.ones((len(performance_return), 2)), columns=columns) net_value.iloc[0] = [1, 1] for i in range(1, len(net_value)): net_value.iloc[i] = net_value.iloc[i - 1] * ( net_value.iloc[0] + performance_return.iloc[i - 1]) performance.to_csv(OUTPUT_PATH + 'performance.csv') performance_return.to_csv(OUTPUT_PATH + 'return.csv') net_value.to_csv(OUTPUT_PATH + 'netValue.csv') # Print performance data performance_management(performance_return, net_value)
def txn_new(self, items): """Function to process a new transaction code. Creates a new account """ try: accountNum = int(items[1]) except ValueError: #Handle the exception if user did not enter an integer err.process_error("ERR_INVALIDACCOUNTNUM") #Since the back end should only get valid input, exit the back end on any value error. sys.exit() #Make sure new account number is unused/unique if (accountNum in accounts_dic): err.process_error("ERR_BADACCOUNTNUM") return accountName = items[4] if (utl.account_name_exists(accountName)): err.process_error("ERR_USEDACCOUNTNAME") return #Create the new account object accountObj = Account.Account(accountNum, 000, accountName) #Add new account to dictionary list of items accounts_dic[accountObj.get_account_num()] = accountObj #new account creation successfully completed. return
def withdraw_money(self): account1 = Account("12345", 500) # inheritence check checking_init = Checking(account1.accountNumber, account1.balance, 5) # Withdraw 10 withdraw = checking_init.withdraw_money(10) self.assertEqual(checking_init.balance - 10, withdraw)
def build(self): screen_manager = ScreenManager() screen_manager.add_widget(Log.LogPage(name="LogPage")) screen_manager.add_widget(Reg.RegPage(name="RegPage")) screen_manager.add_widget(Account.Account(name="Account")) return screen_manager
def addAccount(self, name): if name in self.accounts: return "Already exists" self.accounts[name] = Account(name) self.updateDB() return "Added successfully"
def sendMoney(account): print("Enter the amount for transfer") try: amount = int(input("- ")) if account.balance - amount < 0: print("The maximum you can withdraw is $" + str(abs(0-account.balance))) sendMoney(account) print("\nEnter the card number of the recipient") cardNumber = input("- ") found = False with open("accounts.txt") as fileObjc: for each in fileObjc.readlines(): data = each.split() if data[0] == cardNumber: found = True recipient = Account(cardNumber, int(data[2])) recipient.addBalance(amount) account.subtractBalance(amount) updateDatabase(recipient) updateDatabase(account) print("Transfer success!\n") mainMenu(account) break if found == False: print("Recipient not found in the database!") sendMoney(account) except: sendMoney(account)
def loginAccount(): print("Enter your card number!") cardNumber = input("- ") print("Enter your password") password = input("- ") found = False balance = 0 with open("accounts.txt") as fileObjc: for line in fileObjc.readlines(): line = line.split() if line[0] == cardNumber: try: decryptedPassword = decrypt(password, base64.b64decode(line[1])).decode("utf8") except: print("Incorrect password! Try again!") loginAccount() if decryptedPassword == password: print("You logged in successfully!\n") found = True balance = int(line[2]) account = Account(line[0], balance) mainMenu(account) break else: break if found == False: print("Authenticatin failed!") print() welcome()
def createAccount(): username = request.values.get("username") password = request.values.get("password") #create account account = Account(username, password, bank) bank.addAccount(account) return render_template("account.html", account=account)
def testDeposit(self): print("---Testing account's deposit method---") test_account = Account(200) test_account.deposit(211) self.assertEqual(411, test_account.amount) self.assertEqual(True, test_account.deposit(21.4)) self.assertEqual(False, test_account.deposit(-42)) print("\n")
def testWithdraw(self): print("---Testing account's withdraw method---") test_account = Account(1000) self.assertEqual(False, test_account.withdraw(-4)) self.assertEqual(True, test_account.withdraw(4)) self.assertEqual(996, test_account.amount) self.assertEqual(False, test_account.withdraw(1000)) print("\n")
def test_balance_inherit(self): # create account account1 = Account("12345", 500) checking_init = Checking("12345", 500, 5) print("Checking inherit test: ", checking_init.balance) self.assertEqual( account1.balance, checking_init.balance ) # check to see if both inheritance and balance works
def test_acctNum_inherit(self): # create account account1 = Account("12345", 500) checking_init = Checking("12345", 500, 5) print("Checking account number test: ", checking_init.accountNumber) self.assertEqual( account1.accountNumber, checking_init.accountNumber ) # check to see if both inheritance and balance works
def deposit_money(self): account1 = Account("12345", 500) # inheritence check checking_init = Checking(account1.accountNumber, account1.balance, 5) # We are going to deposit 10 bucks. So we know there should be 510 print("Checking balance: ", checking_init.deposit_money(10)) self.assertEqual(checking_init.balance + 10, checking_init.deposit_money(10))
def test_create_new_wallet_for_existing_account_and_delete_wallet(self): """namesake""" email = TEST_EMAIL1 self.assertTrue(Account.known_email(email)) account = Account.Account(email) new_wallet = account.new_wallet_key() self.assertTrue(account.contains_wallet(new_wallet)) account.remove_wallet(new_wallet) self.assertFalse(account.contains_wallet(new_wallet))
def test_derive_address_and_private_key_from_wallet_key(self): """namesake""" account = Account.Account(TEST_EMAIL1) wallet = Wallet.Wallet.from_wallet_key(account.get_wallet_keys()[0]) self.assertEqual(('48127745670158140224676891053325956567208697269841' '885640624450352410061813546'), wallet.secret_exponent()) self.assertEqual('16EbFsiGJzP6nJA3tFT9umsBrp4Asgt4XH', wallet.address())
def test_derive_child_from_wallet_key(self): """namesake""" account = Account.Account(TEST_EMAIL1) wallet = Wallet.Wallet.from_wallet_key(account.get_wallet_keys()[0]) subkey = wallet.subkey().hwif() self.assertEqual( """xpub68JyWgiDsfyPDroyVmeYKkTp2CDL5QQ4sfYbLxqZEGs7eQVQ AWJHzumB4EL8oEzaqNFSYba2MS21Zo3DA8pU2iCp93EtHR1bZW8N7ev Xbs5""", subkey)
def register(accName, psw, tags) -> bool: if checkAccounts(accName): print("This account already exists!"); return False; account = Account.Account(accName, psw, tags); print("Registered!"); accounts[accName] = account; write_account(account); return True;
def coinbase(): account = Account.Account(TEST_EMAIL1) wallet = Wallet.Wallet.from_wallet_key(account.get_wallet_keys()[0]) address = wallet.address() assert is_address_valid(address) tx_in = TxIn.coinbase_tx_in(script=b'') tx_out = TxOut(50 * 1e8, standard_tx_out_script(address)) tx = Tx(1, [tx_in], [tx_out]) return tx.as_hex()