def pool_users( cluster_manager: cluster_management.ClusterManager, cluster: clusterlib.ClusterLib, ) -> List[clusterlib.PoolUser]: """Create pool users.""" with cluster_manager.cache_fixture() as fixture_cache: if fixture_cache.value: return fixture_cache.value # type: ignore created_users = clusterlib_utils.create_pool_users( cluster_obj=cluster, name_template= f"test_delegation_pool_user_ci{cluster_manager.cluster_instance_num}", no_of_addr=2, ) fixture_cache.value = created_users # fund source addresses clusterlib_utils.fund_from_faucet( created_users[0], cluster_obj=cluster, faucet_data=cluster_manager.cache.addrs_data["user1"], ) return created_users
def payment_addr( self, cluster_manager: cluster_management.ClusterManager, cluster_update_proposal: clusterlib.ClusterLib, ) -> clusterlib.AddressRecord: """Create new payment address.""" cluster = cluster_update_proposal with cluster_manager.cache_fixture() as fixture_cache: if fixture_cache.value: return fixture_cache.value # type: ignore addr = clusterlib_utils.create_payment_addr_records( f"addr_test_update_proposal_ci{cluster_manager.cluster_instance_num}_0", cluster_obj=cluster, )[0] fixture_cache.value = addr # fund source addresses clusterlib_utils.fund_from_faucet( addr, cluster_obj=cluster, faucet_data=cluster_manager.cache.addrs_data["user1"], ) return addr
def registered_user( self, cluster_manager: cluster_management.ClusterManager, cluster: clusterlib.ClusterLib, pool_user: clusterlib.PoolUser, ) -> clusterlib.PoolUser: """Register pool user's stake address.""" with cluster_manager.cache_fixture() as fixture_cache: if fixture_cache.value: return fixture_cache.value # type: ignore fixture_cache.value = pool_user temp_template = f"test_mir_certs_ci{cluster_manager.cluster_instance}" addr_reg_cert = cluster.gen_stake_addr_registration_cert( addr_name=temp_template, stake_vkey_file=pool_user.stake.vkey_file, ) tx_files = clusterlib.TxFiles( certificate_files=[addr_reg_cert], signing_key_files=[ pool_user.payment.skey_file, pool_user.stake.skey_file ], ) cluster.send_tx(src_address=pool_user.payment.address, tx_name=f"{temp_template}_reg", tx_files=tx_files) assert cluster.get_stake_addr_info( pool_user.stake.address ), f"The address {pool_user.stake.address} was not registered" return pool_user
def payment_addrs( self, cluster_manager: cluster_management.ClusterManager, cluster: clusterlib.ClusterLib, ) -> List[clusterlib.AddressRecord]: """Create 2 new payment addresses.""" with cluster_manager.cache_fixture() as fixture_cache: if fixture_cache.value: return fixture_cache.value # type: ignore addrs = clusterlib_utils.create_payment_addr_records( f"addr_test_fee_ci{cluster_manager.cluster_instance}_0", f"addr_test_fee_ci{cluster_manager.cluster_instance}_1", cluster_obj=cluster, ) fixture_cache.value = addrs # fund source addresses clusterlib_utils.fund_from_faucet( addrs[0], cluster_obj=cluster, faucet_data=cluster_manager.cache.addrs_data["user1"], ) return addrs
def issuers_addrs( cluster_manager: cluster_management.ClusterManager, cluster: clusterlib.ClusterLib, ) -> List[clusterlib.AddressRecord]: """Create new issuers addresses.""" with cluster_manager.cache_fixture() as fixture_cache: if fixture_cache.value: return fixture_cache.value # type: ignore addrs = clusterlib_utils.create_payment_addr_records( *[ f"token_minting_ci{cluster_manager.cluster_instance}_{i}" for i in range(3) ], cluster_obj=cluster, ) fixture_cache.value = addrs # fund source addresses clusterlib_utils.fund_from_faucet( addrs[0], cluster_obj=cluster, faucet_data=cluster_manager.cache.addrs_data["user1"], amount=900_000_000, ) return addrs
def new_token( self, cluster_manager: cluster_management.ClusterManager, cluster: clusterlib.ClusterLib, payment_addrs: List[clusterlib.AddressRecord], ) -> clusterlib_utils.TokenRecord: with cluster_manager.cache_fixture() as fixture_cache: if fixture_cache.value: return fixture_cache.value # type: ignore rand = clusterlib.get_rand_str(4) temp_template = f"test_tx_new_token_{rand}" asset_name = f"couttscoin{rand}" new_tokens = clusterlib_utils.new_tokens( asset_name, cluster_obj=cluster, temp_template=temp_template, token_mint_addr=payment_addrs[0], issuer_addr=payment_addrs[1], amount=20_000_000, ) new_token = new_tokens[0] fixture_cache.value = new_token return new_token
def pool_user( self, cluster_manager: cluster_management.ClusterManager, cluster: clusterlib.ClusterLib, ) -> clusterlib.PoolUser: """Create pool user.""" with cluster_manager.cache_fixture() as fixture_cache: if fixture_cache.value: return fixture_cache.value # type: ignore created_user = clusterlib_utils.create_pool_users( cluster_obj=cluster, name_template= f"test_mir_certs_ci{cluster_manager.cluster_instance}", no_of_addr=1, )[0] fixture_cache.value = created_user # fund source addresses clusterlib_utils.fund_from_faucet( created_user, cluster_obj=cluster, faucet_data=cluster_manager.cache.addrs_data["user1"], ) return created_user
def payment_addrs( self, cluster_manager: cluster_management.ClusterManager, cluster: clusterlib.ClusterLib, ) -> List[clusterlib.AddressRecord]: """Create 2 new payment addresses.""" if cluster.use_cddl: pytest.skip("runs only when `cluster.use_cddl == False`") with cluster_manager.cache_fixture() as fixture_cache: if fixture_cache.value: return fixture_cache.value # type: ignore addrs = clusterlib_utils.create_payment_addr_records( f"addr_shelley_cddl_ci{cluster_manager.cluster_instance_num}_0", f"addr_shelley_cddl_ci{cluster_manager.cluster_instance_num}_1", cluster_obj=cluster, ) fixture_cache.value = addrs # fund source addresses clusterlib_utils.fund_from_faucet( addrs[0], cluster_obj=cluster, faucet_data=cluster_manager.cache.addrs_data["user1"], ) return addrs
def past_horizon_funds( self, cluster_manager: cluster_management.ClusterManager, cluster: clusterlib.ClusterLib, payment_addrs: List[clusterlib.AddressRecord], ) -> Tuple[List[clusterlib.UTXOData], List[clusterlib.UTXOData], clusterlib.TxRawOutput]: """Create UTxOs for `test_past_horizon`.""" with cluster_manager.cache_fixture() as fixture_cache: if fixture_cache.value: return fixture_cache.value # type: ignore temp_template = common.get_test_id(cluster) payment_addr = payment_addrs[0] issuer_addr = payment_addrs[1] script_fund = 200_000_000 minting_cost = plutus_common.compute_cost( execution_cost=plutus_common.MINTING_WITNESS_REDEEMER_COST, protocol_params=cluster.get_protocol_params(), ) mint_utxos, collateral_utxos, tx_raw_output = _fund_issuer( cluster_obj=cluster, temp_template=temp_template, payment_addr=payment_addr, issuer_addr=issuer_addr, minting_cost=minting_cost, amount=script_fund, ) retval = mint_utxos, collateral_utxos, tx_raw_output fixture_cache.value = retval return retval
def registered_user( self, cluster_manager: cluster_management.ClusterManager, cluster_pots: clusterlib.ClusterLib, pool_users: List[clusterlib.PoolUser], ) -> clusterlib.PoolUser: """Register pool user's stake address.""" with cluster_manager.cache_fixture() as fixture_cache: if fixture_cache.value: return fixture_cache.value # type: ignore fixture_cache.value = pool_users[1] temp_template = f"test_mir_certs_ci{cluster_manager.cluster_instance_num}" pool_user = pool_users[1] clusterlib_utils.register_stake_address( cluster_obj=cluster_pots, pool_user=pool_users[1], name_template=temp_template ) return pool_user
def multisig_script_policyid( cluster_manager: cluster_management.ClusterManager, cluster: clusterlib.ClusterLib, issuers_addrs: List[clusterlib.AddressRecord], ) -> Tuple[Path, str]: """Return multisig script and it's PolicyId.""" with cluster_manager.cache_fixture() as fixture_cache: if fixture_cache.value: return fixture_cache.value # type: ignore temp_template = "test_native_tokens_multisig" payment_vkey_files = [p.vkey_file for p in issuers_addrs] # create multisig script multisig_script = cluster.build_multisig_script( script_name=temp_template, script_type_arg=clusterlib.MultiSigTypeArgs.ALL, payment_vkey_files=payment_vkey_files[1:], ) policyid = cluster.get_policyid(multisig_script) return multisig_script, policyid
def registered_users( self, cluster_manager: cluster_management.ClusterManager, cluster_pots: clusterlib.ClusterLib, pool_users: List[clusterlib.PoolUser], ) -> List[clusterlib.PoolUser]: """Register pool user's stake address.""" registered = pool_users[1:3] with cluster_manager.cache_fixture() as fixture_cache: if fixture_cache.value: return fixture_cache.value # type: ignore fixture_cache.value = registered for i, pool_user in enumerate(registered): temp_template = f"test_mir_certs_{i}_ci{cluster_manager.cluster_instance_num}" clusterlib_utils.register_stake_address( cluster_obj=cluster_pots, pool_user=pool_user, name_template=temp_template) return registered
def simple_script_policyid( cluster_manager: cluster_management.ClusterManager, cluster: clusterlib.ClusterLib, issuers_addrs: List[clusterlib.AddressRecord], ) -> Tuple[Path, str]: """Return script and it's PolicyId.""" with cluster_manager.cache_fixture() as fixture_cache: if fixture_cache.value: return fixture_cache.value # type: ignore temp_template = "test_native_tokens_simple" issuer_addr = issuers_addrs[1] # create simple script keyhash = cluster.get_payment_vkey_hash(issuer_addr.vkey_file) script_content = {"keyHash": keyhash, "type": "sig"} script = Path(f"{temp_template}.script") with open(f"{temp_template}.script", "w") as out_json: json.dump(script_content, out_json) policyid = cluster.get_policyid(script) return script, policyid