Exemplo n.º 1
0
 def set_dnd(self, **kwargs):
     assert "enabled" in kwargs
     enabled = kwargs["enabled"]
     tree = self.xsi_get("services/donotdisturb")
     tree.xpath("//*[local-name() = 'active']")[0].text = \
         utils.bool_to_str(enabled)
     if "ringSplash" in kwargs:
         tree.xpath("//*[local-name() = 'ringSplash']")[0].text = \
             utils.bool_to_str(kwargs["ringSplash"])
     self.xsi_put("services/donotdisturb", utils.xml_string(tree))
Exemplo n.º 2
0
def _update_simultaneous_ring(tree_, state):
    tree = copy.deepcopy(tree_)
    if 'active' in state:
        tree.xpath("//*[local-name() = 'active']")[0].text = utils.bool_to_str(
            state['active'])
    if 'incomingCalls' in state:
        text = "Ring for all Incoming Calls"
        if state['incomingCalls']:
            text = "Do not Ring if on a Call"
        tree.xpath("//*[local-name() = 'incomingCalls']")[0].text = text
    if 'simRingLocations' not in state:  # Do not modify locations
        return tree
    e = tree.find(utils.ns_escape('simRingLocations'))
    if e is None and state['simRingLocations'] == []:
        return tree
    if e is None:
        e = utils.element('simRingLocations')
        tree.getroot().insert(2, e)
    e.clear()
    if state['simRingLocations'] == []:  # Delete locations
        e.attrib["{http://www.w3.org/2001/XMLSchema-instance}nil"] = "true"
        return tree
    for loc in state['simRingLocations']:
        e.append(_location(loc))
    return tree
Exemplo n.º 3
0
 def _set_active_state(self, api_endpoint, **kwargs):
     assert "enabled" in kwargs
     enabled = kwargs["enabled"]
     tree = self.xsi_get(api_endpoint)
     tree.xpath("//*[local-name() = 'active']")[0].text = \
         utils.bool_to_str(enabled)
     self.xsi_put(api_endpoint, utils.xml_string(tree))
Exemplo n.º 4
0
def _update_forward_number(tree_, number_field_name, state):
    tree = copy.deepcopy(tree_)
    tree.xpath("//*[local-name() = 'active']")[0].text = \
        utils.bool_to_str(state["active"])
    e = tree.find(utils.ns_escape(number_field_name))
    if e is None:
        e = tree.getroot().makeelement(number_field_name)
        tree.getroot().insert(1, e)
    e.text = state["number"]
    if not state["number"]:
        # Xsi server requires this twisted way of defining an
        # empty string value
        e.attrib["{http://www.w3.org/2001/XMLSchema-instance}nil"] = "true"
    if "ringSplash" in state:
        tree.xpath("//*[local-name() = 'ringSplash']")[0].text = \
            utils.bool_to_str(state["ringSplash"])
    return tree
Exemplo n.º 5
0
def run(ctx):
    ctx.assert_scenario_ran('fuel')

    votes = create_votes_array(
        ctx.token_amounts,
        not ctx.args.proposal_fail,
        False
    )
    yay, nay = count_token_votes(ctx.token_amounts, votes)
    ctx.create_js_file(substitutions={
        "dao_abi": ctx.dao_abi,
        "dao_address": ctx.dao_address,
        "offer_abi": ctx.offer_abi,
        "offer_address": ctx.offer_address,
        "offer_amount": ctx.args.deploy_total_costs,
        "offer_desc": 'Test Proposal',
        "proposal_deposit": ctx.args.proposal_deposit,
        "transaction_bytecode": '0x2ca15122',  # solc --hashes SampleOffer.sol
        "debating_period": ctx.args.proposal_debate_seconds,
        "votes": arr_str(votes),
        "should_halve_minquorum": bool_to_str(ctx.args.proposal_halveminquorum)
    })
    print(
        "Notice: Debate period is {} seconds so the test will wait "
        "as much".format(ctx.args.proposal_debate_seconds)
    )

    ctx.execute(expected={
        "dao_proposals_number": "1",
        "proposal_yay": yay,
        "proposal_nay": nay,
        "calculated_deposit": ctx.args.proposal_deposit,
        "onetime_costs": ctx.args.deploy_onetime_costs,
        "deposit_returned": True,
        "offer_promise_valid": True
    })
