"""Run signed v2 program transactions on a disposable offline Surfpool validator.""" import argparse import base64 import struct import subprocess import time from pathlib import Path from solders.instruction import Instruction from solders.hash import Hash from solders.keypair import Keypair from solders.pubkey import Pubkey from solders.transaction import Transaction from test_registry import (ROOT, LOADER, SYSTEM, SYS_CLOCK, Rpc, RpcError, deploy, grant_ix, grant_key, meta, must_fail, state_key) BIN = ROOT / "build/solbound_registry_v2.so" TREASURY = Pubkey.from_string("WvfkgdFk919RxXMoFeKLgJH6toXJ9fCnqDoAFA1gq3r") ORACLE = Pubkey.from_string("7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE") RECEIVER = Pubkey.from_string("rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ") DISCRIMINATOR = bytes.fromhex("22f123639d7ef4cd") FEED = bytes.fromhex("ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d") def config_key(program): return Pubkey.find_program_address([b"config"], program)[0] def init_ix(program, bootstrap, admin): code = Pubkey.find_program_address([bytes(program)], LOADER)[0] return Instruction(program, bytes([5]) + bytes(admin), [ meta(bootstrap, True, True), meta(config_key(program), write=True), meta(SYSTEM), meta(code)]) def update_ix(program, admin, version, cents, treasury, paused): data = struct.pack(" price // 100 or published <= 0: raise ValueError("The SOL/USD feed is invalid or outside the confidence bound.") if not 0 <= timestamp - published <= max_age: raise StalePrice("The SOL/USD feed needs a fresh on-chain publication.") return price def fixture(rpc, timestamp, *, price=15_000_000_000, confidence=1, exponent=-8, feed=FEED, discriminator=DISCRIMINATOR, level=1, size=134, owner=RECEIVER): data = bytearray(134) data[:8], data[40], data[41:73] = discriminator, level, feed struct.pack_into("