How to use get_address method in Slash

Best Python code snippet using slash

test_act.py

Source:test_act.py Github

copy

Full Screen

...43 result = call_score(_score_address, _from, 'totalSupply', {})44 return int(int(result, 16)/10**18)45def call_transaction(_score_address, _fromWallet, _method, _params):46 transaction = CallTransactionBuilder()\47 .from_(_fromWallet.get_address())\48 .to(_score_address)\49 .step_limit(1000000000)\50 .nid(3)\51 .nonce(100)\52 .method(_method)\53 .params(_params)\54 .build()55 signed_transaction = SignedTransaction(transaction, _fromWallet)56 txhash = TestACT.icon_service.send_transaction(signed_transaction)57 #print('txhash = [{}] {}'.format(type(txhash), txhash))58 time.sleep(10)59 txresult = TestACT.icon_service.get_transaction_result(txhash)60 #print('txresult = [{}] {}'.format(type(txresult), txresult))61 return txresult62class TestACT(unittest.TestCase):63 @classmethod64 def setUpClass(cls):65 icon_endpoint = os.environ['ICON_ENDPOINT']66 if icon_endpoint == 'testnet':67 cls.icon_service = IconService(HTTPProvider('https://bicon.net.solidwallet.io/api/v3'))68 cls.act_kard_score_address = 'cx3d85fc30097cb8b18eb52de927b444833c690705'69 cls.act_ace_score_address = 'cxdccbc7ee2d5581e62c8ba300219a5e8d05b58215'70 else:71 cls.icon_service = IconService(HTTPProvider('http://127.0.0.1:9000/api/v3'))72 cls.act_kard_score_address = 'cx3d85fc30097cb8b18eb52de927b444833c690705'73 cls.act_ace_score_address = 'cxdccbc7ee2d5581e62c8ba300219a5e8d05b58215'74 cls.owner_wallet = KeyWallet.load('conf/test_owner.keystore', 'test123!')75 cls.user1_wallet = KeyWallet.load('conf/test_user1.keystore', 'test123!')76 cls.user2_wallet = KeyWallet.load('conf/test_user2.keystore', 'test123!')77 totalSupply = total_supply(cls.act_kard_score_address, cls.owner_wallet.get_address())78 print(f'[KARD]total_supply = {totalSupply}')79 totalSupply = total_supply(cls.act_ace_score_address, cls.owner_wallet.get_address())80 print(f'[A.C.E]total_supply = {totalSupply}')81 owner_balance = balance_of(cls.act_kard_score_address, cls.owner_wallet.get_address(), cls.owner_wallet.get_address())82 print('[KARD]owner_balance = {}'.format(owner_balance))83 user1_balance = balance_of(cls.act_kard_score_address, cls.user1_wallet.get_address(), cls.user1_wallet.get_address())84 print('[KARD]user1_balance = {}'.format(user1_balance))85 user2_balance = balance_of(cls.act_kard_score_address, cls.user2_wallet.get_address(), cls.user2_wallet.get_address())86 print('[KARD]user2_balance = {}'.format(user2_balance))87 owner_balance = balance_of(cls.act_ace_score_address, cls.owner_wallet.get_address(), cls.owner_wallet.get_address())88 print('[A.C.E]owner_balance = {}'.format(owner_balance))89 user1_balance = balance_of(cls.act_ace_score_address, cls.user1_wallet.get_address(), cls.user1_wallet.get_address())90 print('[A.C.E]user1_balance = {}'.format(user1_balance))91 user2_balance = balance_of(cls.act_ace_score_address, cls.user2_wallet.get_address(), cls.user2_wallet.get_address())92 print('[A.C.E]user2_balance = {}'.format(user2_balance))93 def test_name(self):94 result = call_score(self.act_kard_score_address, self.owner_wallet.get_address(), 'name', {})95 print('name = {}'.format(result))96 self.assertEqual(result, 'KARD')97 result = call_score(self.act_ace_score_address, self.owner_wallet.get_address(), 'name', {})98 print('name = {}'.format(result))99 self.assertEqual(result, 'A.C.E')100 def test_symbol(self):101 result = call_score(self.act_kard_score_address, self.owner_wallet.get_address(), 'symbol', {})102 print('symbol = {}'.format(result))103 self.assertEqual(result, 'ACT')104 result = call_score(self.act_ace_score_address, self.owner_wallet.get_address(), 'symbol', {})105 print('symbol = {}'.format(result))106 self.assertEqual(result, 'ACT')107 def test_decimals(self):108 result = call_score(self.act_kard_score_address, self.owner_wallet.get_address(), 'decimals', {})109 print('decimals = {}'.format(int(result, 16)))110 self.assertEqual(int(result, 16), 18)111 result = call_score(self.act_ace_score_address, self.owner_wallet.get_address(), 'decimals', {})112 print('decimals = {}'.format(int(result, 16)))113 self.assertEqual(int(result, 16), 18)114 def test_totalSupply(self):115 self.assertTrue(total_supply(self.act_kard_score_address, self.owner_wallet.get_address()) >= 0)116 self.assertTrue(total_supply(self.act_ace_score_address, self.owner_wallet.get_address()) >= 0)117 def test_balanceOf_kard(self):118 txresult = call_transaction(\119 self.act_kard_score_address,\120 self.owner_wallet,\121 'mint',\122 {'_to': self.owner_wallet.get_address(), '_amount': '0x8ac7230489e80000'}123 )124 print('txresult = [{}] {}'.format(type(txresult), txresult))125 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Transfer(Address,Address,int,bytes)')126 self.assertEqual(txresult['eventLogs'][0]['indexed'][1], self.act_kard_score_address)127 old_owner_balance = balance_of(self.act_kard_score_address, self.owner_wallet.get_address(), self.owner_wallet.get_address())128 old_user1_balance = balance_of(self.act_kard_score_address, self.owner_wallet.get_address(), self.user1_wallet.get_address())129 #print('old_balance = {}'.format(old_balance))130 txresult = call_transaction(\131 self.act_kard_score_address,\132 self.owner_wallet,\133 'transfer',\134 {\135 "_to":self.user1_wallet.get_address(),\136 "_value":"0x8ac7230489e80000"\137 }\138 )139 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Transfer(Address,Address,int,bytes)')140 new_owner_balance = balance_of(self.act_kard_score_address, self.user1_wallet.get_address(), self.owner_wallet.get_address())141 new_user1_balance = balance_of(self.act_kard_score_address, self.user1_wallet.get_address(), self.user1_wallet.get_address())142 #print('new_balance = {}'.format(new_balance))143 self.assertEqual(new_owner_balance, old_owner_balance - 10)144 self.assertEqual(new_user1_balance, old_user1_balance + 10)145 old_user2_balance = balance_of(self.act_kard_score_address, self.owner_wallet.get_address(), self.user2_wallet.get_address())146 old_user1_balance = balance_of(self.act_kard_score_address, self.owner_wallet.get_address(), self.user1_wallet.get_address())147 #print('old_balance = {}'.format(old_balance))148 txresult = call_transaction(\149 self.act_kard_score_address,\150 self.user1_wallet,\151 'transfer',\152 {\153 "_to":self.user2_wallet.get_address(),\154 "_value":"0x8ac7230489e80000"\155 }\156 )157 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Transfer(Address,Address,int,bytes)')158 new_user2_balance = balance_of(self.act_kard_score_address, self.user2_wallet.get_address(), self.user2_wallet.get_address())159 new_user1_balance = balance_of(self.act_kard_score_address, self.user1_wallet.get_address(), self.user1_wallet.get_address())160 #print('new_balance = {}'.format(new_balance))161 self.assertEqual(new_user1_balance, old_user1_balance - 10)162 self.assertEqual(new_user2_balance, old_user2_balance + 10)163 balance = balance_of(\164 self.act_kard_score_address,\165 self.owner_wallet.get_address(),\166 'hx3938461680520062e9fe7e46288d6b74a8682ce5'\167 )168 self.assertEqual(balance, 0)169 def test_balanceOf_ace(self):170 txresult = call_transaction(\171 self.act_ace_score_address,\172 self.owner_wallet,\173 'mint',\174 {'_to': self.owner_wallet.get_address(), '_amount': '0x8ac7230489e80000'}175 )176 print('txresult = [{}] {}'.format(type(txresult), txresult))177 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Transfer(Address,Address,int,bytes)')178 self.assertEqual(txresult['eventLogs'][0]['indexed'][1], self.act_ace_score_address)179 old_owner_balance = balance_of(self.act_ace_score_address, self.owner_wallet.get_address(), self.owner_wallet.get_address())180 old_user1_balance = balance_of(self.act_ace_score_address, self.owner_wallet.get_address(), self.user1_wallet.get_address())181 #print('old_balance = {}'.format(old_balance))182 txresult = call_transaction(\183 self.act_ace_score_address,\184 self.owner_wallet,\185 'transfer',\186 {\187 "_to":self.user1_wallet.get_address(),\188 "_value":"0x8ac7230489e80000"\189 }\190 )191 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Transfer(Address,Address,int,bytes)')192 new_owner_balance = balance_of(self.act_ace_score_address, self.user1_wallet.get_address(), self.owner_wallet.get_address())193 new_user1_balance = balance_of(self.act_ace_score_address, self.user1_wallet.get_address(), self.user1_wallet.get_address())194 #print('new_balance = {}'.format(new_balance))195 self.assertEqual(new_owner_balance, old_owner_balance - 10)196 self.assertEqual(new_user1_balance, old_user1_balance + 10)197 old_user2_balance = balance_of(self.act_ace_score_address, self.owner_wallet.get_address(), self.user2_wallet.get_address())198 old_user1_balance = balance_of(self.act_ace_score_address, self.owner_wallet.get_address(), self.user1_wallet.get_address())199 #print('old_balance = {}'.format(old_balance))200 txresult = call_transaction(\201 self.act_ace_score_address,\202 self.user1_wallet,\203 'transfer',\204 {\205 "_to":self.user2_wallet.get_address(),\206 "_value":"0x8ac7230489e80000"\207 }\208 )209 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Transfer(Address,Address,int,bytes)')210 new_user2_balance = balance_of(self.act_ace_score_address, self.user2_wallet.get_address(), self.user2_wallet.get_address())211 new_user1_balance = balance_of(self.act_ace_score_address, self.user1_wallet.get_address(), self.user1_wallet.get_address())212 #print('new_balance = {}'.format(new_balance))213 self.assertEqual(new_user1_balance, old_user1_balance - 10)214 self.assertEqual(new_user2_balance, old_user2_balance + 10)215 balance = balance_of(\216 self.act_ace_score_address,\217 self.owner_wallet.get_address(),\218 'hx3938461680520062e9fe7e46288d6b74a8682ce5'\219 )220 self.assertEqual(balance, 0)221 def test_paused(self):222 result = call_score(self.act_kard_score_address, self.owner_wallet.get_address(), 'paused', {})223 print(f'paused = {result}')224 self.assertEqual(result, '0x0')225 result = call_score(self.act_ace_score_address, self.owner_wallet.get_address(), 'paused', {})226 print(f'paused = {result}')227 self.assertEqual(result, '0x0')228 def test_pause_kard(self):229 txresult = call_transaction(\230 self.act_kard_score_address,\231 self.owner_wallet,\232 'pause',\233 {}234 )235 print('txresult = [{}] {}'.format(type(txresult), txresult))236 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Paused()')237 result = call_score(self.act_kard_score_address, self.owner_wallet.get_address(), 'paused', {})238 print(f'paused = {result}')239 self.assertEqual(result, '0x1')240 txresult = call_transaction(\241 self.act_kard_score_address,\242 self.owner_wallet,\243 'unpause',\244 {}245 )246 print('txresult = [{}] {}'.format(type(txresult), txresult))247 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Unpaused()')248 result = call_score(self.act_kard_score_address, self.owner_wallet.get_address(), 'paused', {})249 print(f'paused = {result}')250 self.assertEqual(result, '0x0')251 txresult = call_transaction(\252 self.act_kard_score_address,\253 self.user1_wallet,\254 'pause',\255 {}256 )257 print('txresult = [{}] {}'.format(type(txresult), txresult))258 self.assertEqual(txresult['failure']['message'], 'Only the owner is allowed')259 def test_pause_ace(self):260 txresult = call_transaction(\261 self.act_ace_score_address,\262 self.owner_wallet,\263 'pause',\264 {}265 )266 print('txresult = [{}] {}'.format(type(txresult), txresult))267 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Paused()')268 result = call_score(self.act_ace_score_address, self.owner_wallet.get_address(), 'paused', {})269 print(f'paused = {result}')270 self.assertEqual(result, '0x1')271 txresult = call_transaction(\272 self.act_ace_score_address,\273 self.owner_wallet,\274 'unpause',\275 {}276 )277 print('txresult = [{}] {}'.format(type(txresult), txresult))278 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Unpaused()')279 result = call_score(self.act_ace_score_address, self.owner_wallet.get_address(), 'paused', {})280 print(f'paused = {result}')281 self.assertEqual(result, '0x0')282 txresult = call_transaction(\283 self.act_ace_score_address,\284 self.user1_wallet,\285 'pause',\286 {}287 )288 print('txresult = [{}] {}'.format(type(txresult), txresult))289 self.assertEqual(txresult['failure']['message'], 'Only the owner is allowed')290 def test_unpause_kard(self):291 txresult = call_transaction(\292 self.act_kard_score_address,\293 self.owner_wallet,\294 'pause',\295 {}296 )297 print('txresult = [{}] {}'.format(type(txresult), txresult))298 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Paused()')299 txresult = call_transaction(\300 self.act_kard_score_address,\301 self.user1_wallet,\302 'unpause',\303 {}304 )305 print('txresult = [{}] {}'.format(type(txresult), txresult))306 self.assertEqual(txresult['failure']['message'], 'Only the owner is allowed')307 result = call_score(self.act_kard_score_address, self.owner_wallet.get_address(), 'paused', {})308 print(f'paused = {result}')309 self.assertEqual(result, '0x1')310 txresult = call_transaction(\311 self.act_kard_score_address,\312 self.owner_wallet,\313 'unpause',\314 {}315 )316 print('txresult = [{}] {}'.format(type(txresult), txresult))317 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Unpaused()')318 result = call_score(self.act_kard_score_address, self.owner_wallet.get_address(), 'paused', {})319 print(f'paused = {result}')320 self.assertEqual(result, '0x0')321 def test_unpause_ace(self):322 txresult = call_transaction(\323 self.act_ace_score_address,\324 self.owner_wallet,\325 'pause',\326 {}327 )328 print('txresult = [{}] {}'.format(type(txresult), txresult))329 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Paused()')330 txresult = call_transaction(\331 self.act_ace_score_address,\332 self.user1_wallet,\333 'unpause',\334 {}335 )336 print('txresult = [{}] {}'.format(type(txresult), txresult))337 self.assertEqual(txresult['failure']['message'], 'Only the owner is allowed')338 result = call_score(self.act_ace_score_address, self.owner_wallet.get_address(), 'paused', {})339 print(f'paused = {result}')340 self.assertEqual(result, '0x1')341 txresult = call_transaction(\342 self.act_ace_score_address,\343 self.owner_wallet,\344 'unpause',\345 {}346 )347 print('txresult = [{}] {}'.format(type(txresult), txresult))348 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Unpaused()')349 result = call_score(self.act_ace_score_address, self.owner_wallet.get_address(), 'paused', {})350 print(f'paused = {result}')351 self.assertEqual(result, '0x0')352 def test_mint_kard(self):353 old_totalSupply = total_supply(self.act_kard_score_address, self.owner_wallet.get_address())354 old_user1_balance = balance_of(self.act_kard_score_address, self.owner_wallet.get_address(), self.user1_wallet.get_address())355 txresult = call_transaction(\356 self.act_kard_score_address,\357 self.owner_wallet,\358 'mint',\359 {'_to': self.user1_wallet.get_address(), '_amount': '0x8ac7230489e80000'}360 )361 print('txresult = [{}] {}'.format(type(txresult), txresult))362 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Transfer(Address,Address,int,bytes)')363 self.assertEqual(txresult['eventLogs'][0]['indexed'][1], self.act_kard_score_address)364 new_totalSupply = total_supply(self.act_kard_score_address, self.owner_wallet.get_address())365 new_user1_balance = balance_of(self.act_kard_score_address, self.owner_wallet.get_address(), self.user1_wallet.get_address())366 self.assertEqual(new_totalSupply - old_totalSupply, 10)367 self.assertEqual(new_user1_balance - old_user1_balance, 10)368 txresult = call_transaction(\369 self.act_kard_score_address,\370 self.user1_wallet,\371 'mint',\372 {'_to': self.user1_wallet.get_address(), '_amount': '0x8ac7230489e80000'}373 )374 print('txresult = [{}] {}'.format(type(txresult), txresult))375 self.assertEqual(txresult['failure']['message'], 'Only the owner is allowed')376 def test_mint_ace(self):377 old_totalSupply = total_supply(self.act_ace_score_address, self.owner_wallet.get_address())378 old_user1_balance = balance_of(self.act_ace_score_address, self.owner_wallet.get_address(), self.user1_wallet.get_address())379 txresult = call_transaction(\380 self.act_ace_score_address,\381 self.owner_wallet,\382 'mint',\383 {'_to': self.user1_wallet.get_address(), '_amount': '0x8ac7230489e80000'}384 )385 print('txresult = [{}] {}'.format(type(txresult), txresult))386 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Transfer(Address,Address,int,bytes)')387 self.assertEqual(txresult['eventLogs'][0]['indexed'][1], self.act_ace_score_address)388 new_totalSupply = total_supply(self.act_ace_score_address, self.owner_wallet.get_address())389 new_user1_balance = balance_of(self.act_ace_score_address, self.owner_wallet.get_address(), self.user1_wallet.get_address())390 self.assertEqual(new_totalSupply - old_totalSupply, 10)391 self.assertEqual(new_user1_balance - old_user1_balance, 10)392 txresult = call_transaction(\393 self.act_ace_score_address,\394 self.user1_wallet,\395 'mint',\396 {'_to': self.user1_wallet.get_address(), '_amount': '0x8ac7230489e80000'}397 )398 print('txresult = [{}] {}'.format(type(txresult), txresult))399 self.assertEqual(txresult['failure']['message'], 'Only the owner is allowed')400 def test_burn_kard(self):401 txresult = call_transaction(\402 self.act_kard_score_address,\403 self.owner_wallet,\404 'mint',\405 {'_to': self.owner_wallet.get_address(), '_amount': '0x8ac7230489e80000'}406 )407 print('txresult = [{}] {}'.format(type(txresult), txresult))408 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Transfer(Address,Address,int,bytes)')409 self.assertEqual(txresult['eventLogs'][0]['indexed'][1], self.act_kard_score_address)410 old_totalSupply = total_supply(self.act_kard_score_address, self.owner_wallet.get_address())411 #print('old_totalSupply = {}'.format(old_totalSupply))412 txresult = call_transaction(\413 self.act_kard_score_address,\414 self.owner_wallet,\415 'burn',\416 {'_amount': '0x8ac7230489e80000'}417 )418 print('txresult = [{}] {}'.format(type(txresult), txresult))419 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Transfer(Address,Address,int,bytes)')420 self.assertEqual(txresult['eventLogs'][0]['indexed'][2], self.act_kard_score_address)421 new_totalSupply = total_supply(self.act_kard_score_address, self.owner_wallet.get_address())422 #print('new_totalSupply = {}'.format(new_totalSupply))423 self.assertEqual(int(old_totalSupply - new_totalSupply), 10)424 def test_burn_ace(self):425 txresult = call_transaction(\426 self.act_ace_score_address,\427 self.owner_wallet,\428 'mint',\429 {'_to': self.owner_wallet.get_address(), '_amount': '0x8ac7230489e80000'}430 )431 print('txresult = [{}] {}'.format(type(txresult), txresult))432 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Transfer(Address,Address,int,bytes)')433 self.assertEqual(txresult['eventLogs'][0]['indexed'][1], self.act_ace_score_address)434 old_totalSupply = total_supply(self.act_ace_score_address, self.owner_wallet.get_address())435 #print('old_totalSupply = {}'.format(old_totalSupply))436 txresult = call_transaction(\437 self.act_ace_score_address,\438 self.owner_wallet,\439 'burn',\440 {'_amount': '0x8ac7230489e80000'}441 )442 print('txresult = [{}] {}'.format(type(txresult), txresult))443 self.assertEqual(txresult['eventLogs'][0]['indexed'][0], 'Transfer(Address,Address,int,bytes)')444 self.assertEqual(txresult['eventLogs'][0]['indexed'][2], self.act_ace_score_address)445 new_totalSupply = total_supply(self.act_ace_score_address, self.owner_wallet.get_address())446 #print('new_totalSupply = {}'.format(new_totalSupply))447 self.assertEqual(int(old_totalSupply - new_totalSupply), 10)448if __name__ == '__main__':...

