示例#1
0
 def __init__(self, host, port, passphrase):
     self.host = "{host}:{port}".format(host=host, port=port)
     self.passphrase = passphrase
     self.gpg, self.fp = util.get_or_gen_gpg(passphrase, config.CLIENT_GPG_HOME)
     self.server_fp = config.SERVER_KEY_FP
     self.secret = util.generate_random_string()
     self.session = False
示例#2
0
 def __init__(self, label, page, category_id):
     self.id = util.generate_random_string()
     self.group = "taskgroup" + self.id
     self.label = label
     self.page = page
     self.category_id = category_id
     self.complete = False
示例#3
0
    def do_POST(self):
        global globalInfo
        if self.path[0] != '/':
            self.path = '/' + self.path
        path_list = self.path.split('/')

        content_length = int(self.headers['Content-Length'])
        post_data = json.loads(self.rfile.read(content_length).decode('utf-8'))
        print('do_POST', path_list, post_data)
        if path_list[1] == 'query_ticket':
            ticket = post_data['ticket']
            if ticket not in globalInfo.async_result:
                self._set_response(gzip=False)
                self.wfile.write(json.dumps(
                    {'status': False, 'reason': 'ticket %s not exists' % ticket}).encode('utf-8'))
            else:
                self._set_response(gzip=True)
                self.wfile.write(gzip_encode(json.dumps(
                    {'status': True, 'data': globalInfo.async_result[ticket]}).encode('utf-8')))
        elif path_list[1] == 'async_query':
            ticket = ptsutil.generate_random_string(5)
            startTS = datetime.datetime.now().strftime('%Y%m%d-%H:%M:%S')
            globalInfo.async_result[ticket] = {'id': ticket, 'status': 'enqueue', 'startTS': startTS}
            self.worker_pool.apply_async(worker_job, args=(ticket, startTS), callback=worker_callback)
            self._set_response(gzip=False)
            self.wfile.write(json.dumps({'status': True, 'ticket': '%s' % ticket,
                                         'host': globalInfo.host}).encode('utf-8'))
        elif path_list[1] == 'test_empty_response':
            print('recv test_empty_response')
            pass
        else:
            ret_value = {"echo": post_data}
            self._set_response(gzip=True)
            self.wfile.write(gzip_encode(json.dumps(ret_value).encode('utf-8')))
示例#4
0
 def __init__(self, host, port, passphrase):
     self.host = "{host}:{port}".format(host=host, port=port)
     self.passphrase = passphrase
     self.gpg, self.fp = util.get_or_gen_gpg(passphrase,
                                             config.CLIENT_GPG_HOME)
     self.server_fp = config.SERVER_KEY_FP
     self.secret = util.generate_random_string()
     self.session = False
示例#5
0
 def __init__(self, parent, label="", color=[0, 0, 0, -1]):
     self.id = util.generate_random_string()
     self.group = "catgroup" + self.id
     self.parent = parent
     self.label = label
     self.color = color
     self.tasks = TaskTracker()
     self.complete = False
示例#6
0
def authenticate_person(recipient_id):
    key = util.gpg_decrypt(app.gpg, request.data, config.SERVER_PASSPHRASE)
    key2 = util.generate_random_string(32)
    body = {'key': str(key), 'key2': key2}
    msg = json.dumps(body)
    server_fp = util.get_fp_from_gpg(app.gpg, config.SERVER_KEY_FP)
    encrypted = util.gpg_encrypt(app.gpg, server_fp, msg, recipient_id,
                                 config.SERVER_PASSPHRASE)
    return str(encrypted), 200
示例#7
0
    def __init__(self, page_name, parent, path=None, filename=None):
        self.id = util.generate_random_string()
        self.page_name = page_name
        self.parent = parent
        self.path = path
        self.filename = filename

        self.category_tracker = trackers.CategoryTracker()
        self.changes = False
示例#8
0
def upload():
    if 'video' not in request.files:
        return json_error("Video file not found")

    video_file = request.files['video']
    filename = secure_filename(video_file.filename)
    ext = filename.split('.')[-1]
    new_filename = generate_random_string() + '.' + ext
    video_file.save(os.path.join(app.config['UPLOAD_DIR'], new_filename))

    video = Video(filename=new_filename)
    video.save()

    return jsonify(video.to_dict())
示例#9
0
 def add_category(self, sender, data):
     random_id = util.generate_random_string()
     with simple.group(f"newcategory{random_id}",
                       parent=f"categories{self.id}"):
         dpg.add_input_text(f"catlabel{random_id}", label="")
         dpg.add_same_line(spacing=10)
         dpg.add_button(f"catdone{random_id}",
                        callback=self.submit_category,
                        label="Done")
         dpg.add_color_picker4(
             f"catcolor{random_id}",
             default_value=[255, 0, 0, 255],
             height=200,
             width=200,
             label="",
         )
示例#10
0
文件: view_user.py 项目: yzf/WeTalk
def register(request):
    '''
    注册新用户

    参数:
        request.REQUEST['username']: 账号
        request.REQUEST['password']: 密码
    返回值:
        如果成功,则返回
            {'status': 1,
             'info': 'ok',
        否则
            {'status': 0,
             'info': 'error'}
    其他:
    '''
    data = {'status': 0, 'info': 'error'}
    try:
        user = User()
        user.username = request.REQUEST['username']
        user.password = request.REQUEST['password']
        user.icon = Image.objects.get(id=1) #设置默认头像
        if user.username.strip() == '' or user.password.strip() == '':
            raise # 账号或者密码为空
        user.save()# 插入数据
        user_data = user.toJsonFormat()

        auth = Auth()
        auth.key = util.generate_random_string(32)
        auth.data = json.dumps(user_data)
        auth.save()

        create_time = request.REQUEST['create_time']
        # system send a welcome message to user
        system_user = User.objects.get(username="******")
        welcome = Message(to_user=user, from_user=system_user, is_read=False, content="Welcome to WeTalk!", create_time=create_time)
        welcome.save()

        data['authkey'] = auth.key
        data['status'] = 1
        data['info'] = 'ok'
    except Exception as e:
        data['info'] = util.get_exception_message(e)
        print e
    return HttpResponse(json.dumps(data))
