@@ -39,39 +39,6 @@ def get_path_to_pythdir_pair(account_addr):
3939 return os .path .join (pyth_dir , "account_" + str (account_addr ) + ".json" )
4040
4141
42-
43- def resize_account (price_account_address ):
44- """
45- given a string with the pubkey of a price account it calls the resize instruction of the Oracle on it
46- """
47- #constants from oracle.h
48- PROGRAM_VERSION = 2 #TODO: update this
49- COMMAND_UPD_ACCOUNT = 14
50- SYSTEM_PROGRAM = "11111111111111111111111111111111"
51-
52- #update version of price accounts to make sure they resize
53- layout = Struct ("version" / Int32ul , "command" / Int32sl )
54- data = layout .build (dict (version = PROGRAM_VERSION , command = COMMAND_UPD_ACCOUNT ))
55- funding_key = PublicKey (solana_keygen [0 ])
56- price_key = PublicKey (price_account_address )
57- system_key = PublicKey (SYSTEM_PROGRAM )
58- resize_instruction = TransactionInstruction (
59- data = data ,
60- keys = [
61- AccountMeta (pubkey = funding_key , is_signer = True , is_writable = True ),
62- AccountMeta (pubkey = price_key , is_signer = True , is_writable = True ),
63- AccountMeta (pubkey = system_key , is_signer = False , is_writable = False ),
64- ],
65- program_id = PublicKey (solana_program_deploy ),
66- )
67- txn = Transaction ().add (resize_instruction )
68- txn .fee_payer = funding_key
69- funding_key_pair = get_key_pair (solana_keygen [1 ])
70- path_to_price = get_path_to_pythdir_pair (price_key )
71- price_key_pair = get_key_pair (path_to_price )
72- solana_client = Client ("http://localhost:8899" )
73- solana_client .send_transaction (txn , funding_key_pair , price_key_pair )
74-
7542 def get_account_size (acc_address ):
7643 """
7744 given a string with the pubkey of an account, return its size
@@ -116,15 +83,12 @@ def get_account_size(acc_address):
11683 assert after ['publisher_accounts' ][0 ]['conf' ] == 7
11784 assert after ['publisher_accounts' ][0 ]['status' ] == 'trading'
11885
119- resize_account (pyth_init_price ['LTC' ])
12086 time .sleep (20 )
12187 #defined in oracle.h
12288 new_account_size = 6176
12389 assert get_account_size (pyth_init_price ['LTC' ]) == new_account_size
12490
12591
126-
127- #try adding a new price to the resized accounts
12892 cmd = [
12993 'pyth' , 'upd_price_val' ,
13094 pyth_init_price ['LTC' ],
0 commit comments