Exemple #1
0
def run(ctx):
    ctx.assert_scenario_ran('proposal')
    reward_divisor = 50000
    deployment_reward = 85200
    test_deployment_payment = deployment_reward + 10000
    set_div_bytecode = calculate_bytecode('setRewardDivisor',
                                          ('uint256', reward_divisor))
    set_deploy_bytecode = calculate_bytecode('setDeploymentReward',
                                             ('uint256', deployment_reward))
    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,
            "usn_abi": ctx.usn_abi,
            "usn_address": ctx.usn_address,
            "proposal_deposit": ctx.args.proposal_deposit,
            "set_div_bytecode": set_div_bytecode,
            "set_deploy_bytecode": set_deploy_bytecode,
            "debating_period": ctx.args.proposal_debate_seconds,
            "deployment_reward": deployment_reward,
            "test_deployment_payment": test_deployment_payment
        })
    print("Notice: Debate period is {} seconds so the test will wait "
          "as much".format(ctx.args.proposal_debate_seconds))

    ctx.execute(
        expected={
            "offer_reward_divisor": reward_divisor,
            "offer_deployment_reward": deployment_reward,
            "pay_less_fails": True,
            "reward_payment": test_deployment_payment
        })
def run(ctx):
    ctx.assert_scenario_ran('fuel')
    bytecode = calculate_bytecode('sign')
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_address,
            "pfoffer_abi": ctx.pfoffer_abi,
            "pfoffer_address": ctx.pfoffer_address,
            "offer_amount": ctx.args.deploy_total_costs,
            "proposal_deposit": ctx.args.proposal_deposit,
            "transaction_bytecode": bytecode,
            "debating_period": ctx.args.proposal_debate_seconds,
            "vote_status_deadline":
            ctx.args.deploy_pfoffer_vote_status_deadline
        })
    print("Notice: Debate period is {} seconds so the test will wait "
          "as much".format(ctx.args.proposal_debate_seconds))

    ctx.execute(
        expected={
            "only_contractor_can_watch_proposal": True,
            "proposal_succesfully_watched": True,
            "approved_before_deadline": True,
            "no_money_at_sign": True,
            "contract_valid": True,
            "onetime_payment_failed": True
        })
Exemple #3
0
def run(ctx):
    ctx.assert_scenario_ran('proposal')

    bytecode = calculate_bytecode('0xa1da2fb9', True)
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "total_rewards": ctx.args.rewards_total_amount,
            "proposal_deposit": ctx.args.proposal_deposit,
            "transaction_bytecode": bytecode,
            "debating_period": ctx.args.proposal_debate_seconds,
            "prop_id": ctx.next_proposal_id()
        })
    print("Notice: Debate period is {} seconds so the test will wait "
          "as much".format(ctx.args.proposal_debate_seconds))

    results = ctx.execute(
        expected={
            "curator_reward_portion":
            calculate_reward(ctx.token_amounts[0], ctx.total_supply,
                             ctx.args.rewards_total_amount)
        })
    ctx.dao_balance_after_rewards = results['DAO_balance']
    ctx.dao_rewardToken_after_rewards = results['DAO_rewardToken']
Exemple #4
0
def run(ctx):
    ctx.assert_scenario_ran('rewards')

    # let's just use an existing account
    newAddress = ctx.accounts[4]
    bytecode = calculate_bytecode('newContract', ('address', ctx.accounts[4]))
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "new_contract_address": newAddress,
            "proposal_deposit": ctx.args.proposal_deposit,
            "transaction_bytecode": bytecode,
            "debating_period": ctx.args.proposal_debate_seconds
        })
    print("Notice: Debate period is {} seconds so the test will wait "
          "as much".format(ctx.args.proposal_debate_seconds))

    ctx.execute(
        expected={
            "proposal_passed": True,
            "dao_balance_after": 0,
            "money_transferred": True,
            "reward_tokens_transferred": True
        })