示例#11
0
 def add_task(self, sender, data):
     random_id = util.generate_random_string()
     parent = dpg.get_item_parent(sender)
     with simple.group(
             f"newtask{random_id}",
             parent=parent.replace("newtask", ""),
             before=f"taskspace{data.get('category')}",
     ):
         dpg.add_indent()
         dpg.add_input_text(f"tasklabel{random_id}", label="")
         dpg.add_same_line(spacing=10)
         dpg.add_button(
             f"taskdone{random_id}",
             label="Done",
             callback=self.submit_task,
             callback_data={
                 "parent": parent,
                 "category": data["category"]
             },
         )
         dpg.unindent()
示例#12
0
文件: view_user.py 项目: yzf/WeTalk
def register(request):
    '''
    注册新用户

    参数:
        request.REQUEST['username']: 账号
        request.REQUEST['password']: 密码
    返回值:
        如果成功,则返回
            {'status': 1,
             'info': 'ok',
        否则
            {'status': 0,
             'info': 'error'}
    其他:
    '''
    data = {'status': 0, 'info': 'error'}
    try:
        user = User()
        user.username = request.REQUEST['username']
        user.password = request.REQUEST['password']
        user.icon = Image.objects.get(id=1)  #设置默认头像
        if user.username.strip() == '' or user.password.strip() == '':
            raise  # 账号或者密码为空
        user.save()  # 插入数据
        user_data = user.toJsonFormat()

        auth = Auth()
        auth.key = util.generate_random_string(32)
        auth.data = json.dumps(user_data)
        auth.save()

        data['authkey'] = auth.key
        data['status'] = 1
        data['info'] = 'ok'
    except Exception as e:
        data['info'] = util.get_exception_message(e)
        print e
    return HttpResponse(json.dumps(data))
示例#13
0
文件: view_user.py 项目: yzf/WeTalk
def register(request):
    '''
    注册新用户

    参数:
        request.REQUEST['username']: 账号
        request.REQUEST['password']: 密码
    返回值:
        如果成功,则返回
            {'status': 1,
             'info': 'ok',
        否则
            {'status': 0,
             'info': 'error'}
    其他:
    '''
    data = {'status': 0, 'info': 'error'}
    try:
        user = User()
        user.username = request.REQUEST['username']
        user.password = request.REQUEST['password']
        user.icon = Image.objects.get(id=1)#设置默认头像
        if user.username.strip() == '' or user.password.strip() == '':
            raise # 账号或者密码为空
        user.save()# 插入数据
        user_data = user.toJsonFormat()

        auth = Auth()
        auth.key = util.generate_random_string(32)
        auth.data = json.dumps(user_data)
        auth.save()

        data['authkey'] = auth.key
        data['status'] = 1
        data['info'] = 'ok'
    except Exception as e:
        data['info'] = util.get_exception_message(e)
        print e
    return HttpResponse(json.dumps(data))
示例#14
0
文件: view_user.py 项目: yzf/WeTalk
def login(request):
    '''
    登陆系统

    参数:
        request.REQUEST['username']: 账号
        request.REQUEST['password']: 密码
    返回值:
        如果成功,则返回
            {'status': 1,
             'info': 'ok',
        否则
            {'status': 0,
             'info': 'error'}
    其他:
    '''
    data = {'status': 0, 'info': 'error'}
    try:
        username = request.REQUEST['username']
        password = request.REQUEST['password']

        user = User.objects.get(username=username, password=password)
        user_data = user.toJsonFormat()

        auth = Auth()
        auth.key = util.generate_random_string(32)
        auth.data = json.dumps(user_data)
        auth.save()

        data['authkey'] = auth.key
        data['status'] = 1
        data['info'] = 'ok'
    except Exception as e:
        data['info'] = util.get_exception_message(e)
        print e
    return HttpResponse(json.dumps(data))
示例#15
0
文件: view_user.py 项目: yzf/WeTalk
def login(request):
    '''
    登陆系统

    参数:
        request.REQUEST['username']: 账号
        request.REQUEST['password']: 密码
    返回值:
        如果成功,则返回
            {'status': 1,
             'info': 'ok',
        否则
            {'status': 0,
             'info': 'error'}
    其他:
    '''
    data = {'status': 0, 'info': 'error'}
    try:
        username = request.REQUEST['username']
        password = request.REQUEST['password']

        user = User.objects.get(username=username, password=password)
        user_data = user.toJsonFormat()

        auth = Auth()
        auth.key = util.generate_random_string(32)
        auth.data = json.dumps(user_data)
        auth.save()

        data['authkey'] = auth.key
        data['status'] = 1
        data['info'] = 'ok'
    except Exception as e:
        data['info'] = util.get_exception_message(e)
        print e
    return HttpResponse(json.dumps(data))
