Esempio n. 1
0
 def test_betting_market_group_create(self):
     op = operations.Betting_market_group_create(
         **{
             "fee": {
                 "amount": 0,
                 "asset_id": "1.3.0"
             },
             "event_id": "1.0.1241",
             "options": [2, {
                 "score": 100
             }],
             "prefix": prefix,
         })
     ops = [Operation(op)]
     tx = Signed_Transaction(ref_block_num=ref_block_num,
                             ref_block_prefix=ref_block_prefix,
                             expiration=expiration,
                             operations=ops)
     tx = tx.sign([wif], chain=prefix)
     tx.verify([PrivateKey(wif).pubkey], prefix)
     txWire = hexlify(bytes(tx)).decode("ascii")
     compare = ("f68585abf4dce7c804570131000000000000000000d904000"
                "0000000010264000000000001206e69065a3cd673843f4a66"
                "000d7143b2a10f27015d4c49600ffb5c94f6fc95fe40f3577"
                "264b9288b44e4fe3e0aa5397d1c7973054cc55c6bb611c23b"
                "397f5bb0")
     self.assertEqual(compare[:-130], txWire[:-130])
Esempio n. 2
0
    def betting_market_group_create(self,
                                    type,
                                    margin=0,
                                    score=0,
                                    event_id="0.0.0",
                                    account=None):
        """ Create an betting market. This needs to be **proposed**.

            :param str type: One of ``moneyline``, ``spread``, ``overunder``
            :param str event_id: Event ID to create the competitors for (defaults to *relative* id ``0.0.0``)
            :param int margin: Margin for ``spread`` types
            :param int score: Score for ``overunder`` types
            :param str account: (optional) the account to allow access
                to (defaults to ``default_account``)
        """
        assert self.proposer, "'betting_market_create' needs to be proposed"
        assert type in ["moneyline", "spread", "overunder"], "invalid type"
        if not account:
            if "default_account" in config:
                account = config["default_account"]
        if not account:
            raise ValueError("You need to provide an account")
        account = Account(account)

        if type == "moneyline":
            options = [0, {}]
        elif type == "spread":
            options = [1, {"margin": margin}]
        elif type == "overunder":
            options = [2, {"score": score}]

        op = operations.Betting_market_group_create(
            **{
                "fee": {
                    "amount": 0,
                    "asset_id": "1.3.0"
                },
                "event_id": event_id,
                "options": options,
                "prefix": self.rpc.chain_params["prefix"]
            })
        return self.finalizeOp(op, account["name"], "active")
Esempio n. 3
0
 def test_betting_market_group_create(self):
     self.op = operations.Betting_market_group_create(
         **{
             "fee": {
                 "amount": 0,
                 "asset_id": "1.3.0"
             },
             "description": [["en", "Football"], ["de", "Fußball"]],
             "event_id": "1.0.1241",
             "rules_id": "1.22.11",
             "asset_id": "1.3.124",
             "prefix": prefix,
         })
     self.cm = ("f68585abf4dce7c8045701370000000000000000000202646"
                "5084675c39f62616c6c02656e08466f6f7462616c6cd90400"
                "00000000010b000000000016017c0000011f2603de0504424"
                "dfab0b120e4a258ffe15ee5be333ce8e1404986ea10f1d28e"
                "e033ae6b3d2eea9202b4a18bf3e3bff6ae5ddfe3b4b9d7713"
                "fb2ec11f123eaaa39")
     self.doit()
 def test_betting_market_group_create(self):
     self.op = operations.Betting_market_group_create(
         **{
             "fee": {
                 "amount": 0,
                 "asset_id": "1.3.0"
             },
             "description": [["en", "Football"], ["de", "Fußball"]],
             "event_id": "1.0.1241",
             "rules_id": "1.22.11",
             "asset_id": "1.3.124",
             "never_in_play": False,
             "delay_before_settling": 60,
             "prefix": prefix,
         })
     self.cm = ("f68585abf4dce7c80457013c0000000000000000000202646"
                "5084675c39f62616c6c02656e08466f6f7462616c6cd90400"
                "00000000010b000000000016017c003c000000000001204a5"
                "182e5c97b042a61b743eae2f3dc91bfbd323b34043d6a0c5c"
                "fc06fffbb7837648447501de8cdd214eb1e55eabd394cb4af"
                "152c9846f1819ec0b483fa2d275")
     self.doit()
Esempio n. 5
0
    def betting_market_group_create(self,
                                    description,
                                    event_id="0.0.0",
                                    rules_id="0.0.0",
                                    asset=None,
                                    account=None):
        """ Create an betting market. This needs to be **proposed**.

            :param list description: Internationalized list of descriptions
            :param str event_id: Event ID to create this for (defaults to *relative* id ``0.0.0``)
            :param str rule_id: Rule ID to create this with (defaults to *relative* id ``0.0.0``)
            :param peerplays.asset.Asset asset: Asset to be used for this market
            :param str account: (optional) the account to allow access
                to (defaults to ``default_account``)
        """
        assert self.proposer, "'betting_market_create' needs to be proposed"
        if not asset:
            asset = self.rpc.chain_params["core_symbol"]
        if not account:
            if "default_account" in config:
                account = config["default_account"]
        if not account:
            raise ValueError("You need to provide an account")
        account = Account(account, peerplays_instance=self)
        asset = Asset(asset, peerplays_instance=self)
        op = operations.Betting_market_group_create(
            **{
                "fee": {
                    "amount": 0,
                    "asset_id": "1.3.0"
                },
                "description": description,
                "event_id": event_id,
                "rules_id": rules_id,
                "asset_id": asset["id"],
                "prefix": self.rpc.chain_params["prefix"]
            })
        return self.finalizeOp(op, account["name"], "active")
 def test_betting_market_group_create(self):
     self.op = operations.Betting_market_group_create(
         **{
             "fee": {"amount": 0, "asset_id": "1.3.0"},
             "description": [["en", "Football"], ["de", "Fußball"]],
             "event_id": "1.0.1241",
             "rules_id": "1.22.11",
             "asset_id": "1.3.124",
             "never_in_play": False,
             "delay_before_settling": 60,
             "resolution_constraint": "exactly_one_winner",
             "prefix": prefix,
         }
     )
     self.cm = (
         "f68585abf4dce7c80457013c0000000000000000000202646"
         "5084675c39f62616c6c02656e08466f6f7462616c6cd90400"
         "00000000010b000000000016017c003c00000000000120125"
         "d5aeb51a33e6e62a5383f7cf38e6761ee42abfebbfe6c34e1"
         "059bce54e3da2e9af8ae51662f2281435ae7be8880c88b0c2"
         "94eae0e840c39ab6de29435ef02"
     )
     self.doit(0)