Exemple #5
0
def run(ctx):
    ctx.assert_scenario_ran('fuel')
    bytecode = calculate_bytecode('sign')
    ctx.create_js_file(substitutions={
        "dao_abi": ctx.dao_abi,
        "dao_address": ctx.dao_address,
        "pfoffer_abi": ctx.pfoffer_abi,
        "pfoffer_address": ctx.pfoffer_address,
        "offer_amount": ctx.args.deploy_total_costs,
        "proposal_deposit": ctx.args.proposal_deposit,
        "transaction_bytecode": bytecode,
        "debating_period": ctx.args.proposal_debate_seconds,
        "vote_status_deadline": ctx.args.deploy_pfoffer_vote_status_deadline
    })
    print(
        "Notice: Debate period is {} seconds so the test will wait "
        "as much".format(ctx.args.proposal_debate_seconds)
    )

    ctx.execute(expected={
        "only_contractor_can_watch_proposal": True,
        "proposal_succesfully_watched": True,
        "approved_before_deadline": True,
        "no_money_at_sign": True,
        "contract_valid": True,
        "onetime_payment_failed": True
    })
Exemple #6
0
def run(ctx):
    ctx.assert_scenario_ran('fuel')

    votes = create_votes_array_for_quorum(ctx.token_amounts, 0.4, True, False)
    # let's just use an existing account
    newAddress = ctx.accounts[4]
    bytecode = calculate_bytecode('newContract', ("address", newAddress))
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "new_contract_address": newAddress,
            "proposal_deposit": ctx.args.proposal_deposit,
            "votes": arr_str(votes),
            "transaction_bytecode": bytecode,
            "debating_period": ctx.args.proposal_debate_seconds
        })
    print("Notice: Debate period is {} seconds so the test will wait "
          "as much".format(ctx.args.proposal_debate_seconds))

    ctx.execute(expected={
        "proposal_passed": False,
        "new_contract_balance": 0,
        "dao_balance_diff": 0
    })
Exemple #7
0
def run(ctx):
    ctx.assert_scenario_ran('proposal')

    bytecode = calculate_bytecode('retrieveDAOReward', ("bool", True))
    ctx.create_js_file(substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_address,
            "total_rewards": ctx.args.rewards_total_amount,
            "proposal_deposit": ctx.args.proposal_deposit,
            "transaction_bytecode": bytecode,
            "debating_period": ctx.args.proposal_debate_seconds
        }
    )
    print(
        "Notice: Debate period is {} seconds so the test will wait "
        "as much".format(ctx.args.proposal_debate_seconds)
    )

    results = ctx.execute(expected={
        "curator_reward_portion": calculate_reward(
            ctx.token_amounts[0],
            ctx.total_supply,
            ctx.args.rewards_total_amount)
    })
    ctx.dao_balance_after_rewards = results['DAO_balance']
    ctx.dao_rewardToken_after_rewards = results['DAO_rewardToken']
Exemple #8
0
def run(ctx):
    ctx.assert_scenario_ran('split')
    # right after the split scenario ran, wait sufficient time for the
    # child_dao closingTime() to be reached.
    time_now = round(time.time())
    if time_now < ctx.child_dao_closing_time:
        wait_for_secs = ctx.child_dao_closing_time - time_now
        print(
            "The child DAO's closing time is not yet reached. Test will wait "
            "for {} seconds.".format(wait_for_secs))
        time.sleep(wait_for_secs)
    transaction_bytecode = calculate_bytecode(
        'updateClientAddress', ('address', ctx.child_dao_address))
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "split_execution_period": ctx.args.split_execution_period,
            "child_dao_curator": ctx.child_dao_curator,
            "child_dao_address": ctx.child_dao_address,
            "offer_abi": ctx.offer_abi,
            "offer_address": ctx.offer_addr,
            "child_dao_members": arr_str(ctx.child_dao_members),
            "proposal_deposit": ctx.args.proposal_deposit,
            "debating_period": ctx.args.proposal_debate_seconds,
            "transaction_bytecode": transaction_bytecode
        })
    print("Notice: Debate period is {} seconds so the test will wait "
          "as much".format(ctx.args.proposal_debate_seconds))

    ctx.execute(
        expected={
            "offer_client": ctx.child_dao_address,
            "offer_original_client": ctx.dao_addr
        })