示例#16
0
def test_rewards(test_params):

    # test params inits
    rpc = test_params.get('node1').get('rpc')
    rpc1 = test_params.get('node2').get('rpc')

    pubkey = test_params.get('node1').get('pubkey')
    pubkey1 = test_params.get('node2').get('pubkey')

    is_fresh_chain = test_params.get("is_fresh_chain")

    global proxy
    proxy = [rpc, rpc1]

    result = rpc.rewardsaddress()
    for x in result.keys():
        if x.find('ddress') > 0:
            assert result[x][0] == 'R'

    result = rpc.rewardsaddress(pubkey)
    for x in result.keys():
        if x.find('ddress') > 0:
            assert result[x][0] == 'R'

    # no rewards yet
    if is_fresh_chain:
        result = rpc.rewardslist()
        assert result == []

    # looking up non-existent reward should return error
    result = rpc.rewardsinfo("none")
    assert_error(result)

    # creating rewards plan with name > 8 chars, should return error
    result = rpc.rewardscreatefunding("STUFFSTUFF", "7777", "25", "0", "10", "10")
    assert_error(result)

    # creating rewards plan with 0 funding
    result = rpc.rewardscreatefunding("STUFF", "0", "25", "0", "10", "10")
    assert_error(result)

    # creating rewards plan with 0 maxdays
    result = rpc.rewardscreatefunding("STUFF", "7777", "25", "0", "10", "0")
    assert_error(result)

    # creating rewards plan with > 25% APR
    result = rpc.rewardscreatefunding("STUFF", "7777", "30", "0", "10", "10")
    assert_error(result)

    # creating valid rewards plan
    plan_name = generate_random_string(6)
    result = rpc.rewardscreatefunding(plan_name, "7777", "25", "0", "10", "10")
    assert result['hex'], 'got raw xtn'
    fundingtxid = send_and_mine(result['hex'], rpc)
    assert fundingtxid, 'got txid'
    result = rpc.rewardsinfo(fundingtxid)
    assert_success(result)
    assert result['name'] == plan_name
    assert result['APR'] == "25.00000000"
    assert result['minseconds'] == 0
    assert result['maxseconds'] == 864000
    assert result['funding'] == "7777.00000000"
    assert result['mindeposit'] == "10.00000000"
    assert result['fundingtxid'] == fundingtxid

    # checking if new plan in rewardslist
    result = rpc.rewardslist()
    assert fundingtxid in result

    # creating reward plan with already existing name, should return error
    result = rpc.rewardscreatefunding(plan_name, "7777", "25", "0", "10", "10")
    assert_error(result)

    # add funding amount must be positive
    result = rpc.rewardsaddfunding(plan_name, fundingtxid, "-1")
    assert_error(result)

    # add funding amount must be positive
    result = rpc.rewardsaddfunding(plan_name, fundingtxid, "0")
    assert_error(result)

    # adding valid funding
    result = rpc.rewardsaddfunding(plan_name, fundingtxid, "555")
    addfundingtxid = send_and_mine(result['hex'], rpc)
    assert addfundingtxid, 'got funding txid'

    # checking if funding added to rewardsplan
    result = rpc.rewardsinfo(fundingtxid)
    assert result['funding'] == "8332.00000000"

    # trying to lock funds, locking funds amount must be positive
    result = rpc.rewardslock(plan_name, fundingtxid, "-5")
    assert_error(result)

    # trying to lock funds, locking funds amount must be positive
    result = rpc.rewardslock(plan_name, fundingtxid, "0")
    assert_error(result)

    # trying to lock less than the min amount is an error
    result = rpc.rewardslock(plan_name, fundingtxid, "7")
    assert_error(result)

    # locking funds in rewards plan
    result = rpc.rewardslock(plan_name, fundingtxid, "10")
    assert_success(result)
    locktxid = result['hex']
    assert locktxid, "got lock txid"

    # locktxid has not been broadcast yet
    result = rpc.rewardsunlock(plan_name, fundingtxid, locktxid)
    assert_error(result)

    # broadcast xtn
    txid = rpc.sendrawtransaction(locktxid)
    assert txid, 'got txid from sendrawtransaction'

    # confirm the xtn above
    wait_some_blocks(rpc, 1)

    # will not unlock since reward amount is less than tx fee
    result = rpc.rewardsunlock(plan_name, fundingtxid, locktxid)
    assert_error(result)
示例#17
0
文件: svwa.py 项目: Yas3r/svwa-1
def generate_csrf_token():
    if '_csrf_token' not in session:
        session['_csrf_token'] = generate_random_string()
    return session['_csrf_token']
