How to use invoke_test method in autotest

Best Python code snippet using autotest_python

test_swap.py

Source: test_swap.py Github

copy

Full Screen

...18 current_balance_contract = int(token.GetBalance(user_wallet, TestSwapBase.swap_contract))19 amountToSwap = 100020 eth_addr = bytes.fromhex('7FAB4CB3D917719284F9E715A9c6B6FA1fBA217f')21 swap_args = [self.token_owner_addr(), eth_addr, Fixed8.FromDecimal(amountToSwap).value]22 tx, results = self.invoke_test(user_wallet, 'swapToEth', swap_args, contract=TestSwapBase.swap_contract.ToString())23 self.assertEqual(results[0].GetBoolean(), True)24 self.dispatched_events = []25 tx, block = self._invoke_tx_on_blockchain(tx, user_wallet)26 # now get the last event dispatched27 swap_event = self.dispatched_events[-1]28 self.assertEqual(swap_event.notify_type, b'onSwapToEth')29 event_results = swap_event.event_payload.Value30 self.assertEqual(len(event_results), 5)31 amount = event_results[3].Value32 ethAddr = event_results[2].Value33 addr = event_results[1].Value34 swapId = event_results[4].Value35 self.assertEqual(Fixed8.FromDecimal(amountToSwap).value, int.from_bytes(amount, 'little'))36 self.assertEqual(addr, self.token_owner_sh())37 self.assertEqual(ethAddr, eth_addr)38 self.assertEqual(swapId, '1')39 new_balance_user = int(token.GetBalance(user_wallet, self.token_owner_addr()))40 new_balance_contract = int(token.GetBalance(user_wallet, TestSwapBase.swap_contract))41 self.assertEqual(new_balance_contract, current_balance_contract + amountToSwap)42 self.assertEqual(new_balance_user, current_balance_user - amountToSwap)43 tx, results = self.invoke_test(user_wallet, 'totalSwapped', [], contract=TestSwapBase.swap_contract.ToString())44 amount = results[0].GetBigInteger()45 self.assertEqual(Fixed8.FromDecimal(new_balance_contract).value, amount)46 # invalid eth address47 invalid_eth_addr = bytes.fromhex('7FAB4CB3D917719284F9E715A9c6B6FA1fBA2a')48 swap_args = [self.token_owner_addr(), invalid_eth_addr, Fixed8.FromDecimal(amountToSwap).value]49 tx, results = self.invoke_test(user_wallet, 'swapToEth', swap_args, contract=TestSwapBase.swap_contract.ToString())50 self.assertEqual(len(results), 0)51 # Test min swap amount52 amountToSwap = 499.9999953 swap_args = [self.token_owner_addr(), eth_addr, Fixed8.FromDecimal(amountToSwap).value]54 tx, results = self.invoke_test(user_wallet, 'swapToEth', swap_args, contract=TestSwapBase.swap_contract.ToString())55 self.assertEqual(len(results), 0)56 # Test swap id increment57 amountToSwap = 60058 swap_args = [self.token_owner_addr(), eth_addr, Fixed8.FromDecimal(amountToSwap).value]59 60 tx, results = self.invoke_test(user_wallet, 'swapToEth', swap_args, contract=TestSwapBase.swap_contract.ToString())61 self.dispatched_events = []62 tx, block = self._invoke_tx_on_blockchain(tx, user_wallet)63 swap_event = self.dispatched_events[-1]64 event_results = swap_event.event_payload.Value65 swapId = event_results[4].Value66 self.assertEqual(swapId, '2')67 def test_b_swap_from_eth(self):68 user_wallet = self.GetTokenOwner()69 token = self.nep5_token_from_contract(TestSwapBase.nex_contract)70 current_balance_user = int(token.GetBalance(user_wallet, self.token_owner_addr()))71 amountToSwap = 100072 eth_addr = bytes.fromhex('7FAB4CB3D917719284F9E715A9c6B6FA1fBA217f')73 swap_id = 174 swap_args = [self.token_owner_addr(), eth_addr, Fixed8.FromDecimal(amountToSwap).value, swap_id]75 # should fail, only minter can swap from eth76 tx, results = self.invoke_test(user_wallet, 'swapFromEth', swap_args, contract=TestSwapBase.swap_contract.ToString())77 self.assertFalse(results[0].GetBoolean())78 owner_wallet = self.GetOwner1()79 minter_wallet = self.GetOwner2()80 setMinterArgs = [self.owner2_sh()]81 # Set a minter82 tx, results = self.invoke_test(owner_wallet, 'setMinter', setMinterArgs, contract=TestSwapBase.swap_contract.ToString())83 self.assertTrue(results[0].GetBoolean())84 self._invoke_tx_on_blockchain(tx, owner_wallet)85 # owner shouldn't be able to mint, only minter86 swap_args = [self.token_owner_addr(), eth_addr, Fixed8.FromDecimal(amountToSwap).value, swap_id]87 tx, results = self.invoke_test(owner_wallet, 'swapFromEth', swap_args, contract=TestSwapBase.swap_contract.ToString())88 self.assertFalse(results[0].GetBoolean())89 def test_c_swap_from_eth(self):90 user_wallet = self.GetTokenOwner()91 token = self.nep5_token_from_contract(TestSwapBase.nex_contract)92 current_balance_user = int(token.GetBalance(user_wallet, self.token_owner_addr()))93 amountToSwap = 160094 eth_addr = bytes.fromhex('7FAB4CB3D917719284F9E715A9c6B6FA1fBA217f')95 swap_id = '1'96 swap_args = [self.token_owner_addr(), eth_addr, Fixed8.FromDecimal(amountToSwap).value, swap_id]97 # should fail, only owner can swap from eth98 tx, results = self.invoke_test(user_wallet, 'swapFromEth', swap_args, contract=TestSwapBase.swap_contract.ToString())99 self.assertFalse(results[0].GetBoolean())100 minter_wallet = self.GetOwner2()101 # cant swap back more than has been swapped102 swap_args = [self.token_owner_addr(), eth_addr, Fixed8.FromDecimal(amountToSwap+10000).value, swap_id]103 tx, results = self.invoke_test(minter_wallet, 'swapFromEth', swap_args, contract=TestSwapBase.swap_contract.ToString())104 self.assertEqual(len(results), 0)105 # should be ok106 swap_args = [self.token_owner_addr(), eth_addr, Fixed8.FromDecimal(amountToSwap).value, swap_id]107 tx, results = self.invoke_test(minter_wallet, 'swapFromEth', swap_args, contract=TestSwapBase.swap_contract.ToString())108 self.assertEqual(results[0].GetBoolean(), True)109 self.dispatched_events = []110 tx, block = self._invoke_tx_on_blockchain(tx, minter_wallet)111 # now get the last event dispatched112 swap_event = self.dispatched_events[-1]113 self.assertEqual(swap_event.notify_type, b'onSwapFromEth')114 event_results = swap_event.event_payload.Value115 self.assertEqual(len(event_results), 5)116 amount = event_results[3].Value117 ethAddr = event_results[2].Value118 addr = event_results[1].Value119 swapid = event_results[4].Value120 self.assertEqual(Fixed8.FromDecimal(amountToSwap).value, int.from_bytes(amount, 'little'))121 self.assertEqual(addr, self.token_owner_sh())122 self.assertEqual(ethAddr, eth_addr)123 self.assertEqual(swap_id, swapid)124 tx, results = self.invoke_test(user_wallet, 'totalSwapped', [], contract=TestSwapBase.swap_contract.ToString())125 self.assertEqual(results[0].GetBigInteger(), 0)126 new_balance_user = int(token.GetBalance(user_wallet, self.token_owner_addr()))127 self.assertEqual(new_balance_user, current_balance_user + amountToSwap)128 # Now try with same swap ID, should fail129 swap_args = [self.token_owner_addr(), eth_addr, Fixed8.FromDecimal(amountToSwap).value, swap_id]130 tx, results = self.invoke_test(minter_wallet, 'swapFromEth', swap_args, contract=TestSwapBase.swap_contract.ToString())...