Exemple #9
0
def run(ctx):
    ctx.assert_scenario_ran('proposal')
    daily_limit_in_ether = 5
    pay_reward_amount = 10
    bytecode = calculate_bytecode('setDailyWithdrawLimit',
                                  ('uint256', to_wei(daily_limit_in_ether)))
    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,
            "proposal_deposit": ctx.args.proposal_deposit,
            "pay_reward_amount": pay_reward_amount,
            "transaction_bytecode": bytecode,
            "debating_period": ctx.args.proposal_debate_seconds,
        })
    print("Notice: Debate period is {} seconds so the test will wait "
          "as much".format(ctx.args.proposal_debate_seconds))

    ctx.execute(
        expected={
            "offer_daily_withdraw_limit": daily_limit_in_ether,
            "contractor_diff": daily_limit_in_ether,
            "dao_rewardaccount_diff": pay_reward_amount,
            "sample_offer_no_donations": True
        })
Exemple #10
0
def run(ctx):
    ctx.assert_scenario_ran("split")
    # right after the split scenario ran, wait sufficient time for the
    # child_dao closingTime() to be reached.
    time_now = round(time.time())
    if time_now < ctx.child_dao_closing_time:
        wait_for_secs = ctx.child_dao_closing_time - time_now
        print(
            "The child DAO's closing time is not yet reached. Test will wait " "for {} seconds.".format(wait_for_secs)
        )
        time.sleep(wait_for_secs)
    transaction_bytecode = calculate_bytecode("updateClientAddress", ("address", ctx.child_dao_address))
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_address,
            "split_execution_period": ctx.args.split_execution_period,
            "child_dao_curator": ctx.child_dao_curator,
            "child_dao_address": ctx.child_dao_address,
            "offer_abi": ctx.offer_abi,
            "offer_address": ctx.offer_address,
            "child_dao_members": arr_str(ctx.child_dao_members),
            "proposal_deposit": ctx.args.proposal_deposit,
            "debating_period": ctx.args.proposal_debate_seconds,
            "transaction_bytecode": transaction_bytecode,
        }
    )
    print(
        "Notice: Debate period is {} seconds so the test will wait " "as much".format(ctx.args.proposal_debate_seconds)
    )

    ctx.execute(expected={"offer_client": ctx.child_dao_address, "offer_original_client": ctx.dao_address})
Exemple #11
0
def run(ctx):
    ctx.assert_scenario_ran('rewards')

    # let's just use an existing account
    newAddress = ctx.accounts[4]
    bytecode = calculate_bytecode('newContract', ('address', ctx.accounts[4]))
    ctx.create_js_file(substitutions={
        "dao_abi": ctx.dao_abi,
        "dao_address": ctx.dao_addr,
        "new_contract_address": newAddress,
        "proposal_deposit": ctx.args.proposal_deposit,
        "transaction_bytecode": bytecode,
        "debating_period": ctx.args.proposal_debate_seconds,
        "prop_id": ctx.next_proposal_id()
    })
    print(
        "Notice: Debate period is {} seconds so the test will wait "
        "as much".format(ctx.args.proposal_debate_seconds)
    )

    ctx.execute(expected={
        "proposal_passed": True,
        "dao_balance_after": 0,
        "money_transferred": True,
        "reward_tokens_transferred": True
    })
Exemple #12
0
def run(ctx):
    ctx.assert_scenario_ran('proposal')
    daily_limit_in_ether = 5
    pay_reward_amount = 10
    bytecode = calculate_bytecode('setDailyWithdrawLimit', ('uint256', to_wei(daily_limit_in_ether)))
    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,
        "proposal_deposit": ctx.args.proposal_deposit,
        "pay_reward_amount": pay_reward_amount,
        "transaction_bytecode": bytecode,
        "debating_period": ctx.args.proposal_debate_seconds,
    })
    print(
        "Notice: Debate period is {} seconds so the test will wait "
        "as much".format(ctx.args.proposal_debate_seconds)
    )

    ctx.execute(expected={
        "offer_daily_withdraw_limit": daily_limit_in_ether,
        "contractor_diff": daily_limit_in_ether,
        "dao_rewardaccount_diff": pay_reward_amount,
        "sample_offer_no_donations": True
    })
Exemple #13
0
def run(ctx):
    ctx.assert_scenario_ran('fuel')

    bytecode = calculate_bytecode(
        'changeProposalDeposit',
        ('uint256', ctx.args.deposit_new_value)
    )
    ctx.create_js_file(substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "proposal_deposit": ctx.args.proposal_deposit,
            "transaction_bytecode": bytecode,
            "debating_period": ctx.args.deposit_debate_seconds,
            "prop_id": ctx.next_proposal_id()
        }
    )
    print(
        "Notice: Debate period is {} seconds so the test will wait "
        "as much".format(ctx.args.proposal_debate_seconds)
    )

    ctx.execute(expected={
        "proposal_passed": True,
        "deposit_after_vote": ctx.args.deposit_new_value
    })
Exemple #14
0
def run(ctx):
    ctx.assert_scenario_ran('fuel')

    votes = create_votes_array_for_quorum(ctx.token_amounts, 0.4, True)
    # let's just use an existing account
    newAddress = ctx.accounts[4]
    bytecode = calculate_bytecode('newContract', ("address", newAddress))
    ctx.create_js_file(substitutions={
        "dao_abi": ctx.dao_abi,
        "dao_address": ctx.dao_addr,
        "new_contract_address": newAddress,
        "proposal_deposit": ctx.args.proposal_deposit,
        "votes": arr_str(votes),
        "transaction_bytecode": bytecode,
        "debating_period": ctx.args.proposal_debate_seconds,
        "prop_id": ctx.next_proposal_id()
    })
    print(
        "Notice: Debate period is {} seconds so the test will wait "
        "as much".format(ctx.args.proposal_debate_seconds)
    )

    ctx.execute(expected={
        "proposal_passed": False,
        "new_contract_balance": 0,
        "dao_balance_diff": 0
    })
Exemple #15
0
def run(ctx):
    ctx.assert_scenario_ran('proposal')
    reward_divisor = 50000
    deployment_reward = 85200
    test_deployment_payment = deployment_reward + 10000
    set_div_bytecode = calculate_bytecode(
        'setRewardDivisor', ('uint256', reward_divisor)
    )
    set_deploy_bytecode = calculate_bytecode(
        'setDeploymentReward', ('uint256', deployment_reward)
    )
    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,
        "usn_abi": ctx.usn_abi,
        "usn_address": ctx.usn_address,
        "proposal_deposit": ctx.args.proposal_deposit,
        "set_div_bytecode": set_div_bytecode,
        "set_deploy_bytecode": set_deploy_bytecode,
        "debating_period": ctx.args.proposal_debate_seconds,
        "deployment_reward": deployment_reward,
        "test_deployment_payment": test_deployment_payment
    })
    print(
        "Notice: Debate period is {} seconds so the test will wait "
        "as much".format(ctx.args.proposal_debate_seconds)
    )

    ctx.execute(expected={
        "offer_reward_divisor": reward_divisor,
        "offer_deployment_reward": deployment_reward,
        "pay_less_fails": True,
        "reward_payment": test_deployment_payment
    })
Exemple #16
0
def run(ctx):
    ctx.assert_scenario_ran("spendall")
    attacker_address = ctx.accounts[3]
    bytecode = calculate_bytecode("payOut", ("address", attacker_address), ("uint256", to_wei(5)))
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_address,
            "attacker_address": attacker_address,
            "proposal_deposit": ctx.args.proposal_deposit,
            "debating_period": ctx.args.proposal_debate_seconds,
            "transaction_bytecode": bytecode,
        }
    )

    ctx.execute(expected={"extra_balance_diff_after_attack": 0})
Exemple #17
0
def run(ctx):
    ctx.assert_scenario_ran('spendall')
    attacker_address = ctx.accounts[3]
    bytecode = calculate_bytecode('payOut', ('address', attacker_address),
                                  ('uint256', to_wei(5)))
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_address,
            "attacker_address": attacker_address,
            "proposal_deposit": ctx.args.proposal_deposit,
            "debating_period": ctx.args.proposal_debate_seconds,
            "transaction_bytecode": bytecode
        })

    ctx.execute(expected={"extra_balance_diff_after_attack": 0})