示例#18
0
def test_oracles():

    # test params inits
    with open('test_config.json', 'r') as f:
        params_dict = json.load(f)

    node1_params = params_dict["node1"]
    node2_params = params_dict["node2"]

    rpc = rpc_connect(node1_params["rpc_user"], node1_params["rpc_password"],
                      node1_params["rpc_ip"], node1_params["rpc_port"])
    rpc1 = rpc_connect(node2_params["rpc_user"], node2_params["rpc_password"],
                       node2_params["rpc_ip"], node2_params["rpc_port"])
    pubkey = node1_params["pubkey"]
    pubkey1 = node2_params["pubkey"]

    is_fresh_chain = params_dict["is_fresh_chain"]

    result = rpc.oraclesaddress()
    assert_success(result)

    for x in result.keys():
        if x.find('ddress') > 0:
            assert result[x][0] == 'R'

    result = rpc.oraclesaddress(pubkey)
    assert_success(result)

    for x in result.keys():
        if x.find('ddress') > 0:
            assert result[x][0] == 'R'

    # there are no oracles created yet
    if is_fresh_chain:
        result = rpc.oracleslist()
        assert result == []

    # looking up non-existent oracle should return error.
    result = rpc.oraclesinfo("none")
    assert_error(result)

    # attempt to create oracle with not valid data type should return error
    result = rpc.oraclescreate("Test", "Test", "Test")
    assert_error(result)

    # attempt to create oracle with description > 32 symbols should return error
    too_long_name = generate_random_string(33)
    result = rpc.oraclescreate(too_long_name, "Test", "s")
    assert_error(result)

    # attempt to create oracle with description > 4096 symbols should return error
    too_long_description = generate_random_string(4100)
    result = rpc.oraclescreate("Test", too_long_description, "s")
    assert_error(result)

    # valid creating oracles of different types
    # using such naming to re-use it for data publishing / reading (e.g. oracle_s for s type)
    print(len(rpc.listunspent()))
    valid_formats = [
        "s", "S", "d", "D", "c", "C", "t", "T", "i", "I", "l", "L", "h", "Ihh"
    ]
    for f in valid_formats:
        result = rpc.oraclescreate("Test_" + f, "Test_" + f, f)
        assert_success(result)
        globals()["oracle_{}".format(f)] = rpc.sendrawtransaction(
            result['hex'])

    wait_some_blocks(rpc, 1)

    for f in valid_formats:
        # trying to register with negative datafee
        result = rpc.oraclesregister(globals()["oracle_{}".format(f)], "-100")
        assert_error(result)

        # trying to register with zero datafee
        result = rpc.oraclesregister(globals()["oracle_{}".format(f)], "0")
        assert_error(result)

        # trying to register with datafee less than txfee
        result = rpc.oraclesregister(globals()["oracle_{}".format(f)], "500")
        assert_error(result)

        # trying to register valid (unfunded)
        result = rpc.oraclesregister(globals()["oracle_{}".format(f)], "10000")
        assert_error(result)

        # Fund the oracles
        result = rpc.oraclesfund(globals()["oracle_{}".format(f)])
        assert_success(result)
        fund_txid = rpc.sendrawtransaction(result["hex"])
        assert fund_txid, "got txid"

    wait_some_blocks(rpc, 1)

    for f in valid_formats:
        # trying to register valid (funded)
        result = rpc.oraclesregister(globals()["oracle_{}".format(f)], "10000")
        print(f)
        assert_success(result)
        register_txid = rpc.sendrawtransaction(result["hex"])
        assert register_txid, "got txid"

        # TODO: for most of the non valid oraclesregister and oraclessubscribe transactions generating and broadcasting now
        # so trying only valid oraclessubscribe atm
        result = rpc.oraclessubscribe(globals()["oracle_{}".format(f)], pubkey,
                                      "1")
        assert_success(result)
        subscribe_txid = rpc.sendrawtransaction(result["hex"])
        assert register_txid, "got txid"

    wait_some_blocks(rpc, 2)

    # now lets publish and read valid data for each oracle type

    # recording data for s type
    result = rpc.oraclesdata(globals()["oracle_{}".format("s")],
                             "05416e746f6e")
    assert_success(result)
    oraclesdata_s = rpc.sendrawtransaction(result["hex"])
    info_s = rpc.oraclesinfo(globals()["oracle_{}".format("s")])
    batonaddr_s = info_s['registered'][0]['baton']

    # recording data for S type
    result = rpc.oraclesdata(
        globals()["oracle_{}".format("S")],
        "000161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161"
    )
    assert_success(result)
    oraclesdata_S = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("S")])
    batonaddr_S = info['registered'][0]['baton']

    # recording data for d type
    result = rpc.oraclesdata(globals()["oracle_{}".format("d")], "0101")
    assert_success(result)
    # baton
    oraclesdata_d = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("d")])
    batonaddr_d = info['registered'][0]['baton']

    # recording data for D type
    result = rpc.oraclesdata(globals()["oracle_{}".format("D")], "010001")
    assert_success(result)
    # baton
    oraclesdata_D = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("D")])
    batonaddr_D = info['registered'][0]['baton']

    # recording data for c type
    result = rpc.oraclesdata(globals()["oracle_{}".format("c")], "ff")
    assert_success(result)
    # baton
    oraclesdata_c = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("c")])
    batonaddr_c = info['registered'][0]['baton']

    # recording data for C type
    result = rpc.oraclesdata(globals()["oracle_{}".format("C")], "ff")
    assert_success(result)
    # baton
    oraclesdata_C = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("C")])
    batonaddr_C = info['registered'][0]['baton']

    # recording data for t type
    result = rpc.oraclesdata(globals()["oracle_{}".format("t")], "ffff")
    assert_success(result)
    # baton
    oraclesdata_t = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("t")])
    batonaddr_t = info['registered'][0]['baton']

    # recording data for T type
    result = rpc.oraclesdata(globals()["oracle_{}".format("T")], "ffff")
    assert_success(result)
    # baton
    oraclesdata_T = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("T")])
    batonaddr_T = info['registered'][0]['baton']

    # recording data for i type
    result = rpc.oraclesdata(globals()["oracle_{}".format("i")], "ffffffff")
    assert_success(result)
    # baton
    oraclesdata_i = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("i")])
    batonaddr_i = info['registered'][0]['baton']

    # recording data for I type
    result = rpc.oraclesdata(globals()["oracle_{}".format("I")], "ffffffff")
    assert_success(result)
    # baton
    oraclesdata_I = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("I")])
    batonaddr_I = info['registered'][0]['baton']

    # recording data for l type
    result = rpc.oraclesdata(globals()["oracle_{}".format("l")],
                             "00000000ffffffff")
    assert_success(result)
    # baton
    oraclesdata_l = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("l")])
    batonaddr_l = info['registered'][0]['baton']

    # recording data for L type
    result = rpc.oraclesdata(globals()["oracle_{}".format("L")],
                             "00000000ffffffff")
    assert_success(result)
    # baton
    oraclesdata_L = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("L")])
    batonaddr_L = info['registered'][0]['baton']

    # recording data for h type
    result = rpc.oraclesdata(
        globals()["oracle_{}".format("h")],
        "00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff")
    assert_success(result)
    # baton
    oraclesdata_h = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("h")])
    batonaddr_h = info['registered'][0]['baton']

    # recording data for Ihh type
    result = rpc.oraclesdata(
        globals()["oracle_{}".format("Ihh")],
        "ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff"
    )
    assert_success(result)
    # baton
    oraclesdata_Ihh = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("Ihh")])
    batonaddr_Ihh = info['registered'][0]['baton']

    wait_some_blocks(rpc, 1)

    # checking data for s type
    result = rpc.oraclessamples(globals()["oracle_{}".format("s")],
                                batonaddr_s, "1")
    assert "['Anton']" == str(result["samples"][0]['data'])

    # checking data for S type
    result = rpc.oraclessamples(globals()["oracle_{}".format("S")],
                                batonaddr_S, "1")
    assert "['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']" == str(
        result["samples"][0]['data'])

    # checking data for d type
    result = rpc.oraclessamples(globals()["oracle_{}".format("d")],
                                batonaddr_d, "1")
    assert "['01']" == str(result["samples"][0]['data'])

    # checking data for D type
    result = rpc.oraclessamples(globals()["oracle_{}".format("D")],
                                batonaddr_D, "1")
    assert "['01']" == str(result["samples"][0]['data'])

    # checking data for c type
    result = rpc.oraclessamples(globals()["oracle_{}".format("c")],
                                batonaddr_c, "1")
    assert "['-1']" == str(result["samples"][0]['data'])

    # checking data for C type
    result = rpc.oraclessamples(globals()["oracle_{}".format("C")],
                                batonaddr_C, "1")
    assert "['255']" == str(result["samples"][0]['data'])

    # checking data for t type
    result = rpc.oraclessamples(globals()["oracle_{}".format("t")],
                                batonaddr_t, "1")
    assert "['-1']" == str(result["samples"][0]['data'])

    # checking data for T type
    result = rpc.oraclessamples(globals()["oracle_{}".format("T")],
                                batonaddr_T, "1")
    assert "['65535']" == str(result["samples"][0]['data'])

    # checking data for i type
    result = rpc.oraclessamples(globals()["oracle_{}".format("i")],
                                batonaddr_i, "1")
    assert "['-1']" == str(result["samples"][0]['data'])

    # checking data for I type
    result = rpc.oraclessamples(globals()["oracle_{}".format("I")],
                                batonaddr_I, "1")
    assert "['4294967295']" == str(result["samples"][0]['data'])

    # checking data for l type
    result = rpc.oraclessamples(globals()["oracle_{}".format("l")],
                                batonaddr_l, "1")
    assert "['-4294967296']" == str(result["samples"][0]['data'])

    # checking data for L type
    result = rpc.oraclessamples(globals()["oracle_{}".format("L")],
                                batonaddr_L, "1")
    assert "['18446744069414584320']" == str(result["samples"][0]['data'])

    # checking data for h type
    result = rpc.oraclessamples(globals()["oracle_{}".format("h")],
                                batonaddr_h, "1")
    assert "['ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000']" == str(
        result["samples"][0]['data'])

    # checking data for Ihh type
    result = rpc.oraclessamples(globals()["oracle_{}".format("Ihh")],
                                batonaddr_Ihh, "1")
    assert "['4294967295', 'ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000', 'ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000']" == str(
        result["samples"][0]['data'])