Exemplo n.º 6
0
def run(ctx):
    deploy_contract(
        ctx,
        substitutions={
            "creator_abi": ctx.creator_abi,
            "creator_bin": ctx.creator_bin
        },
        name='deploy_dao_creator',
        result='dao_creator_address'
    )
    deploy_contract(
        ctx,
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_bin": ctx.dao_bin,
            "dao_creator_address": ctx.dao_creator_address,
            "min_tokens_to_create": ctx.args.deploy_min_tokens_to_create,
            "default_proposal_deposit": ctx.args.deploy_proposal_deposit,
            "using_old_dao": bool_to_str(ctx.args.dao_version != "master")
        },
        name='deploy_dao',
        result='dao_address',
        cb=calculate_closing_time
    )
    deploy_contract(
        ctx,
        substitutions={
            "dao_address": ctx.dao_address,
            "offer_abi": ctx.offer_abi,
            "offer_bin": ctx.offer_bin,
            "offer_onetime": ctx.args.deploy_onetime_costs,
            "offer_total": ctx.args.deploy_total_costs,
        },
        name='deploy_offer',
        result='offer_address'
    )
    deploy_contract(
        ctx,
        substitutions={
            "dao_address": ctx.dao_address,
            "pfoffer_abi": ctx.pfoffer_abi,
            "pfoffer_bin": ctx.pfoffer_bin,
            "offer_onetime": ctx.args.deploy_onetime_costs,
            "offer_total": ctx.args.deploy_total_costs,
        },
        name='deploy_pfoffer',
        result='pfoffer_address'
    )
    deploy_contract(
        ctx,
        substitutions={
            "offer_address": ctx.offer_address,
            "usn_abi": ctx.usn_abi,
            "usn_bin": ctx.usn_bin
        },
        name='deploy_usn',
        result='usn_address'
    )

    print("DAO Creator address is: {}".format(ctx.dao_creator_address))
    print("DAO address is: {}".format(ctx.dao_address))
    print("SampleOffer address is: {}".format(ctx.offer_address))
    print("PFOffer address is: {}".format(ctx.pfoffer_address))
    print("USNRewardPayOut address is: {}".format(ctx.usn_address))
    with open(ctx.save_file, "w") as f:
        f.write(json.dumps({
            "dao_creator_address": ctx.dao_creator_address,
            "dao_address": ctx.dao_address,
            "offer_address": ctx.offer_address,
            "pfoffer_address": ctx.pfoffer_address,
            "usn_address": ctx.usn_address,
            "closing_time": ctx.closing_time
        }))

    # after deployment recalculate for the subsequent tests what the min
    # amount of tokens is in the case of extrabalance tests
    if ctx.scenario_uses_extrabalance():
        ctx.args.deploy_min_tokens_to_create = (
            int(ctx.args.deploy_min_tokens_to_create * 1.5)
        )
Exemplo n.º 7
0
def run(ctx):
    deploy_contract(ctx,
                    substitutions={
                        "creator_abi": ctx.creator_abi,
                        "creator_bin": ctx.creator_bin
                    },
                    name='deploy_dao_creator',
                    result='dao_creator_address')
    deploy_contract(ctx,
                    substitutions={
                        "dao_abi":
                        ctx.dao_abi,
                        "dao_bin":
                        ctx.dao_bin,
                        "dao_creator_address":
                        ctx.dao_creator_address,
                        "min_tokens_to_create":
                        ctx.args.deploy_min_tokens_to_create,
                        "default_proposal_deposit":
                        ctx.args.deploy_proposal_deposit,
                        "using_old_dao":
                        bool_to_str(ctx.args.dao_version != "master")
                    },
                    name='deploy_dao',
                    result='dao_address',
                    cb=calculate_closing_time)
    deploy_contract(ctx,
                    substitutions={
                        "dao_address": ctx.dao_address,
                        "offer_abi": ctx.offer_abi,
                        "offer_bin": ctx.offer_bin,
                        "offer_onetime": ctx.args.deploy_onetime_costs,
                        "offer_total": ctx.args.deploy_total_costs,
                    },
                    name='deploy_offer',
                    result='offer_address')
    deploy_contract(ctx,
                    substitutions={
                        "dao_address": ctx.dao_address,
                        "pfoffer_abi": ctx.pfoffer_abi,
                        "pfoffer_bin": ctx.pfoffer_bin,
                        "offer_onetime": ctx.args.deploy_onetime_costs,
                        "offer_total": ctx.args.deploy_total_costs,
                    },
                    name='deploy_pfoffer',
                    result='pfoffer_address')
    deploy_contract(ctx,
                    substitutions={
                        "offer_address": ctx.offer_address,
                        "usn_abi": ctx.usn_abi,
                        "usn_bin": ctx.usn_bin
                    },
                    name='deploy_usn',
                    result='usn_address')

    print("DAO Creator address is: {}".format(ctx.dao_creator_address))
    print("DAO address is: {}".format(ctx.dao_address))
    print("SampleOffer address is: {}".format(ctx.offer_address))
    print("PFOffer address is: {}".format(ctx.pfoffer_address))
    print("USNRewardPayOut address is: {}".format(ctx.usn_address))
    with open(ctx.save_file, "w") as f:
        f.write(
            json.dumps({
                "dao_creator_address": ctx.dao_creator_address,
                "dao_address": ctx.dao_address,
                "offer_address": ctx.offer_address,
                "pfoffer_address": ctx.pfoffer_address,
                "usn_address": ctx.usn_address,
                "closing_time": ctx.closing_time
            }))

    # after deployment recalculate for the subsequent tests what the min
    # amount of tokens is in the case of extrabalance tests
    if ctx.scenario_uses_extrabalance():
        ctx.args.deploy_min_tokens_to_create = (int(
            ctx.args.deploy_min_tokens_to_create * 1.5))
Exemplo n.º 8
0
def run(ctx):
    json_dict = {}
    deploy_contract(
        ctx,
        substitutions={
            "creator_abi": ctx.creator_abi,
            "creator_bin": ctx.creator_bin
        },
        name='deploy_dao_creator',
        result='dao_creator_address',
        json_dict=json_dict
    )
    deploy_contract(
        ctx,
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_bin": ctx.dao_bin,
            "dao_creator_address": ctx.dao_creator_address,
            "min_tokens_to_create": ctx.args.deploy_min_tokens_to_create,
            "default_proposal_deposit": ctx.args.deploy_proposal_deposit,
            "using_old_dao": bool_to_str(ctx.args.dao_version != "master")
        },
        name='deploy_dao',
        result='dao_address',
        json_dict=json_dict,
        cb=calculate_closing_time
    )
    deploy_contract(
        ctx,
        substitutions={
            "dao_address": ctx.dao_address,
            "offer_abi": ctx.offer_abi,
            "offer_bin": ctx.offer_bin,
            "offer_onetime": ctx.args.deploy_onetime_costs,
            "offer_total": ctx.args.deploy_total_costs,
        },
        name='deploy_offer',
        result='offer_address',
        json_dict=json_dict
    )

    if ctx.scenario_uses_pfoffer():
        deploy_contract(
            ctx,
            substitutions={
                "dao_address": ctx.dao_address,
                "pfoffer_abi": ctx.pfoffer_abi,
                "pfoffer_bin": ctx.pfoffer_bin,
                "offer_onetime": ctx.args.deploy_onetime_costs,
                "offer_total": ctx.args.deploy_total_costs,
            },
            name='deploy_pfoffer',
            result='pfoffer_address',
            json_dict=json_dict
        )

    deploy_contract(
        ctx,
        substitutions={
            "offer_address": ctx.offer_address,
            "usn_abi": ctx.usn_abi,
            "usn_bin": ctx.usn_bin
        },
        name='deploy_usn',
        result='usn_address',
        json_dict=json_dict
    )

    if ctx.scenario_uses_dthpool():
        deploy_contract(
            ctx,
            substitutions={
                "dao_address": ctx.dao_address,
                "dthpool_abi": ctx.dthpool_abi,
                "dthpool_bin": ctx.dthpool_bin
            },
            name='deploy_dthpool',
            result='dthpool_address',
            json_dict=json_dict
        )

    with open(ctx.save_file, "w") as f:
        f.write(json.dumps(json_dict))

    # after deployment recalculate for the subsequent tests what the min
    # amount of tokens is in the case of extrabalance tests
    if ctx.scenario_uses_extrabalance():
        ctx.args.deploy_min_tokens_to_create = (
            int(ctx.args.deploy_min_tokens_to_create * 1.5)
        )