Full Screen

Full Screen

wallet_class.py

Source:wallet_class.py Github

copy

Full Screen

...37 a44_0_t = "mjGeJZyBj9sMFwysn69xYSt73W2Qb9hfwo"38 a44_19_t = "mgzT18jNAyzpYYGeVsh8Mctx4aRT7rMkSL"39 a44_19_i_t = "mo7LhsYk8bXMS3tM2dJTa364QAwv25Xxo4"40 w = Wallet(m, path_type="BIP44", testnet=True)41 self.assertEqual(w.get_address(0)["address"], a44_0_t)42 self.assertEqual(w.get_address(19)["address"], a44_19_t)43 self.assertEqual(w.get_address(19, chain="internal")["address"], a44_19_i_t)44 w = Wallet(m, path_type="BIP44")45 self.assertEqual(w.testnet, False)46 self.assertEqual(w.account_public_xkey, xpub44)47 self.assertEqual(w.account_private_xkey, xpriv44)48 self.assertEqual(w.get_address(0)["address"], a44_0)49 self.assertEqual(w.get_address(1)["address"], a44_1)50 self.assertEqual(w.get_address(2)["address"], a44_2)51 self.assertEqual(w.get_address(3)["address"], a44_3)52 self.assertEqual(w.get_address(19)["address"], a44_19)53 self.assertEqual(w.get_address(0)["private_key"], p44_0)54 self.assertEqual(w.get_address(1)["private_key"], p44_1)55 self.assertEqual(w.get_address(2)["private_key"], p44_2)56 self.assertEqual(w.get_address(3)["private_key"], p44_3)57 self.assertEqual(w.get_address(19)["private_key"], p44_19)58 self.assertEqual(w.get_address(19, chain="internal")["private_key"], p_44_19_i)59 w2 = Wallet(xpub44)60 self.assertEqual(w2.testnet, False)61 self.assertEqual(w2.account_public_xkey, xpub44)62 self.assertEqual(w2.account_private_xkey, None)63 self.assertEqual(w2.get_address(0)["address"], a44_0)64 self.assertEqual(w2.get_address(1)["address"], a44_1)65 self.assertEqual(w2.get_address(2)["address"], a44_2)66 self.assertEqual(w2.get_address(3)["address"], a44_3)67 self.assertEqual(w2.get_address(19)["address"], a44_19)68 self.assertEqual(w2.get_address(19, chain="internal")["address"], a44_19_i)69 wt = Wallet(xpriv44t)70 self.assertEqual(wt.testnet, True)71 self.assertEqual(wt.get_address(0)["address"], a44_0_t)72 self.assertEqual(wt.get_address(19)["address"], a44_19_t)73 self.assertEqual(wt.get_address(19, chain="internal")["address"], a44_19_i_t)74 w3 = Wallet(xpriv44, path_type="BIP44")75 self.assertEqual(w3.testnet, False)76 self.assertEqual(w3.account_public_xkey, xpub44)77 self.assertEqual(w3.account_private_xkey, xpriv44)78 self.assertEqual(w3.get_address(0)["address"], a44_0)79 self.assertEqual(w3.get_address(1)["address"], a44_1)80 self.assertEqual(w3.get_address(2)["address"], a44_2)81 self.assertEqual(w3.get_address(3)["address"], a44_3)82 self.assertEqual(w3.get_address(19)["address"], a44_19)83 self.assertEqual(w3.get_address(0)["private_key"], p44_0)84 self.assertEqual(w3.get_address(1)["private_key"], p44_1)85 self.assertEqual(w3.get_address(2)["private_key"], p44_2)86 self.assertEqual(w3.get_address(3)["private_key"], p44_3)87 self.assertEqual(w3.get_address(19)["private_key"], p44_19)88 self.assertEqual(w3.get_address(19, chain="internal")["private_key"], p_44_19_i)89 w3 = Wallet(xpriv44)90 self.assertEqual(w3.testnet, False)91 self.assertEqual(w3.account_public_xkey, xpub44)92 self.assertEqual(w3.account_private_xkey, xpriv44)93 self.assertEqual(w3.get_address(0)["address"], a44_0)94 self.assertEqual(w3.get_address(1)["address"], a44_1)95 self.assertEqual(w3.get_address(2)["address"], a44_2)96 self.assertEqual(w3.get_address(3)["address"], a44_3)97 self.assertEqual(w3.get_address(19)["address"], a44_19)98 self.assertEqual(w3.get_address(0)["private_key"], p44_0)99 self.assertEqual(w3.get_address(1)["private_key"], p44_1)100 self.assertEqual(w3.get_address(2)["private_key"], p44_2)101 self.assertEqual(w3.get_address(3)["private_key"], p44_3)102 self.assertEqual(w3.get_address(19)["private_key"], p44_19)103 self.assertEqual(w3.get_address(19, chain="internal")["private_key"], p_44_19_i)104 w3 = Wallet(xpriv44root)105 self.assertEqual(w3.testnet, False)106 self.assertEqual(w3.account_public_xkey, xpub44)107 self.assertEqual(w3.account_private_xkey, xpriv44)108 self.assertEqual(w3.get_address(0)["address"], a44_0)109 self.assertEqual(w3.get_address(1)["address"], a44_1)110 self.assertEqual(w3.get_address(2)["address"], a44_2)111 self.assertEqual(w3.get_address(3)["address"], a44_3)112 self.assertEqual(w3.get_address(19)["address"], a44_19)113 self.assertEqual(w3.get_address(0)["private_key"], p44_0)114 self.assertEqual(w3.get_address(1)["private_key"], p44_1)115 self.assertEqual(w3.get_address(2)["private_key"], p44_2)116 self.assertEqual(w3.get_address(3)["private_key"], p44_3)117 self.assertEqual(w3.get_address(19)["private_key"], p44_19)118 self.assertEqual(w3.get_address(19, chain="internal")["private_key"], p_44_19_i)119 xpub49 = "ypub6Wxm6Wp2UwckK3bv1DRcuEzxbnaSqT9MVV3tFZGhZYRgNdBPoiBcPwA8TDX9EoDfkztSgqeX" \120 "fJPSk3PQMt4inLH4hzsjbob81kmy8oQFHkx"121 xpriv49 = "yprvAHyQh1H8ea4T6ZXSuBtcY74E3kjxRzRW8G8HTAs61CthVprFGAsMr8qebvGZM9G99qXVtocg" \122 "LtZjRZC4iS9L1ovJ8TEfLVs8nN5ahZJpkGm"123 xpriv49root = "yprvABrGsX5C9jansfXo7ZUYnQQGS29hy7nQetPHCooQkVjXmCa9E9qwhSRS48FB8dchgu8Jv" \124 "bZMJWmh5XyTZPKfdL6MY3tTFfXikhNK4iprszc"125 a49_0 = "3KDC6ugKwrxGLsTKfEoQY79GooVGtyCj6p"126 a49_1 = "3CqYvv5NShfJihWpp3mvikzJAq2DrDrywR"127 a49_2 = "3LcotDRszCGkgCBiUYxUZ1tZeWTQ7AgV6N"128 a49_3 = "35GTWtRp9Xypn6UFECrwBF5qa8vsbLeanb"129 a49_19 = "3MWHqhd7tcY2MUucd4xbTZBNJS8DTTteuq"130 a49_19_i = "3AHmLTefeW12yp4CiRPK2Q1mEUwMzYQWLH"131 p49_0 = "KyjKJyyJPgqCyxqMjkBLFg6KboQvsChE82KkuuYZQVFGjQAPN4v2"132 p49_1 = "KxJLTnrsNkgFYYeA1R5GCpfxnaLVbeSPYjiVWnJkjz4anTaCXdti"133 p49_2 = "L36ZqLCpWv9mcX3eG7q59mfe5yhjfP1GoSWtBMU6GDyHNnJ2CqkE"134 p49_3 = "KxVArb2SPBJKXftppVg8JUS6zdf5EMBRJ87KZKv1HDf5wDF8t3kv"135 p49_19 = "KwV6ztbWQHxkUhrpmqVuV9xgqahx4jHxHwfUeNx1HQhjQXSQAhq2"136 p_49_19_i = "L3PDN7Hs2CtBG78f2BkvXA6B2zRn9dfPf9S1KXN2tAEVfY9LdpqY"137 w = Wallet(m, path_type="BIP49")138 self.assertEqual(w.testnet, False)139 self.assertEqual(w.account_public_xkey, xpub49)140 self.assertEqual(w.account_private_xkey, xpriv49)141 self.assertEqual(w.get_address(0)["address"], a49_0)142 self.assertEqual(w.get_address(1)["address"], a49_1)143 self.assertEqual(w.get_address(2)["address"], a49_2)144 self.assertEqual(w.get_address(3)["address"], a49_3)145 self.assertEqual(w.get_address(19)["address"], a49_19)146 self.assertEqual(w.get_address(0)["private_key"], p49_0)147 self.assertEqual(w.get_address(1)["private_key"], p49_1)148 self.assertEqual(w.get_address(2)["private_key"], p49_2)149 self.assertEqual(w.get_address(3)["private_key"], p49_3)150 self.assertEqual(w.get_address(19)["private_key"], p49_19)151 self.assertEqual(w.get_address(19, chain="internal")["private_key"], p_49_19_i)152 w2 = Wallet(xpub49)153 self.assertEqual(w2.testnet, False)154 self.assertEqual(w2.account_public_xkey, xpub49)155 self.assertEqual(w2.account_private_xkey, None)156 self.assertEqual(w2.get_address(0)["address"], a49_0)157 self.assertEqual(w2.get_address(1)["address"], a49_1)158 self.assertEqual(w2.get_address(2)["address"], a49_2)159 self.assertEqual(w2.get_address(3)["address"], a49_3)160 self.assertEqual(w2.get_address(19)["address"], a49_19)161 self.assertEqual(w2.get_address(19, chain="internal")["address"], a49_19_i)162 w3 = Wallet(xpriv49)163 self.assertEqual(w3.testnet, False)164 self.assertEqual(w3.account_public_xkey, xpub49)165 self.assertEqual(w3.account_private_xkey, xpriv49)166 self.assertEqual(w3.get_address(0)["address"], a49_0)167 self.assertEqual(w3.get_address(1)["address"], a49_1)168 self.assertEqual(w3.get_address(2)["address"], a49_2)169 self.assertEqual(w3.get_address(3)["address"], a49_3)170 self.assertEqual(w3.get_address(19)["address"], a49_19)171 self.assertEqual(w3.get_address(0)["private_key"], p49_0)172 self.assertEqual(w3.get_address(1)["private_key"], p49_1)173 self.assertEqual(w3.get_address(2)["private_key"], p49_2)174 self.assertEqual(w3.get_address(3)["private_key"], p49_3)175 self.assertEqual(w3.get_address(19)["private_key"], p49_19)176 self.assertEqual(w3.get_address(19, chain="internal")["private_key"], p_49_19_i)177 w3 = Wallet(xpriv49root)178 self.assertEqual(w3.testnet, False)179 self.assertEqual(w3.account_public_xkey, xpub49)180 self.assertEqual(w3.account_private_xkey, xpriv49)181 self.assertEqual(w3.get_address(0)["address"], a49_0)182 self.assertEqual(w3.get_address(1)["address"], a49_1)183 self.assertEqual(w3.get_address(2)["address"], a49_2)184 self.assertEqual(w3.get_address(3)["address"], a49_3)185 self.assertEqual(w3.get_address(19)["address"], a49_19)186 self.assertEqual(w3.get_address(0)["private_key"], p49_0)187 self.assertEqual(w3.get_address(1)["private_key"], p49_1)188 self.assertEqual(w3.get_address(2)["private_key"], p49_2)189 self.assertEqual(w3.get_address(3)["private_key"], p49_3)190 self.assertEqual(w3.get_address(19)["private_key"], p49_19)191 self.assertEqual(w3.get_address(19, chain="internal")["private_key"], p_49_19_i)192 xpub84 = "zpub6rhSjy3XXQKAh6aBPXKMPa56gsSmPFb8rKh94uZa4fgncTLXsdRWq3Ur9BAoFSa8BXJ79ST5Hz" \193 "Krxx8M3jBYsTnsE9E3CcpQ8vhKAP684ta"194 xpriv84 = "zprvAdi6LTWdh2ksUcViHVnM2S8N8qcGynsHV6mYGX9xWL9ojf1PL67GHFANHvoLm4J41hGT8QGR" \195 "vDNUeEnNw16Xh9ZpYvvatwmaTCjMnRnuKp7"196 xpriv84root = "zprvAWgYBBk7JR8GixiuwvGAzVVmbzJ9ujmuZzuVzChJ8W7QpJPNUp1WKW5a5LCm8YGd6YF7g5" \197 "9umB8Expb2H5jgRZmxQPasqaMD2RRxTDiBj3B"198 a84_0 = "bc1qktswv5qw0af9hzc87ql6vhgdh5m3kmpz9py3uh"199 a84_1 = "bc1qwffx8huf8wwwpt6u0vh3z4sst5p9jpmvf8jkpf"200 a84_2 = "bc1q3e6gfa4lvrl5p74ug5hkjukvq2gn22l08h2ng0"201 a84_3 = "bc1q8wljecft5hkv2u9hql0244v3gee504pvat7w4m"202 a84_19 = "bc1qha4un56xlhvyxld365jhqqdrg7dfnf86py66fx"203 a84_19_i = "bc1q0ll86xmwvk6uy9e3x9qn92dyfn9mwdepjmva8p"204 p84_0 = "Kx1cq5txr9q1ohyzWkA4LUgZvjqbokpd7UBoGvnWwwveGfP6p4YJ"205 p84_1 = "KztQibwvHLfZHz2wBcX6AiLmAyCvfFJxfsAKFSMgpuvHEsG22r8z"206 p84_2 = "L4y7iw2kUu5PdoqSRZ8wX7oVNnMkZquZRVnKb2KLjGpVvrgMJ4cB"207 p84_3 = "L3n2KAM1DaM9uMY2AKLsyqe8TFTHm6gYjzWjVjCS42ocPwpbApfK"208 p84_19 = "L21r2kT3GxpK7kRBWZ5EFVrRYEzvSLWpxnLEC4drWbBjNrDAR69Y"209 p_84_19_i = "Kx1wszVqpRytaaH2rXwntBr39vLSNPeW8jhqiBmAf6gAvbQbHQcy"210 w = Wallet(m, path_type="BIP84")211 self.assertEqual(w.testnet, False)212 self.assertEqual(w.account_public_xkey, xpub84)213 self.assertEqual(w.account_private_xkey, xpriv84)214 self.assertEqual(w.get_address(0)["address"], a84_0)215 self.assertEqual(w.get_address(1)["address"], a84_1)216 self.assertEqual(w.get_address(2)["address"], a84_2)217 self.assertEqual(w.get_address(3)["address"], a84_3)218 self.assertEqual(w.get_address(19)["address"], a84_19)219 self.assertEqual(w.get_address(0)["private_key"], p84_0)220 self.assertEqual(w.get_address(1)["private_key"], p84_1)221 self.assertEqual(w.get_address(2)["private_key"], p84_2)222 self.assertEqual(w.get_address(3)["private_key"], p84_3)223 self.assertEqual(w.get_address(19)["private_key"], p84_19)224 self.assertEqual(w.get_address(19, chain="internal")["private_key"], p_84_19_i)225 w2 = Wallet(xpub84)226 self.assertEqual(w2.testnet, False)227 self.assertEqual(w2.account_public_xkey, xpub84)228 self.assertEqual(w2.account_private_xkey, None)229 self.assertEqual(w2.get_address(0)["address"], a84_0)230 self.assertEqual(w2.get_address(1)["address"], a84_1)231 self.assertEqual(w2.get_address(2)["address"], a84_2)232 self.assertEqual(w2.get_address(3)["address"], a84_3)233 self.assertEqual(w2.get_address(19)["address"], a84_19)234 self.assertEqual(w2.get_address(19, chain="internal")["address"], a84_19_i)235 w3 = Wallet(xpriv84)236 self.assertEqual(w3.testnet, False)237 self.assertEqual(w3.account_public_xkey, xpub84)238 self.assertEqual(w3.account_private_xkey, xpriv84)239 self.assertEqual(w3.get_address(0)["address"], a84_0)240 self.assertEqual(w3.get_address(1)["address"], a84_1)241 self.assertEqual(w3.get_address(2)["address"], a84_2)242 self.assertEqual(w3.get_address(3)["address"], a84_3)243 self.assertEqual(w3.get_address(19)["address"], a84_19)244 self.assertEqual(w3.get_address(0)["private_key"], p84_0)245 self.assertEqual(w3.get_address(1)["private_key"], p84_1)246 self.assertEqual(w3.get_address(2)["private_key"], p84_2)247 self.assertEqual(w3.get_address(3)["private_key"], p84_3)248 self.assertEqual(w3.get_address(19)["private_key"], p84_19)249 self.assertEqual(w3.get_address(19, chain="internal")["private_key"], p_84_19_i)250 w3 = Wallet(xpriv84root)251 self.assertEqual(w3.testnet, False)252 self.assertEqual(w3.account_public_xkey, xpub84)253 self.assertEqual(w3.account_private_xkey, xpriv84)254 self.assertEqual(w3.get_address(0)["address"], a84_0)255 self.assertEqual(w3.get_address(1)["address"], a84_1)256 self.assertEqual(w3.get_address(2)["address"], a84_2)257 self.assertEqual(w3.get_address(3)["address"], a84_3)258 self.assertEqual(w3.get_address(19)["address"], a84_19)259 self.assertEqual(w3.get_address(0)["private_key"], p84_0)260 self.assertEqual(w3.get_address(1)["private_key"], p84_1)261 self.assertEqual(w3.get_address(2)["private_key"], p84_2)262 self.assertEqual(w3.get_address(3)["private_key"], p84_3)263 self.assertEqual(w3.get_address(19)["private_key"], p84_19)...