def test_faucet():

    # test params inits
    with open('test_config.json', 'r') as f:
        params_dict = json.load(f)

    node1_params = params_dict["node1"]
    node2_params = params_dict["node2"]

    rpc = rpc_connect(node1_params["rpc_user"], node1_params["rpc_password"],
                      node1_params["rpc_ip"], node1_params["rpc_port"])
    rpc1 = rpc_connect(node2_params["rpc_user"], node2_params["rpc_password"],
                       node2_params["rpc_ip"], node2_params["rpc_port"])
    pubkey = node1_params["pubkey"]
    pubkey1 = node2_params["pubkey"]

    is_fresh_chain = params_dict["is_fresh_chain"]

    result = rpc.rewardsaddress()
    for x in result.keys():
        if x.find('ddress') > 0:
            assert result[x][0] == 'R'

    result = rpc.rewardsaddress(pubkey)
    for x in result.keys():
        if x.find('ddress') > 0:
            assert result[x][0] == 'R'

    # no rewards yet
    if is_fresh_chain:
        result = rpc.rewardslist()
        assert result == []

    # looking up non-existent reward should return error
    result = rpc.rewardsinfo("none")
    assert_error(result)

    # creating rewards plan with name > 8 chars, should return error
    result = rpc.rewardscreatefunding("STUFFSTUFF", "7777", "25", "0", "10",
                                      "10")
    assert_error(result)

    # creating rewards plan with 0 funding
    result = rpc.rewardscreatefunding("STUFF", "0", "25", "0", "10", "10")
    assert_error(result)

    # creating rewards plan with 0 maxdays
    result = rpc.rewardscreatefunding("STUFF", "7777", "25", "0", "10", "0")
    assert_error(result)

    # creating rewards plan with > 25% APR
    result = rpc.rewardscreatefunding("STUFF", "7777", "30", "0", "10", "10")
    assert_error(result)

    # creating valid rewards plan
    plan_name = generate_random_string(6)
    result = rpc.rewardscreatefunding(plan_name, "7777", "25", "0", "10", "10")
    assert result['hex'], 'got raw xtn'
    fundingtxid = send_and_mine(result['hex'], rpc)
    assert fundingtxid, 'got txid'
    result = rpc.rewardsinfo(fundingtxid)
    assert_success(result)
    assert result['name'] == plan_name
    assert result['APR'] == "25.00000000"
    assert result['minseconds'] == 0
    assert result['maxseconds'] == 864000
    assert result['funding'] == "7777.00000000"
    assert result['mindeposit'] == "10.00000000"
    assert result['fundingtxid'] == fundingtxid

    # checking if new plan in rewardslist
    result = rpc.rewardslist()
    assert fundingtxid in result

    # creating reward plan with already existing name, should return error
    result = rpc.rewardscreatefunding(plan_name, "7777", "25", "0", "10", "10")
    assert_error(result)

    # add funding amount must be positive
    result = rpc.rewardsaddfunding(plan_name, fundingtxid, "-1")
    assert_error(result)

    # add funding amount must be positive
    result = rpc.rewardsaddfunding(plan_name, fundingtxid, "0")
    assert_error(result)

    # adding valid funding
    result = rpc.rewardsaddfunding(plan_name, fundingtxid, "555")
    addfundingtxid = send_and_mine(result['hex'], rpc)
    assert addfundingtxid, 'got funding txid'

    # checking if funding added to rewardsplan
    result = rpc.rewardsinfo(fundingtxid)
    assert result['funding'] == "8332.00000000"

    # trying to lock funds, locking funds amount must be positive
    result = rpc.rewardslock(plan_name, fundingtxid, "-5")
    assert_error(result)

    # trying to lock funds, locking funds amount must be positive
    result = rpc.rewardslock(plan_name, fundingtxid, "0")
    assert_error(result)

    # trying to lock less than the min amount is an error
    result = rpc.rewardslock(plan_name, fundingtxid, "7")
    assert_error(result)

    # locking funds in rewards plan
    result = rpc.rewardslock(plan_name, fundingtxid, "10")
    assert_success(result)
    locktxid = result['hex']
    assert locktxid, "got lock txid"

    # locktxid has not been broadcast yet
    result = rpc.rewardsunlock(plan_name, fundingtxid, locktxid)
    assert_error(result)

    # broadcast xtn
    txid = rpc.sendrawtransaction(locktxid)
    assert txid, 'got txid from sendrawtransaction'

    # confirm the xtn above
    wait_some_blocks(rpc, 1)

    # will not unlock since reward amount is less than tx fee
    result = rpc.rewardsunlock(plan_name, fundingtxid, locktxid)
    assert_error(result)
