コード例 #1
0
ファイル: test_dice.py プロジェクト: Alrighttt/komodo
 def dicebet_maincheck(proxy, casino, schema):
     res = proxy.dicebet(casino.get('name'), casino.get('fundingtxid'), casino.get('minbet'), casino.get('maxodds'))
     validate_template(res, schema)
     assert res.get('result') == 'success'
     bettxid = proxy.sendrawtransaction(res.get('hex'))
     mine_and_waitconfirms(bettxid, proxy)
     return bettxid
コード例 #2
0
    def test_channelspayment(self, test_params):
        channelspayment_schema = {
            'type': 'object',
            'properties': {
                'result': {
                    'type': 'string'
                },
                'error': {
                    'type': 'string'
                },
                'hex': {
                    'type': 'string'
                }
            },
            'required': ['result']
        }

        rpc1 = test_params.get('node1').get('rpc')
        pubkey2 = test_params.get('node2').get('pubkey')
        open_txid = self.channelslist_get(rpc1)
        if not open_txid:
            open_txid = self.new_channel(rpc1, pubkey2, '10',
                                         '100000').get('open_txid')
            minpayment = '100000'
        else:
            minpayment = rpc1.channelsinfo(open_txid).get(
                "Denomination (satoshi)")
        res = rpc1.channelspayment(open_txid, minpayment)
        validate_template(res, channelspayment_schema)
        txid = rpc1.sendrawtransaction(res.get('hex'))
        mine_and_waitconfirms(txid, rpc1)
コード例 #3
0
    def test_faucetget(self, test_params):
        faucetget_schema = {
            'type': 'object',
            'properties': {
                'result': {
                    'type': 'string'
                },
                'hex': {
                    'type': 'string'
                },
                'error': {
                    'type': 'string'
                }
            }
        }

        rpc1 = test_params.get('node1').get('rpc')
        node_addr = test_params.get('node1').get('address')
        res = rpc1.faucetget()
        # should return error if faucetget have already been used by pubkey
        validate_template(res, faucetget_schema)
        try:
            fhex = res.get('hex')
            isinstance(fhex, str)
            res = rpc1.decoderawtransaction(fhex)
            vout_fauc = res.get('vout')[1]
            assert node_addr in vout_fauc.get('scriptPubKey').get('addresses')
            assert vout_fauc.get('valueZat') == pow(10,
                                                    8) * vout_fauc.get('value')
        except (KeyError, TypeError, exc.RpcTypeError):
            assert res.get('result') == 'error'
コード例 #4
0
ファイル: test_heir.py プロジェクト: Alrighttt/komodo
    def test_heirfund(self, test_params):
        heirfund_schema = {
            'type': 'object',
            'properties': {
                'result': {
                    'type': 'string'
                },
                'hex': {
                    'type': 'string'
                },
                'error': {
                    'type': 'string'
                }
            },
            'required': ['result']
        }

        rpc1 = test_params.get('node1').get('rpc')
        pubkey1 = test_params.get('node1').get('pubkey')
        amount = '100'
        name = 'heir' + randomstring(5)
        inactivitytime = '20'
        res = rpc1.heirfund(amount, name, pubkey1, inactivitytime, 'testMemo')
        validate_template(res, heirfund_schema)
        txid = rpc1.sendrawtransaction(res.get('hex'))
        mine_and_waitconfirms(txid, rpc1)
コード例 #5
0
ファイル: test_heir.py プロジェクト: Alrighttt/komodo
    def test_heirclaim(self, test_params):
        heirclaim_schema = {
            'type': 'object',
            'properties': {
                'result': {
                    'type': 'string'
                },
                'hex': {
                    'type': 'string'
                },
                'error': {
                    'type': 'string'
                }
            },
            'required': ['result']
        }

        rpc1 = test_params.get('node1').get('rpc')
        # create heir plan to claim
        pubkey1 = test_params.get('node2').get('pubkey')
        amount = '100'
        name = 'heir' + randomstring(5)
        inactivitytime = '120'
        res = rpc1.heirfund(amount, name, pubkey1, inactivitytime, 'testMemo')
        fundtxid = rpc1.sendrawtransaction(res.get('hex'))
        mine_and_waitconfirms(fundtxid, rpc1)

        # Wait inactivitytime and claim funds
        time.sleep(int(inactivitytime))
        print("\n Sleeping for inactivity time")
        res = rpc1.heirclaim(amount, fundtxid)
        validate_template(res, heirclaim_schema)
        claimtxid = rpc1.sendrawtransaction(res.get('hex'))
        mine_and_waitconfirms(claimtxid, rpc1)
コード例 #6
0
ファイル: test_dice.py プロジェクト: Alrighttt/komodo
 def diceaddfunds_maincheck(proxy, amount, fundtxid, schema):
     name = proxy.diceinfo(fundtxid).get('name')
     res = proxy.diceaddfunds(name, fundtxid, amount)
     validate_template(res, schema)
     assert res.get('result') == 'success'
     addtxid = proxy.sendrawtransaction(res.get('hex'))
     mine_and_waitconfirms(addtxid, proxy)
コード例 #7
0
ファイル: test_dexp2p.py プロジェクト: remkrr/spacecoin
    def test_dexrpc_get(self, test_params):
        # check get id
        schema_broadcast = {
            'type': 'object',
            'properties': {
                'timestamp': {
                    'type': 'integer'
                },
                'recvtime': {
                    'type': 'integer'
                },
                'id': {
                    'type': 'integer'
                },
                'tagA': {
                    'type': 'string'
                },
                'tagB': {
                    'type': 'string'
                },
                'senderpub': {
                    'type': 'string'
                },
                'destpub': {
                    'type': 'string'
                },
                'payload': {
                    'type': 'string'
                },
                'hex': {
                    'type': 'integer'
                },
                'amountA': {
                    'type': ['string']
                },
                'amountB': {
                    'type': ['string']
                },
                'priority': {
                    'type': 'integer'
                },
                'error': {
                    'type': 'string'
                },
                'cancelled': {
                    'type': 'integer'
                }
            },
            'required': ['timestamp', 'id', 'tagA', 'tagB', 'payload']
        }

        rpc1 = test_params.get('node1').get('rpc')
        pubkey = rpc1.DEX_stats().get('publishable_pubkey')
        message = randomhex()
        res = rpc1.DEX_broadcast(message, '4', 'BASE', 'REL', pubkey, '10',
                                 '1')
        order_id = str(res.get('id'))
        res = rpc1.DEX_get(order_id)
        validate_template(res, schema_broadcast)  # same response to broadcast
コード例 #8
0
    def test_channelsaddress(self, test_params):
        channelsaddress_schema = {
            'type': 'object',
            'properties': {
                'result': {
                    'type': 'string'
                },
                'error': {
                    'type': 'string'
                },
                'ChannelsCCAddress': {
                    'type': 'string'
                },
                'ChannelsCCBalance': {
                    'type': 'number'
                },
                'ChannelsNormalAddress': {
                    'type': 'string'
                },
                'ChannelsNormalBalance': {
                    'type': 'number'
                },
                'ChannelsCC1of2Address': {
                    'type': 'string'
                },
                'ChannelsCC1of2TokensAddress': {
                    'type': 'string'
                },
                'PubkeyCCaddress(Channels)': {
                    'type': 'string'
                },
                'PubkeyCCbalance(Channels)': {
                    'type': 'number'
                },
                'myCCAddress(Channels)': {
                    'type': 'string'
                },
                'myCCbalance(Channels)': {
                    'type': 'number'
                },
                'myaddress': {
                    'type': 'string'
                },
                'mybalance': {
                    'type': 'number'
                }
            },
            'required': ['result']
        }
        rpc1 = test_params.get('node1').get('rpc')
        pubkey2 = test_params.get('node2').get('pubkey')

        res = rpc1.channelsaddress(pubkey2)
        validate_template(res, channelsaddress_schema)
        for key in res.keys():
            if key.find('ddress') > 0:
                assert validate_raddr_pattern(res.get(key))
コード例 #9
0
 def rewardsaddfunding_maincheck(proxy, fundtxid, schema):
     name = proxy.rewardsinfo(fundtxid).get('name')
     amount = proxy.rewardsinfo(fundtxid).get(
         'mindeposit')  # not related to mindeposit here, just to get amount
     res = proxy.rewardsaddfunding(name, fundtxid, amount)
     validate_template(res, schema)
     assert res.get('result') == 'success'
     txid = proxy.sendrawtransaction(res.get('hex'))
     mine_and_waitconfirms(txid, proxy)
コード例 #10
0
ファイル: test_dice.py プロジェクト: Alrighttt/komodo
    def test_dicelist(self, test_params):
        dicelist_schema = {
            'type': 'array',
            'items': {'type': 'string'}
        }

        rpc1 = test_params.get('node1').get('rpc')
        res = rpc1.dicelist()
        validate_template(res, dicelist_schema)
コード例 #11
0
ファイル: test_dexp2p.py プロジェクト: remkrr/spacecoin
    def test_dexrpc_inbox_broadcast(self, test_params):
        # inbox message broadcast
        schema_broadcast = {
            'type': 'object',
            'properties': {
                'timestamp': {
                    'type': 'integer'
                },
                'recvtime': {
                    'type': 'integer'
                },
                'id': {
                    'type': 'integer'
                },
                'tagA': {
                    'type': 'string'
                },
                'tagB': {
                    'type': 'string'
                },
                'senderpub': {
                    'type': 'string'
                },
                'destpub': {
                    'type': 'string'
                },
                'payload': {
                    'type': 'string'
                },
                'hex': {
                    'type': 'integer'
                },
                'amountA': {
                    'type': ['string']
                },
                'amountB': {
                    'type': ['string']
                },
                'priority': {
                    'type': 'integer'
                },
                'error': {
                    'type': 'string'
                },
                'cancelled': {
                    'type': 'integer'
                }
            },
            'required': ['timestamp', 'id', 'tagA', 'tagB', 'payload']
        }

        rpc1 = test_params.get('node1').get('rpc')
        pubkey = rpc1.DEX_stats().get('publishable_pubkey')
        message = 'testmessage'
        res = rpc1.DEX_broadcast(message, '4', 'inbox', '', pubkey, '', '')
        validate_template(res, schema_broadcast)
コード例 #12
0
ファイル: test_heir.py プロジェクト: Alrighttt/komodo
    def test_heiraddress(self, test_params):
        heiraddress_schema = {
            'type': 'object',
            'properties': {
                'result': {
                    'type': 'string'
                },
                'HeirCCAddress': {
                    'type': 'string'
                },
                'CCbalance': {
                    'type': 'number'
                },
                'HeirNormalAddress': {
                    'type': 'string'
                },
                'HeirCC`1of2`Address': {
                    'type': 'string'
                },
                'HeirCC`1of2`TokensAddress': {
                    'type': 'string'
                },
                'myAddress': {
                    'type': 'string'
                },
                'myCCAddress(Heir)': {
                    'type': 'string'
                },
                'PubkeyCCAddress(Heir)': {
                    'type': 'string'
                },
                'myCCaddress': {
                    'type': 'string'
                },
                'myCCbalance': {
                    'type': 'number'
                },
                'myaddress': {
                    'type': 'string'
                },
                'mybakance': {
                    'type': 'number'
                },
                'error': {
                    'type': 'string'
                }
            },
            'required': ['result']
        }

        rpc1 = test_params.get('node1').get('rpc')
        pubkey1 = test_params.get('node1').get('pubkey')
        res = rpc1.heiraddress(pubkey1)
        validate_template(res, heiraddress_schema)
        assert res.get('result') == 'success'
コード例 #13
0
 def channelslist_get(proxy: object, schema=None) -> str:
     res = proxy.channelslist()
     open_txid = None
     if schema:
         validate_template(res, schema)
     # check dict items returned to find first available channel
     for key in res.keys():
         if validate_tx_pattern(key):
             open_txid = key
             break
     return open_txid
コード例 #14
0
    def test_rewardsaddress(self, test_params):
        rewardsaddress_schema = {
            'type': 'object',
            'properties': {
                'result': {
                    'type': 'string'
                },
                'error': {
                    'type': 'string'
                },
                'RewardsCCAddress': {
                    'type': 'string'
                },
                'RewardsCCBalance': {
                    'type': 'number'
                },
                'RewardsNormalAddress': {
                    'type': 'string'
                },
                'RewardsNormalBalance': {
                    'type': 'number'
                },
                'RewardsCCTokensAddress': {
                    'type': 'string'
                },
                'PubkeyCCaddress(Rewards)': {
                    'type': 'string'
                },
                'PubkeyCCbalance(Rewards)': {
                    'type': 'number'
                },
                'myCCAddress(Rewards)': {
                    'type': 'string'
                },
                'myCCbalance(Rewards)': {
                    'type': 'number'
                },
                'myaddress': {
                    'type': 'string'
                },
                'mybalance': {
                    'type': 'number'
                }
            },
            'required': ['result']
        }

        rpc = test_params.get('node1').get('rpc')
        res = rpc.rewardsaddress()
        validate_template(res, rewardsaddress_schema)
        assert res.get('result') == 'success'
コード例 #15
0
 def un_lock_maincheck(proxy, fundtxid, schema):
     name = proxy.rewardsinfo(fundtxid).get('name')
     amount = proxy.rewardsinfo(fundtxid).get('mindeposit')
     res = proxy.rewardslock(name, fundtxid, amount)
     validate_template(res, schema)
     assert res.get('result') == 'success'
     locktxid = proxy.sendrawtransaction(res.get('hex'))
     mine_and_waitconfirms(locktxid, proxy)
     print('\nWaiting some time to gain reward for locked funds')
     time.sleep(10)
     res = proxy.rewardsunlock(name, fundtxid, locktxid)
     print(res)
     validate_template(res, schema)
     assert res.get('result') == 'error'  # reward is less than txfee atm
コード例 #16
0
ファイル: test_dexp2p.py プロジェクト: remkrr/spacecoin
    def test_dexrpc_streamsub(self, test_params):
        # subscribe to streamed file, single iteration
        schema_streamsub = {
            'type': 'object',
            'properties': {
                'fname': {
                    'type': 'string'
                },
                'senderpub': {
                    'type': 'string'
                },
                'filehash': {
                    'type': 'string'
                },
                'checkhash': {
                    'type': 'string'
                },
                'result': {
                    'type': 'string'
                },
                'id': {
                    'type': 'integer'
                },
                'filesize': {
                    'type': 'integer'
                },
                'fragments': {
                    'type': 'integer'
                },
                'numlocators': {
                    'type': 'integer'
                }
            }
        }

        rpc1 = test_params.get('node1').get('rpc')
        rpc2 = test_params.get('node2').get('rpc')
        filename = 'file_to_stream'
        pubkey = rpc1.DEX_stats().get('publishable_pubkey')
        write_empty_file(filename, 1)
        res = rpc1.DEX_stream(filename, '6')
        assert res.get('result') == 'success'
        time.sleep(15)  # time to broadcast
        res = rpc2.DEX_streamsub(filename, '0', pubkey)
        assert res.get(
            'result') == 'error'  # will always fail with current test setup
        print(res)
        validate_template(res, schema_streamsub)
        if os.path.isfile(filename):
            os.remove(filename)
コード例 #17
0
 def new_rewardsplan(proxy, schema=None):
     name = randomstring(4)
     amount = '250'
     apr = '25'
     mindays = '0'
     maxdays = '10'
     mindeposit = '10'
     res = proxy.rewardscreatefunding(name, amount, apr, mindays, maxdays,
                                      mindeposit)
     if schema:
         validate_template(res, schema)
     assert res.get('result') == 'success'
     txid = proxy.sendrawtransaction(res.get('hex'))
     mine_and_waitconfirms(txid, proxy)
     rewardsplan = {'fundingtxid': txid, 'name': name}
     return rewardsplan
コード例 #18
0
    def test_faucetaddress(self, test_params):
        faucetaddress_schema = {
            'type': 'object',
            'properties': {
                'result': {
                    'type': 'string'
                },
                'FaucetCCAddress': {
                    'type': 'string'
                },
                'FaucetCCBalance': {
                    'type': 'number'
                },
                'FaucetNormalAddress': {
                    'type': 'string'
                },
                'FaucetNormalBalance': {
                    'type': 'number'
                },
                'FaucetCCTokenAddress': {
                    'type': 'string'
                },
                'PubkeyCCaddress(Faucet)': {
                    'type': 'string'
                },
                'PubkeyCCbalance(Faucet)': {
                    'type': 'number'
                },
                'myCCaddress(Faucet)': {
                    'type': 'string'
                },
                'myCCbalance(Faucet)': {
                    'type': 'number'
                },
                'myaddress': {
                    'type': 'string'
                },
                'mybalance': {
                    'type': 'number'
                }
            }
        }

        rpc1 = test_params.get('node1').get('rpc')
        res = rpc1.faucetaddress()
        validate_template(res, faucetaddress_schema)
コード例 #19
0
    def test_faucetfund(self, test_params):
        faucetfund_schema = {
            'type': 'object',
            'properties': {
                'result': {
                    'type': 'string'
                },
                'hex': {
                    'type': 'string'
                },
            }
        }

        rpc1 = test_params.get('node1').get('rpc')
        res = rpc1.faucetfund('10')
        validate_template(res, faucetfund_schema)
        txid = rpc1.sendrawtransaction(res.get('hex'))
        mine_and_waitconfirms(txid, rpc1, 1)
コード例 #20
0
ファイル: test_dexp2p.py プロジェクト: remkrr/spacecoin
    def test_dexrpc_stream(self, test_params):
        # stream file, single iteration
        schema_stream = {
            'type': 'object',
            'properties': {
                'fname': {
                    'type': 'string'
                },
                'senderpub': {
                    'type': 'string'
                },
                'filehash': {
                    'type': 'string'
                },
                'checkhash': {
                    'type': 'string'
                },
                'result': {
                    'type': 'string'
                },
                'id': {
                    'type': 'integer'
                },
                'filesize': {
                    'type': 'integer'
                },
                'fragments': {
                    'type': 'integer'
                },
                'numlocators': {
                    'type': 'integer'
                }
            }
        }

        rpc1 = test_params.get('node1').get('rpc')
        filename = 'file_to_stream'
        write_empty_file(filename, 1)
        res = rpc1.DEX_stream(filename, '6')
        validate_template(res, schema_stream)
        assert res.get('result') == 'success'
        if os.path.isfile(filename):
            os.remove(filename)
コード例 #21
0
    def test_faucetinfo(self, test_params):
        faucetinfo_schema = {
            'type': 'object',
            'properties': {
                'result': {
                    'type': 'string'
                },
                'name': {
                    'type': 'string'
                },
                'funding': {
                    'type': 'string'
                }
            }
        }

        rpc1 = test_params.get('node1').get('rpc')
        res = rpc1.faucetinfo()
        validate_template(res, faucetinfo_schema)
コード例 #22
0
ファイル: test_heir.py プロジェクト: Alrighttt/komodo
    def test_heiradd(self, test_params):
        hieradd_schema = {
            'type': 'object',
            'properties': {
                'result': {
                    'type': 'string'
                },
                'hex': {
                    'type': 'string'
                },
                'error': {
                    'type': 'string'
                }
            },
            'required': ['result']
        }

        rpc1 = test_params.get('node1').get('rpc')
        amount = '100'
        try:
            fundid = rpc1.heirlist()[0]
            res = rpc1.heiradd(amount, fundid)
            validate_template(res, hieradd_schema)
            assert res.get('result') == 'success'
            txid = rpc1.sendrawtransaction(res.get('hex'))
            mine_and_waitconfirms(txid, rpc1)
        except IndexError:
            print('\nNo heirplan on chain, creating one\n')
            pubkey1 = test_params.get('node1').get('pubkey')
            amount = '100'
            name = 'heir' + randomstring(5)
            inactivitytime = '20'
            res = rpc1.heirfund(amount, name, pubkey1, inactivitytime,
                                'testMemoHeirInfo')
            txid = rpc1.sendrawtransaction(res.get('hex'))
            mine_and_waitconfirms(txid, rpc1)
            fundid = rpc1.heirlist()[0]
            res = rpc1.heiradd(amount, fundid)
            validate_template(res, hieradd_schema)
            assert res.get('result') == 'success'
            txid = rpc1.sendrawtransaction(res.get('hex'))
            mine_and_waitconfirms(txid, rpc1)
コード例 #23
0
ファイル: test_dexp2p.py プロジェクト: remkrr/spacecoin
    def test_dexrpc_setpubkey(self, test_params):
        # check setpubkey with random pubkey-like string
        schema_setpub = {
            'type': 'object',
            'properties': {
                'publishable_pubkey': {
                    'type': 'string'
                },
                'perfstats': {
                    'type': 'string'
                },
                'result': {
                    'type': 'string'
                },
                'secpkey': {
                    'type': 'string'
                },
                'recvaddr': {
                    'type': 'string'
                },
                'recvZaddr': {
                    'type': 'string'
                },
                'handle': {
                    'type': 'string'
                },
                'txpowbits': {
                    'type': 'integer'
                },
                'vip': {
                    'type': 'integer'
                },
                'cmdpriority': {
                    'type': 'integer'
                }
            }
        }

        rpc1 = test_params.get('node1').get('rpc')
        res = rpc1.DEX_setpubkey('01' + randomhex())
        validate_template(res, schema_setpub)
        assert res.get('result') == 'success'
コード例 #24
0
 def new_channel(proxy: object,
                 destpubkey: str,
                 numpayments: str,
                 paysize: str,
                 schema=None,
                 tokenid=None) -> dict:
     if tokenid:
         res = proxy.channelsopen(destpubkey, numpayments, paysize, tokenid)
     else:
         res = proxy.channelsopen(destpubkey, numpayments, paysize)
     if schema:
         validate_template(res, schema)
     open_txid = proxy.sendrawtransaction(res.get('hex'))
     mine_and_waitconfirms(open_txid, proxy)
     channel = {
         'open_txid': open_txid,
         'number_of_payments': numpayments,
     }
     if tokenid:
         channel.update({'tokenid': tokenid})
     return channel
コード例 #25
0
ファイル: test_dice.py プロジェクト: Alrighttt/komodo
    def test_diceaddress(self, test_params):
        diceaddress_schema = {
            'type': 'object',
            'properties': {
                'result': {'type': 'string'},
                'DiceCCAddress': {'type': 'string'},
                'DiceCCBalance': {'type': 'number'},
                'DiceNormalAddress': {'type': 'string'},
                'DiceNormalBalance': {'type': 'number'},
                'DiceCCTokensAddress': {'type': 'string'},
                'myCCAddress(Dice)': {'type': 'string'},
                'myCCBalance(Dice)': {'type': 'number'},
                'myaddress': {'type': 'string'},
                'mybalance': {'type': 'number'},
                'error': {'type': 'string'}
            },
            'required': ['result']
        }

        rpc1 = test_params.get('node1').get('rpc')
        pubkey1 = test_params.get('node1').get('pubkey')
        res = rpc1.diceaddress()
        validate_template(res, diceaddress_schema)
        res = rpc1.diceaddress('')
        validate_template(res, diceaddress_schema)
        res = rpc1.diceaddress(pubkey1)
        validate_template(res, diceaddress_schema)
コード例 #26
0
ファイル: test_dexp2p.py プロジェクト: remkrr/spacecoin
    def test_dexrpc_stats(self, test_params):
        schema_stats = {
            'type': 'object',
            'properties': {
                'publishable_pubkey': {
                    'type': 'string'
                },
                'perfstats': {
                    'type': 'string'
                },
                'result': {
                    'type': 'string'
                },
                'secpkey': {
                    'type': 'string'
                },
                'recvaddr': {
                    'type': 'string'
                },
                'recvZaddr': {
                    'type': 'string'
                },
                'handle': {
                    'type': 'string'
                },
                'txpowbits': {
                    'type': 'integer'
                },
                'vip': {
                    'type': 'integer'
                },
                'cmdpriority': {
                    'type': 'integer'
                }
            }
        }

        rpc1 = test_params.get('node1').get('rpc')
        res = rpc1.DEX_stats()
        validate_template(res, schema_stats)
コード例 #27
0
ファイル: test_dexp2p.py プロジェクト: remkrr/spacecoin
    def test_dexrpc_subscribe(self, test_params):
        # subscribe to published file
        schema_publish_subscribe = {
            'type': 'object',
            'properties': {
                'fname': {
                    'type': 'string'
                },
                'result': {
                    'type': 'string'
                },
                'id': {
                    'type': 'integer'
                },
                'senderpub': {
                    'type': 'string'
                },
                'filesize': {
                    'type': 'integer'
                },
                'fragments': {
                    'type': 'integer'
                },
                'numlocators': {
                    'type': 'integer'
                },
                'filehash': {
                    'type': 'string'
                }
            }
        }

        rpc1 = test_params.get('node1').get('rpc')
        pubkey = rpc1.DEX_stats().get('publishable_pubkey')
        file = 'to_publish.txt'
        write_file(file)
        res = rpc1.DEX_subscribe(file, '0', '0', pubkey)
        validate_template(res, schema_publish_subscribe)
        assert res.get('result') == 'success'
コード例 #28
0
ファイル: test_dice.py プロジェクト: Alrighttt/komodo
 def new_casino(proxy, schema=None):
     rpc1 = proxy
     name = randomstring(4)
     funds = '777'
     minbet = '1'
     maxbet = '77'
     maxodds = '10'
     timeoutblocks = '5'
     res = rpc1.dicefund(name, funds, minbet, maxbet, maxodds, timeoutblocks)
     if schema:
         validate_template(res, schema)
     assert res.get('result') == 'success'
     txid = rpc1.sendrawtransaction(res.get('hex'))
     mine_and_waitconfirms(txid, rpc1)
     casino = {
         'fundingtxid': txid,
         'name': name,
         'minbet': minbet,
         'maxbet': maxbet,
         'maxodds': maxodds
     }
     return casino
コード例 #29
0
ファイル: test_heir.py プロジェクト: Alrighttt/komodo
    def test_heirinfo(self, test_params):
        heirinfo_schema = {
            'type': 'object',
            'properties': {
                'name': {
                    'type': 'string'
                },
                'fundingtxid': {
                    'type': 'string'
                },
                'owner': {
                    'type': 'string'
                },
                'tokenid': {
                    'type': 'string'
                },
                'heir': {
                    'type': 'string'
                },
                'type': {
                    'type': 'string'
                },
                'lifetime': {
                    'type': 'string'
                },
                'available': {
                    'type': 'string'
                },
                'OwnerRemainderTokens': {
                    'type': 'string'
                },
                'InactivityTimeSetting': {
                    'type': 'string'
                },
                'IsHeirSpendingAllowed': {
                    'type': 'string'
                },
                'memo': {
                    'type': 'string'
                },
                'result': {
                    'type': 'string'
                },
                'error': {
                    'type': 'string'
                }
            },
            'required': ['result']
        }

        rpc1 = test_params.get('node1').get('rpc')
        try:
            fundid = rpc1.heirlist()[0]
            res = rpc1.heirinfo(fundid)
            validate_template(res, heirinfo_schema)
            assert res.get('result') == 'success'
        except IndexError:
            print('\nNo heirplan on chain, creating one\n')
            pubkey1 = test_params.get('node1').get('pubkey')
            amount = '100'
            name = 'heir' + randomstring(5)
            inactivitytime = '20'
            res = rpc1.heirfund(amount, name, pubkey1, inactivitytime,
                                'testMemoHeirInfo')
            txid = rpc1.sendrawtransaction(res.get('hex'))
            mine_and_waitconfirms(txid, rpc1)
            fundid = rpc1.heirlist()[0]
            res = rpc1.heirinfo(fundid)
            validate_template(res, heirinfo_schema)
            assert res.get('result') == 'success'
コード例 #30
0
 def rewardsinfo_maincheck(proxy, fundtxid, schema):
     res = proxy.rewardsinfo(fundtxid)
     validate_template(res, schema)
     assert res.get('result') == 'success'