Exemple #18
0
def run(ctx):
    ctx.assert_scenario_ran('fuel')

    bytecode = calculate_bytecode('changeProposalDeposit',
                                  ('uint256', ctx.args.deposit_new_value))
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "proposal_deposit": ctx.args.proposal_deposit,
            "transaction_bytecode": bytecode,
            "debating_period": ctx.args.deposit_debate_seconds
        })
    print("Notice: Debate period is {} seconds so the test will wait "
          "as much".format(ctx.args.proposal_debate_seconds))

    ctx.execute(expected={"deposit_after_vote": ctx.args.deposit_new_value})
Exemple #19
0
def run(ctx):
    ctx.assert_scenario_ran('fuel')
    extra_balance_ether_to_get = 5
    bytecode = calculate_bytecode(
        'payOut', ('address', ctx.dao_addr),
        ('uint256', to_wei(extra_balance_ether_to_get)))
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "proposal_deposit": ctx.args.proposal_deposit,
            "debating_period": ctx.args.proposal_debate_seconds,
            "transaction_bytecode": bytecode
        })

    ctx.execute(
        expected={"dao_balance_diff_after_claim": extra_balance_ether_to_get})
Exemple #20
0
def run(ctx):
    ctx.assert_scenario_ran('spendall')
    extra_balance_ether_to_get = 5
    bytecode = calculate_bytecode(
        'payOut',
        ('address', ctx.dao_address),
        ('uint256', to_wei(extra_balance_ether_to_get))
    )
    ctx.create_js_file(substitutions={
        "dao_abi": ctx.dao_abi,
        "dao_address": ctx.dao_address,
        "proposal_deposit": ctx.args.proposal_deposit,
        "debating_period": ctx.args.proposal_debate_seconds,
        "transaction_bytecode": bytecode
    })

    ctx.execute(expected={
        "dao_balance_diff_after_claim": extra_balance_ether_to_get
    })
Exemple #21
0
def run(ctx):
    ctx.assert_scenario_ran('fuel')
    bytecode = calculate_bytecode('sign')
    ctx.create_js_file(substitutions={
        "dao_abi": ctx.dao_abi,
        "dao_address": ctx.dao_address,
        "pfoffer_abi": ctx.pfoffer_abi,
        "pfoffer_address": ctx.pfoffer_address,
        "offer_amount": ctx.args.deploy_total_costs,
        "proposal_deposit": ctx.args.proposal_deposit,
        "transaction_bytecode": bytecode,
        "debating_period": ctx.args.proposal_debate_seconds,
        "vote_status_deadline": ctx.args.deploy_pfoffer_vote_status_deadline
    })

    ctx.execute(expected={
        "proposal_succesfully_watched": True,
        "approved_before_deadline": False,
    })
Exemple #22
0
def run(ctx):
    ctx.assert_scenario_ran("proposal")
    bytecode = calculate_bytecode("returnRemainingEther")
    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,
            "proposal_deposit": ctx.args.proposal_deposit,
            "transaction_bytecode": bytecode,
            "debating_period": ctx.args.proposal_debate_seconds,
        }
    )
    print(
        "Notice: Debate period is {} seconds so the test will wait " "as much".format(ctx.args.proposal_debate_seconds)
    )

    ctx.execute(expected={"got_back_all_money": True, "bad_proposal_failed": True, "offer_contract_valid": False})
Exemple #23
0
def run(ctx):
    ctx.assert_scenario_ran('proposal')
    bytecode = calculate_bytecode('returnRemainingMoney')
    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,
            "proposal_deposit": ctx.args.proposal_deposit,
            "transaction_bytecode": bytecode,
            "debating_period": ctx.args.proposal_debate_seconds,
        })
    print("Notice: Debate period is {} seconds so the test will wait "
          "as much".format(ctx.args.proposal_debate_seconds))

    ctx.execute(expected={
        "got_back_all_money": True,
        "offer_contract_valid": False
    })
Exemple #24
0
def run(ctx):
    ctx.assert_scenario_ran('fund')

    bytecode = calculate_bytecode('0xe33734fd', ctx.args.deposit_new_value)
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "proposal_deposit": ctx.args.proposal_deposit,
            "transaction_bytecode": bytecode,
            "debating_period": ctx.args.deposit_debate_seconds,
            "prop_id": ctx.next_proposal_id()
        })
    print("Notice: Debate period is {} seconds so the test will wait "
          "as much".format(ctx.args.proposal_debate_seconds))

    ctx.execute(expected={
        "proposal_passed": True,
        "deposit_after_vote": ctx.args.deposit_new_value
    })