Full Screen

Full Screen

tests.py

Source: tests.py Github

copy

Full Screen

...16 assert(d.X == "Class A atribute X") 17 assert(d.Y == "Class B atribute Y extend class A")18 assert(d.Z == "Class C atribute Z extend class A")19 20def invoke_test(test):21 return {22 "-a" : run_checks_class_A,23 "-b" : run_checks_class_B,24 "-c" : run_checks_class_C,25 "-d" : run_checks_class_D, 26 }[test]()27def run_checks(): 28 args, _ = getopt.getopt(sys.argv[1:], "abcd", [])29 30 if args:31 for o, _ in args: 32 invoke_test(o)33 else: 34 print("Tipo de teste não infomado.")...

Full Screen

Full Screen

test.py

Source: test.py Github

copy

Full Screen

...4if __name__ == "__main__":5 if len(sys.argv) <= 1:6 print("Please specify a test name")7 for test_name in sys.argv[1:]:...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Dec’22 Updates: The All-New LT Browser 2.0, XCUI App Automation with HyperExecute, And More!

Greetings folks! With the new year finally upon us, we’re excited to announce a collection of brand-new product updates. At LambdaTest, we strive to provide you with a comprehensive test orchestration and execution platform to ensure the ultimate web and mobile experience.

How To Find Hidden Elements In Selenium WebDriver With Java

Have you ever struggled with handling hidden elements while automating a web or mobile application? I was recently automating an eCommerce application. I struggled with handling hidden elements on the web page.

What exactly do Scrum Masters perform throughout the course of a typical day

Many theoretical descriptions explain the role of the Scrum Master as a vital member of the Scrum team. However, these descriptions do not provide an honest answer to the fundamental question: “What are the day-to-day activities of a Scrum Master?”

QA&#8217;s and Unit Testing &#8211; Can QA Create Effective Unit Tests

Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.

Quick Guide To Drupal Testing

Dries Buytaert, a graduate student at the University of Antwerp, came up with the idea of developing something similar to a chat room. Moreover, he modified the conventional chat rooms into a website where his friends could post their queries and reply through comments. However, for this project, he thought of creating a temporary archive of posts.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful