示例#1
0
文件: run.py 项目: CBobRobison/DAO
def prepare_test_split(ctx, split_gas):
    ctx.assert_scenario_ran('rewards')

    votes = create_votes_array(
        ctx.token_amounts,
        not ctx.args.proposal_fail,
        True
    )
    # remember the account information of the first True votes. They will be
    # the child dao curator in this scenario and grandchild curator in the next
    iterator = (
        (ctx.accounts[i], ctx.token_amounts[i])
        for i, vote in enumerate(votes) if vote is True
    )
    (ctx.child_dao_curator, _) = next(iterator)
    (ctx.grandchild_dao_curator, ctx.grandchild_dao_curator_before) = next(iterator)
    ctx.create_js_file(substitutions={
        "dao_abi": ctx.dao_abi,
        "dao_address": ctx.dao_address,
        "debating_period": ctx.args.split_debate_seconds,
        "split_execution_period": ctx.args.split_execution_period,
        "split_gas": split_gas,
        "votes": arr_str(votes),
        "child_dao_curator": ctx.child_dao_curator
        }
    )
    print(
        "Notice: Debate period is {} seconds so the test will wait "
        "as much".format(ctx.args.split_debate_seconds)
    )
    return votes
示例#2
0
def prepare_test_split(ctx, split_gas):
    ctx.assert_scenario_ran('rewards')

    votes = create_votes_array(
        ctx.token_amounts,
        not ctx.args.proposal_fail,
        True
    )
    # remember the account information of the first True votes. They will be
    # the child dao curator in this scenario and grandchild curator in the next
    iterator = (
        (ctx.accounts[i], ctx.token_amounts[i])
        for i, vote in enumerate(votes) if vote is True
    )
    (ctx.child_dao_curator, _) = next(iterator)
    (ctx.grandchild_dao_curator, ctx.grandchild_dao_curator_before) = next(iterator)
    ctx.create_js_file(substitutions={
        "dao_abi": ctx.dao_abi,
        "dao_address": ctx.dao_addr,
        "debating_period": ctx.args.split_debate_seconds,
        "split_execution_period": ctx.args.split_execution_period,
        "split_gas": split_gas,
        "votes": arr_str(votes),
        "child_dao_curator": ctx.child_dao_curator
        }
    )
    print(
        "Notice: Debate period is {} seconds so the test will wait "
        "as much".format(ctx.args.split_debate_seconds)
    )
    return votes
示例#3
0
文件: run.py 项目: ptahdunbar/DAO.js
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_addr,
            "offer_abi": ctx.offer_abi,
            "offer_address": ctx.offer_addr,
            "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": str(
                ctx.args.proposal_halveminquorum).lower()
        })
    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
        })
示例#4
0
    def prepare_test_split(self, split_gas):
        if self.prop_id != 2:
            # run the rewards scenario first
            self.run_test_rewards()

        debate_secs = 15
        votes = create_votes_array(
            self.token_amounts,
            not self.args.proposal_fail
        )
        self.create_js_file(
            'split',
            {
                "dao_abi": self.dao_abi,
                "dao_address": self.dao_addr,
                "debating_period": debate_secs,
                "split_gas": split_gas,
                "votes": arr_str(votes),
                "prop_id": self.next_proposal_id()
            }
        )
        print(
            "Notice: Debate period is {} seconds so the test will wait "
            "as much".format(debate_secs)
        )
        output = self.run_script('split.js')
        return votes, output
示例#5
0
def prepare_test_split(ctx, split_gas):
    ctx.assert_scenario_ran('rewards')

    votes = create_votes_array(ctx.token_amounts, not ctx.args.proposal_fail)
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "debating_period": ctx.args.split_debate_seconds,
            "split_gas": split_gas,
            "votes": arr_str(votes),
            "prop_id": ctx.next_proposal_id()
        })
    print("Notice: Debate period is {} seconds so the test will wait "
          "as much".format(ctx.args.split_debate_seconds))
    return votes