Exemple #25
0
def run(ctx):
    ctx.assert_scenario_ran('fuel')
    bytecode = calculate_bytecode('sign')
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_address,
            "pfoffer_abi": ctx.pfoffer_abi,
            "pfoffer_address": ctx.pfoffer_address,
            "offer_amount": ctx.args.deploy_total_costs,
            "proposal_deposit": ctx.args.proposal_deposit,
            "transaction_bytecode": bytecode,
            "debating_period": ctx.args.proposal_debate_seconds,
            "vote_status_deadline":
            ctx.args.deploy_pfoffer_vote_status_deadline
        })

    ctx.execute(expected={
        "proposal_succesfully_watched": True,
        "approved_before_deadline": False,
    })
Exemple #26
0
def run(ctx):
    ctx.assert_scenario_ran('proposal')
    bytecode = calculate_bytecode('payOneTimeReward')
    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,
        "proposal_deposit": ctx.args.proposal_deposit,
        "transaction_bytecode": bytecode,
        "debating_period": ctx.args.proposal_debate_seconds,
    })
    print(
        "Notice: Debate period is {} seconds so the test will wait "
        "as much".format(ctx.args.proposal_debate_seconds)
    )

    ctx.execute(expected={
        # Nothing should make it to the reward account
        "dao_rewardaccount_diff": 0,
        # The DAO keeps the proposal deposit
        "dao_balance_diff": to_wei(ctx.args.proposal_deposit)
    })
Exemple #27
0
def run(ctx):
    ctx.assert_scenario_ran('fuel')
    onetime_bytecode = calculate_bytecode('getOneTimePayment')
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_address,
            "pfoffer_abi": ctx.pfoffer_abi,
            "pfoffer_address": ctx.pfoffer_address,
            "offer_amount": ctx.args.deploy_total_costs,
            "proposal_deposit": ctx.args.proposal_deposit,
            "transaction_bytecode": '0x2ca15122',
            "onetime_bytecode": onetime_bytecode,
            "debating_period": ctx.args.proposal_debate_seconds
        })
    print("Notice: Debate period is {} seconds so the test will wait "
          "as much".format(ctx.args.proposal_debate_seconds))

    ctx.execute(
        expected={
            "no_money_at_sign": True,
            "contract_valid": True,
            "onetime_payment_failed": True
        })
Exemple #28
0
def run(ctx):
    ctx.assert_scenario_ran('fuel')
    onetime_bytecode = calculate_bytecode('getOneTimePayment')
    ctx.create_js_file(substitutions={
        "dao_abi": ctx.dao_abi,
        "dao_address": ctx.dao_address,
        "pfoffer_abi": ctx.pfoffer_abi,
        "pfoffer_address": ctx.pfoffer_address,
        "offer_amount": ctx.args.deploy_total_costs,
        "proposal_deposit": ctx.args.proposal_deposit,
        "transaction_bytecode": '0x2ca15122',
        "onetime_bytecode": onetime_bytecode,
        "debating_period": ctx.args.proposal_debate_seconds
    })
    print(
        "Notice: Debate period is {} seconds so the test will wait "
        "as much".format(ctx.args.proposal_debate_seconds)
    )

    ctx.execute(expected={
        "no_money_at_sign": True,
        "contract_valid": True,
        "onetime_payment_failed": True
    })