示例#20
0
def test_oracles(test_params):

    # test params inits
    rpc = test_params.get('node1').get('rpc')
    rpc1 = test_params.get('node2').get('rpc')

    pubkey = test_params.get('node1').get('pubkey')
    pubkey1 = test_params.get('node2').get('pubkey')

    is_fresh_chain = test_params.get("is_fresh_chain")

    result = rpc.oraclesaddress()
    assert_success(result)

    for x in result.keys():
        if x.find('ddress') > 0:
            assert result[x][0] == 'R'

    result = rpc.oraclesaddress(pubkey)
    assert_success(result)

    for x in result.keys():
        if x.find('ddress') > 0:
            assert result[x][0] == 'R'

    # there are no oracles created yet
    if is_fresh_chain:
        result = rpc.oracleslist()
        assert result == []

    # looking up non-existent oracle should return error.
    result = rpc.oraclesinfo("none")
    assert_error(result)

    # attempt to create oracle with not valid data type should return error
    result = rpc.oraclescreate("Test", "Test", "Test")
    assert_error(result)

    # attempt to create oracle with description > 32 symbols should return error
    too_long_name = generate_random_string(33)
    result = rpc.oraclescreate(too_long_name, "Test", "s")
    assert_error(result)

    # attempt to create oracle with description > 4096 symbols should return error
    too_long_description = generate_random_string(4100)
    result = rpc.oraclescreate("Test", too_long_description, "s")
    assert_error(result)

    # valid creating oracles of different types
    # using such naming to re-use it for data publishing / reading (e.g. oracle_s for s type)
    print(len(rpc.listunspent()))
    # enable mining
    valid_formats = [
        "s", "S", "d", "D", "c", "C", "t", "T", "i", "I", "l", "L", "h", "Ihh"
    ]
    for f in valid_formats:
        result = rpc.oraclescreate("Test_" + f, "Test_" + f, f)
        assert_success(result)
        # globals()["oracle_{}".format(f)] = rpc.sendrawtransaction(result['hex'])
        globals()["oracle_{}".format(f)] = send_and_mine(result['hex'], rpc)

    list_fund_txid = []
    for f in valid_formats:
        # trying to register with negative datafee
        result = rpc.oraclesregister(globals()["oracle_{}".format(f)], "-100")
        assert_error(result)

        # trying to register with zero datafee
        result = rpc.oraclesregister(globals()["oracle_{}".format(f)], "0")
        assert_error(result)

        # trying to register with datafee less than txfee
        result = rpc.oraclesregister(globals()["oracle_{}".format(f)], "500")
        assert_error(result)

        # trying to register valid (unfunded)
        result = rpc.oraclesregister(globals()["oracle_{}".format(f)], "10000")
        assert_error(result)

        # Fund the oracles
        result = rpc.oraclesfund(globals()["oracle_{}".format(f)])
        assert_success(result)
        fund_txid = rpc.sendrawtransaction(result["hex"])
        list_fund_txid.append(fund_txid)
        assert fund_txid, "got txid"

    wait_some_blocks(rpc, 2)

    for t in list_fund_txid:
        c = 0
        print("Waiting confiramtions for oraclesfund")
        while c < 2:
            try:
                c = rpc.getrawtransaction(t, 1)['confirmations']
            except KeyError:
                time.sleep(29)
        print("Oracles fund confirmed \n", t)

    for f in valid_formats:
        # trying to register valid (funded)
        result = rpc.oraclesregister(globals()["oracle_{}".format(f)],
                                     "100000")
        assert_success(result)
        print("Registering ", f)
        register_txid = rpc.sendrawtransaction(result["hex"])
        assert register_txid, "got txid"

        # TODO: for most of the non valid oraclesregister and oraclessubscribe transactions generating and broadcasting now
        # so trying only valid oraclessubscribe atm
        result = rpc.oraclessubscribe(globals()["oracle_{}".format(f)], pubkey,
                                      "1")
        assert_success(result)
        subscribe_txid = rpc.sendrawtransaction(result["hex"])
        assert register_txid, "got txid"

    wait_some_blocks(rpc, 2)

    # now lets publish and read valid data for each oracle type

    # recording data for s type
    result = rpc.oraclesdata(globals()["oracle_{}".format("s")],
                             "05416e746f6e")
    assert_success(result)
    oraclesdata_s = rpc.sendrawtransaction(result["hex"])
    info_s = rpc.oraclesinfo(globals()["oracle_{}".format("s")])
    batonaddr_s = info_s['registered'][0]['baton']

    # recording data for S type
    result = rpc.oraclesdata(
        globals()["oracle_{}".format("S")],
        "000161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161"
    )
    assert_success(result)
    oraclesdata_S = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("S")])
    batonaddr_S = info['registered'][0]['baton']

    # recording data for d type
    result = rpc.oraclesdata(globals()["oracle_{}".format("d")], "0101")
    assert_success(result)
    # baton
    oraclesdata_d = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("d")])
    batonaddr_d = info['registered'][0]['baton']

    # recording data for D type
    result = rpc.oraclesdata(globals()["oracle_{}".format("D")], "010001")
    assert_success(result)
    # baton
    oraclesdata_D = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("D")])
    batonaddr_D = info['registered'][0]['baton']

    # recording data for c type
    result = rpc.oraclesdata(globals()["oracle_{}".format("c")], "ff")
    assert_success(result)
    # baton
    oraclesdata_c = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("c")])
    batonaddr_c = info['registered'][0]['baton']

    # recording data for C type
    result = rpc.oraclesdata(globals()["oracle_{}".format("C")], "ff")
    assert_success(result)
    # baton
    oraclesdata_C = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("C")])
    batonaddr_C = info['registered'][0]['baton']

    # recording data for t type
    result = rpc.oraclesdata(globals()["oracle_{}".format("t")], "ffff")
    assert_success(result)
    # baton
    oraclesdata_t = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("t")])
    batonaddr_t = info['registered'][0]['baton']

    # recording data for T type
    result = rpc.oraclesdata(globals()["oracle_{}".format("T")], "ffff")
    assert_success(result)
    # baton
    oraclesdata_T = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("T")])
    batonaddr_T = info['registered'][0]['baton']

    # recording data for i type
    result = rpc.oraclesdata(globals()["oracle_{}".format("i")], "ffffffff")
    assert_success(result)
    # baton
    oraclesdata_i = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("i")])
    batonaddr_i = info['registered'][0]['baton']

    # recording data for I type
    result = rpc.oraclesdata(globals()["oracle_{}".format("I")], "ffffffff")
    assert_success(result)
    # baton
    oraclesdata_I = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("I")])
    batonaddr_I = info['registered'][0]['baton']

    # recording data for l type
    result = rpc.oraclesdata(globals()["oracle_{}".format("l")],
                             "00000000ffffffff")
    assert_success(result)
    # baton
    oraclesdata_l = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("l")])
    batonaddr_l = info['registered'][0]['baton']

    # recording data for L type
    result = rpc.oraclesdata(globals()["oracle_{}".format("L")],
                             "00000000ffffffff")
    assert_success(result)
    # baton
    oraclesdata_L = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("L")])
    batonaddr_L = info['registered'][0]['baton']

    # recording data for h type
    result = rpc.oraclesdata(
        globals()["oracle_{}".format("h")],
        "00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff")
    assert_success(result)
    # baton
    oraclesdata_h = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("h")])
    batonaddr_h = info['registered'][0]['baton']

    # recording data for Ihh type
    result = rpc.oraclesdata(
        globals()["oracle_{}".format("Ihh")],
        "ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff"
    )
    assert_success(result)
    # baton
    oraclesdata_Ihh = rpc.sendrawtransaction(result["hex"])
    info = rpc.oraclesinfo(globals()["oracle_{}".format("Ihh")])
    batonaddr_Ihh = info['registered'][0]['baton']

    wait_some_blocks(rpc, 1)

    # checking data for s type
    result = rpc.oraclessamples(globals()["oracle_{}".format("s")],
                                batonaddr_s, "1")
    assert "['Anton']" == str(result["samples"][0]['data'])

    # checking data for S type
    result = rpc.oraclessamples(globals()["oracle_{}".format("S")],
                                batonaddr_S, "1")
    assert "['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']" == str(
        result["samples"][0]['data'])

    # checking data for d type
    result = rpc.oraclessamples(globals()["oracle_{}".format("d")],
                                batonaddr_d, "1")
    assert "['01']" == str(result["samples"][0]['data'])

    # checking data for D type
    result = rpc.oraclessamples(globals()["oracle_{}".format("D")],
                                batonaddr_D, "1")
    assert "['01']" == str(result["samples"][0]['data'])

    # checking data for c type
    result = rpc.oraclessamples(globals()["oracle_{}".format("c")],
                                batonaddr_c, "1")
    assert "['-1']" == str(result["samples"][0]['data'])

    # checking data for C type
    result = rpc.oraclessamples(globals()["oracle_{}".format("C")],
                                batonaddr_C, "1")
    assert "['255']" == str(result["samples"][0]['data'])

    # checking data for t type
    result = rpc.oraclessamples(globals()["oracle_{}".format("t")],
                                batonaddr_t, "1")
    assert "['-1']" == str(result["samples"][0]['data'])

    # checking data for T type
    result = rpc.oraclessamples(globals()["oracle_{}".format("T")],
                                batonaddr_T, "1")
    assert "['65535']" == str(result["samples"][0]['data'])

    # checking data for i type
    result = rpc.oraclessamples(globals()["oracle_{}".format("i")],
                                batonaddr_i, "1")
    assert "['-1']" == str(result["samples"][0]['data'])

    # checking data for I type
    result = rpc.oraclessamples(globals()["oracle_{}".format("I")],
                                batonaddr_I, "1")
    assert "['4294967295']" == str(result["samples"][0]['data'])

    # checking data for l type
    result = rpc.oraclessamples(globals()["oracle_{}".format("l")],
                                batonaddr_l, "1")
    assert "['-4294967296']" == str(result["samples"][0]['data'])

    # checking data for L type
    result = rpc.oraclessamples(globals()["oracle_{}".format("L")],
                                batonaddr_L, "1")
    assert "['18446744069414584320']" == str(result["samples"][0]['data'])

    # checking data for h type
    result = rpc.oraclessamples(globals()["oracle_{}".format("h")],
                                batonaddr_h, "1")
    assert "['ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000']" == str(
        result["samples"][0]['data'])

    # checking data for Ihh type
    result = rpc.oraclessamples(globals()["oracle_{}".format("Ihh")],
                                batonaddr_Ihh, "1")
    assert "['4294967295', 'ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000', 'ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000']" == str(
        result["samples"][0]['data'])