Full Screen

Full Screen

IMT2019083_ias.py

Source:IMT2019083_ias.py Github

copy

Full Screen

...33 while not self.halt:34 35 if (self.ibr.get() == ""): 36 37 self.mar.set_address(self.pc.get_address()) 38 self.mbr.set(self.memory.get(self.mar.get_address())) 39 self.ibr.set(self.mbr.get()[20:]) 40 self.ir.set(self.mbr.get()[0:8]) 41 self.mar.set_address(self.mbr.get()[8:20]) 42 self.pc.set_address(dec_to_unsign(unsign_to_dec(self.pc.get_address()) + 1)) 43 44 else:45 46 self.ir.set(self.ibr.get()[0:8]) 47 self.mar.set_address(self.ibr.get()[8:20]) 48 self.ibr.set("") 49 self.Execute()50 51 def Execute(self):52 53 54 mapping = {"00001010":self.LOAD_MQ, "00001001":self.LOAD_MQ_MX,"00100001":self.STOR_MX, "00000001":self.LOAD_MX, "00000010":self.LOAD_negMX,55 "00000011":self.LOAD_MODMX, "00000100":self.LOAD_NEGMODMX, "00001101":self.JUMP_MX_LEFT,"00001110":self.JUMP_MX_RIGHT,"00001111":self.JUMP_posMX_LEFT,56 "00010000":self.JUMP_posMX_RIGHT,"00000101":self.ADD_MX,"00000111":self.ADD_MODMX,"00000110":self.SUB_MX,"00001000":self.SUB_MODMX,"00001100":self.DIV_MX,57 "00010100":self.LSH, "00010101":self.RSH, "11111111":self.HALT}58 mapping[self.ir.get()]()59 60 def LOAD_MQ(self): 61 self.ac.set(self.mq.get()) 62 def LOAD_MQ_MX(self):63 64 self.mq.set(self.memory.get(self.mar.get_address()))65 def STOR_MX(self): 66 67 self.memory.set(self.mar.get_address(), self.ac.get())68 def LOAD_MX(self):69 self.ac.set(self.memory.get(self.mar.get_address())) 70 def LOAD_negMX(self):71 72 self.ac.set(dec_to_sign(-sign_to_dec(self.memory.get(self.mar.get_address())))) 73 def LOAD_MODMX(self):74 75 self.ac.set(dec_to_sign(abs(sign_to_dec(self.memory.get(self.mar.get_address()))))) 76 def LOAD_NEGMODMX(self):77 78 self.ac.set(dec_to_sign(-abs(sign_to_dec(self.memory.get(self.mar.get_address()))))) 79 def JUMP_MX_LEFT(self):80 81 self.ibr.set("") 82 self.pc.set_address(self.mar.get_address()) 83 84 def JUMP_MX_RIGHT(self):85 86 self.ibr.set(self.memory.get(self.mar.get_address())[20:40]) 87 self.pc.set_address(dec_to_sign(unsign_to_dec(self.mar.get_address()) + 1)) 88 89 def JUMP_posMX_LEFT(self):90 91 if (sign_to_dec(self.ac.get()) > 0):92 93 self.ibr.set("")94 self.pc.set_address(self.mar.get_address())95 def JUMP_posMX_RIGHT(self):96 97 if (sign_to_dec(self.ac.get()) > 0):98 99 self.ibr.set(self.memory.get(self.mar.get_address())[20:40]) 100 self.pc.set_address(dec_to_sign(unsign_to_dec(self.mar.get_address()) + 1)) 101 102 def ADD_MX(self):103 104 self.ac.set(dec_to_sign(sign_to_dec(self.ac.get()) + sign_to_dec(self.memory.get(self.mar.get_address()))))105 def ADD_MODMX(self):106 107 if (sign_to_dec(self.memory.get(self.mar.get_address())) > 0):108 self.ac.set(dec_to_sign(sign_to_dec(self.ac.get()) + sign_to_dec(self.memory.get(self.mar.get_address()))))109 else:110 self.ac.set(dec_to_sign(sign_to_dec(self.ac.get()) - sign_to_dec(self.memory.get(self.mar.get_address()))))111 def SUB_MX(self): 112 113 self.ac.set(dec_to_sign(sign_to_dec(self.ac.get()) - sign_to_dec(self.memory.get(self.mar.get_address()))))114 def SUB_MODMX(self):115 116 if (sign_to_dec(self.memory.get(self.mar.get_address())) > 0):117 self.ac.set(dec_to_sign(sign_to_dec(self.ac.get()) - sign_to_dec(self.memory.get(self.mar.get_address()))))118 else:119 self.ac.set(dec_to_sign(sign_to_dec(self.ac.get()) + sign_to_dec(self.memory.get(self.mar.get_address()))))120 def DIV_MX(self):121 self.mq.set(dec_to_sign(int(sign_to_dec(self.ac.get()) / sign_to_dec(self.memory.get(self.mar.get_address())))))122 self.ac.set(dec_to_sign(sign_to_dec(self.ac.get()) % sign_to_dec(self.memory.get(self.mar.get_address()))))123 def LSH(self):124 125 self.ac.set(dec_to_sign(sign_to_dec(self.ac.get()) << 1))126 def RSH(self):127 self.ac.set(dec_to_sign(sign_to_dec(self.ac.get()) >> 1))128 129 def HALT(self):130 self.halt = True ...

Full Screen

Full Screen

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 Slash 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