Exemple #29
0
def test_args():
    """ Parse the test arguments and create and return the arguments object"""
    p = argparse.ArgumentParser(description='DAO contracts test framework')
    read_scenario_options(p)

    p.add_argument('--solc', help='Full path to the solc binary to use')
    p.add_argument('--geth', help='Full path to the geth binary to use')
    p.add_argument('--keep-limits',
                   action='store_true',
                   help=('If given then the debate limits of the original '
                         'contracts will not be removed'))
    p.add_argument('--clean-chain',
                   action='store_true',
                   help=('If given then the blockchain is deleted before any '
                         'test scenario is executed'))
    p.add_argument(
        '--verbose',
        action='store_true',
        help='If given then all test checks are printed in the console')
    p.add_argument(
        '--proposal-fail',
        action='store_true',
        help='If given, then in the proposal scenario the voting will fail')
    p.add_argument(
        '--compile-test',
        action='store_true',
        help='If given, then tests will only try to compile the contracts')
    p.add_argument(
        '--users-num',
        type=int,
        help='The number of user accounts to create for the scenarios.'
        'Should be at least 3',
        default=5)
    p.add_argument('--scenario',
                   choices=['none'] + available_scenarios(),
                   default='none',
                   help='Available test scenario to play out')
    p.add_argument('--describe-scenarios',
                   action='store_true',
                   help='Print the description of all scenarios and then quit')
    p.add_argument(
        '--abi',
        type=str,
        default="",
        help=(
            "If given then don't run any tests but print the abi of the given "
            "function with the arguments provided. Example call:"
            "test.py --abi \"transfer address foo uint256 5\""))
    p.add_argument(
        '--dao-version',
        type=str,
        default="v1.0",
        choices=["v1.0", "master"],
        help="The version of the DAO code to run the tests against.")
    args = p.parse_args()

    # Argument verification
    if args.users_num < 3:
        print("ERROR: Tests need 3 or more users")
        sys.exit(1)

    # if it's an abi test call then just show bytecode and exit
    if args.abi != "":
        arglist = args.abi.split(" ")
        function_args = []
        for type_name, value in pairwise(arglist[1:]):
            function_args.append((type_name, value))
        bytecode = calculate_bytecode(arglist[0], *function_args)
        print("Requested bytecode is:\n{}\n.Exiting ...".format(bytecode))
        sys.exit(0)

    if args.compile_test:
        # if we are asking for compile_test then it should always be against
        # the latest version of the contracts
        args.dao_version = "master"

    return args
Exemple #30
0
def test_args():
    """ Parse the test arguments and create and return the arguments object"""
    p = argparse.ArgumentParser(description='Foundation contracts test framework')
    read_scenario_options(p)

    p.add_argument(
        '--solc',
        help='Full path to the solc binary to use'
    )
    p.add_argument(
        '--geth',
        help='Full path to the geth binary to use'
    )
    p.add_argument(
        '--keep-limits',
        action='store_true',
        help=(
            'If given then the debate limits of the original '
            'contracts will not be removed'
        )
    )
    p.add_argument(
        '--clean-chain',
        action='store_true',
        help=(
            'If given then the blockchain is deleted before any '
            'test scenario is executed'
        )
    )
    p.add_argument(
        '--verbose',
        action='store_true',
        help='If given then all test checks are printed in the console'
    )
    p.add_argument(
        '--proposal-fail',
        action='store_true',
        help='If given, then in the proposal scenario the voting will fail'
    )
    p.add_argument(
        '--users-num',
        type=int,
        help='The number of user accounts to create for the scenarios.'
        'Should be at least 3',
        default=5
    )
    p.add_argument(
        '--scenario',
        choices=['none'] + available_scenarios(),
        default='none',
        help='Available test scenario to play out'
    )
    p.add_argument(
        '--describe-scenarios',
        action='store_true',
        help='Print the description of all scenarios and then quit'
    )
    p.add_argument(
        '--abi',
        type=str,
        default="",
        help=(
            "If given then don't run any tests but print the abi of the given "
            "function with the arguments provided. Example call:"
            "test.py --abi \"transfer address foo uint256 5\""
        )
    )
    args = p.parse_args()

    # Argument verification
    if args.users_num < 3:
        print("ERROR: Tests need 3 or more users")
        sys.exit(1)

    # if it's an abi test call then just show bytecode and exit
    if args.abi != "":
        arglist = args.abi.split(" ")
        function_args = []
        for type_name, value in pairwise(arglist[1:]):
            function_args.append((type_name, value))
        bytecode = calculate_bytecode(arglist[0], *function_args)
        print("Requested bytecode is:\n{}\n.Exiting ...".format(bytecode))
        sys.exit(0)

    return args