示例#21
0
 def authenticate(self):
     if not self.secret:
         self.secret = util.generate_random_string()
     if not self.session:
         self._challenge_server()
     return self.secret
示例#22
0
 def __init__(self, tab_name, parent):
     self.id = util.generate_random_string()
     self.tab_name = tab_name
     self.parent = parent
     self.page = None
示例#23
0
 def authenticate(self):
     if not self.secret:
         self.secret = util.generate_random_string()
     if not self.session:
         self._challenge_server()
     return self.secret
示例#24
0
def test_dice(test_params):

    # test params inits
    rpc = test_params.get('node1').get('rpc')
    rpc1 = test_params.get('node2').get('rpc')

    pubkey = test_params.get('node1').get('pubkey')
    pubkey1 = test_params.get('node2').get('pubkey')

    is_fresh_chain = test_params.get("is_fresh_chain")

    # second node should have some balance to place bets
    result = rpc1.getbalance()
    assert result > 99

    result = rpc.diceaddress()
    assert result['result'] == 'success'

    for x in result.keys():
        if x.find('ddress') > 0:
            assert result[x][0] == 'R'

    result = rpc.diceaddress(pubkey)
    for x in result.keys():
        print(x + ": " + str(result[x]))
    assert result['result'] == 'success'

    for x in result.keys():
        if x.find('ddress') > 0:
            assert result[x][0] == 'R'

    # no dice created yet
    if is_fresh_chain:
        result = rpc.dicelist()
        assert result == []

    # set dice name for futher usage
    dicename = generate_random_string(5)

    # creating dice plan with too long name (>8 chars)
    result = rpc.dicefund("THISISTOOLONG", "10000", "10", "10000", "10", "5")
    assert_error(result)

    # creating dice plan with < 100 funding
    result = rpc.dicefund(dicename, "10", "1", "10000", "10", "5")
    assert_error(result)

    # creating dice plan with 0 blocks timeout
    result = rpc.dicefund(dicename, "10", "1", "10000", "10", "0")
    assert_error(result)

    # creating dice plan
    dicefundtx = rpc.dicefund(dicename, "1000", "1", "800", "10", "5")
    diceid = send_and_mine(dicefundtx['hex'], rpc)

    # checking if it in plans list now
    result = rpc.dicelist()
    assert diceid in result

    # adding zero funds to plan
    result = rpc.diceaddfunds(dicename, diceid, "0")
    assert_error(result)

    # adding negative funds to plan
    result = rpc.diceaddfunds(dicename, diceid, "-1")
    assert_error(result)

    # adding funds to plan
    addfundstx = rpc.diceaddfunds(dicename, diceid, "1100")
    result = send_and_mine(addfundstx['hex'], rpc)

    # checking if funds added to plan
    result = rpc.diceinfo(diceid)
    assert result["funding"] == "2100.00000000"

    # not valid dice info checking
    result = rpc.diceinfo("invalid")
    assert_error(result)

    # placing 0 amount bet
    result = rpc1.dicebet(dicename, diceid, "0", "2")
    assert_error(result)

    # placing negative amount bet
    result = rpc1.dicebet(dicename, diceid, "-1", "2")
    assert_error(result)

    # placing bet more than maxbet
    result = rpc1.dicebet(dicename, diceid, "900", "2")
    assert_error(result)

    # placing bet with amount more than funding
    result = rpc1.dicebet(dicename, diceid, "3000", "2")
    assert_error(result)

    # placing bet with potential won more than funding
    result = rpc1.dicebet(dicename, diceid, "750", "9")
    assert_error(result)

    # placing 0 odds bet
    result = rpc1.dicebet(dicename, diceid, "1", "0")
    assert_error(result)

    # placing negative odds bet
    result = rpc1.dicebet(dicename, diceid, "1", "-1")
    assert_error(result)

    # placing bet with odds more than allowed
    result = rpc1.dicebet(dicename, diceid, "1", "11")
    assert_error(result)

    # placing bet with not correct dice name
    result = rpc1.dicebet("nope", diceid, "100", "2")
    assert_error(result)

    # placing bet with not correct dice id
    result = rpc1.dicebet(dicename, pubkey, "100", "2")
    assert_error(result)