示例#6
0
    def run_test_proposal(self):
        if not self.token_amounts:
            # run the funding scenario first
            self.run_test_fund()

        debate_secs = 20
        minamount = 2  # is determined by the total costs + one time costs
        amount = random.randint(minamount, sum(self.token_amounts))
        votes = create_votes_array(
            self.token_amounts,
            not self.args.proposal_fail
        )
        yay, nay = count_token_votes(self.token_amounts, votes)
        # self.create_proposal_js(amount, debate_secs, votes)
        self.create_js_file(
            'proposal',
            {
                "dao_abi": self.dao_abi,
                "dao_address": self.dao_addr,
                "offer_abi": self.offer_abi,
                "offer_address": self.offer_addr,
                "offer_amount": amount,
                "offer_desc": 'Test Proposal',
                "proposal_deposit": self.args.proposal_deposit,
                "transaction_bytecode": '0x2ca15122',  # solc --hashes SampleOffer.sol
                "debating_period": debate_secs,
                "votes": arr_str(votes)
            }
        )
        print(
            "Notice: Debate period is {} seconds so the test will wait "
            "as much".format(debate_secs)
        )
        output = self.run_script('proposal.js')
        eval_test('proposal', output, {
            "dao_proposals_number": "1",
            "proposal_passed": True,
            "proposal_yay": yay,
            "proposal_nay": nay,
            "calculated_deposit": self.args.proposal_deposit,
            "onetime_costs": self.args.offer_onetime_costs,
            "deposit_returned": True,
            "offer_promise_valid": True
        })
        self.prop_id = 1
示例#7
0
def run(framework):
    if not framework.token_amounts:
        # run the funding scenario first
        framework.run_scenario('fund')

    minamount = 2  # is determined by the total costs + one time costs
    amount = random.randint(minamount, sum(framework.token_amounts))
    votes = create_votes_array(
        framework.token_amounts,
        not framework.args.proposal_fail
    )
    yay, nay = count_token_votes(framework.token_amounts, votes)
    framework.create_js_file(substitutions={
            "dao_abi": framework.dao_abi,
            "dao_address": framework.dao_addr,
            "offer_abi": framework.offer_abi,
            "offer_address": framework.offer_addr,
            "offer_amount": amount,
            "offer_desc": 'Test Proposal',
            "proposal_deposit": framework.args.proposal_deposit,
            "transaction_bytecode": '0x2ca15122',  # solc --hashes SampleOffer.sol
            "debating_period": framework.args.proposal_debate_seconds,
            "votes": arr_str(votes)
        }
    )
    print(
        "Notice: Debate period is {} seconds so the test will wait "
        "as much".format(framework.args.proposal_debate_seconds)
    )

    framework.execute(expected={
        "dao_proposals_number": "1",
        "proposal_passed": True,
        "proposal_yay": yay,
        "proposal_nay": nay,
        "calculated_deposit": framework.args.proposal_deposit,
        "onetime_costs": framework.args.deploy_onetime_costs,
        "deposit_returned": True,
        "offer_promise_valid": True
    })
    framework.prop_id = 1
示例#8
0
文件: run.py 项目: FelixA/DAO
def prepare_test_split(ctx, split_gas):
    ctx.assert_scenario_ran('rewards')

    votes = create_votes_array(
        ctx.token_amounts,
        not ctx.args.proposal_fail
    )
    ctx.create_js_file(substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "debating_period": ctx.args.split_debate_seconds,
            "split_gas": split_gas,
            "votes": arr_str(votes),
            "prop_id": ctx.next_proposal_id()
        }
    )
    print(
        "Notice: Debate period is {} seconds so the test will wait "
        "as much".format(ctx.args.split_debate_seconds)
    )
    return votes
示例#9
0
文件: run.py 项目: CJGuest/DAO
def run(ctx):
    ctx.assert_scenario_ran('fuel')

    minamount = 2  # is determined by the total costs + one time costs
    amount = random.randint(minamount, sum(ctx.token_amounts))
    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_addr,
        "offer_abi": ctx.offer_abi,
        "offer_address": ctx.offer_addr,
        "offer_amount": amount,
        "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": str(ctx.args.proposal_halveminquorum).lower()
    })
    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_passed": True,
        "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
    })
示例#10
0
def prepare_test_split(framework, split_gas):
    if framework.prop_id != 2:
        # run the rewards scenario first
        framework.run_scenario('rewards')

    votes = create_votes_array(
        framework.token_amounts,
        not framework.args.proposal_fail
    )
    framework.create_js_file(substitutions={
            "dao_abi": framework.dao_abi,
            "dao_address": framework.dao_addr,
            "debating_period": framework.args.split_debate_seconds,
            "split_gas": split_gas,
            "votes": arr_str(votes),
            "prop_id": framework.next_proposal_id()
        }
    )
    print(
        "Notice: Debate period is {} seconds so the test will wait "
        "as much".format(framework.args.split_debate_seconds)
    )
    return votes