How to use the schema.commands_pb2.Command function in schema

To help you get started, we’ve selected a few schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / iroha-python / tests / helper / test_stateless_validator.py View on Github external
def test_stateless_validator_create_asset(self):
        create_as = Command(
            create_asset = Command.CreateAsset(
                asset_name="yen",
                domain_id="ichigo.mashimaro",
                precision=3
            )
        )
        self.assertTrue(stateless_validator.command(create_as))
github hyperledger / iroha-python / tests / helper / test_stateless_validator.py View on Github external
def test_stateless_validator_set_account_quorum(self):
        set_ac_q = Command(
            set_account_quorum = Command.SetAccountQuorum(
                account_id = "rihito@light.wing",
                quorum = 100
            )
        )
        self.assertTrue(stateless_validator.command(set_ac_q))
        set_ac_q = Command(
            set_account_quorum = Command.SetAccountQuorum(
                account_id = "rihito@light.wing",
                quorum = 0
            )
        )
        self.assertFalse(stateless_validator.command(set_ac_q))
github hyperledger / iroha-python / tests / helper / test_stateless_validator.py View on Github external
def test_stateless_validator_true(self):
        logger.debug("test_create_account")
        create_ac = Command.CreateAccount(
            account_name = "rihito",
            domain_id = "light.wing",
            main_pubkey = self.keypair.public_key
        )
        payload = Transaction.Payload(
            commands = [
                Command(create_account = create_ac)
            ],
            creator_account_id = self.creator,
            tx_counter = self.tx_counter,
            created_time = crypto.now()
        )

        tx = Transaction(
            payload = payload,
            signatures = [
                Signature(
                    pubkey = self.keypair.public_key,
                    signature = crypto.sign(self.keypair,crypto.sign_hash(payload))
                )
            ]
        )
        self.assertTrue(stateless_validator.verify(tx))
github hyperledger / iroha-python / tests / helper / test_stateless_validator.py View on Github external
create_account = Command.CreateAccount(
                account_name = "rihito",
                domain_id = "light.wing",
                main_pubkey = self.keypair.public_key
            )
        )
        self.assertTrue(stateless_validator.command(create_ac))
        create_ac = Command(
            create_account = Command.CreateAccount(
                account_name = "rihitoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",
                domain_id = "light.wing",
                main_pubkey = self.keypair.public_key
            )
        )
        self.assertFalse(stateless_validator.command(create_ac))
        create_ac = Command(
            create_account = Command.CreateAccount(
                account_name = "rihito",
                domain_id = "light.wing.a.c.f",
                main_pubkey = self.keypair.public_key
            )
        )
        self.assertTrue(stateless_validator.command(create_ac))
        create_ac = Command(
            create_account = Command.CreateAccount(
                account_name = "rihito",
                domain_id = "light.wing.a*.c.d.e.f.g.sf",
                main_pubkey = self.keypair.public_key
            )
        )
        self.assertFalse(stateless_validator.command(create_ac))
github hyperledger / iroha-python / tests / transaction / test_transaction.py View on Github external
def test_transaction(self):
        logger.debug("test_transaction")
        tx = Transaction()

        keypairs = []
        keypairs.append(crypto.create_key_pair())
        keypairs.append(crypto.create_key_pair())
        keypairs.append(crypto.create_key_pair())

        tx.add_key_pairs(keypairs)
        tx.set_creator_account_id("test@test")


        logger.info("add command")
        tx.add_command(
            Command.AddSignatory(
                account_id = "test@test",
                pubkey = keypairs[0].public_key
            )
        )
        tx.add_command(
            Command.SetAccountQuorum(
                account_id = "test@test",
                quorum = 2
            )
        )


        logger.info("check signatures")
        self.assertEqual(tx.count_signatures(),0)
        tx.sign()
        self.assertEqual(tx.count_signatures(),3)
github hyperledger / iroha-python / tests / transaction / test_command.py View on Github external
def test_wrap_cmd_add_asset_quantity(self):
        add_asset_q = Command(
            add_asset_quantity = Command.AddAssetQuantity(
                account_id="chika@ichigo.mashimaro",
                asset_id="ichigo.mashimaro/yen",
                amount=int2amount(100)
            )
        )
        self.assertEqual(add_asset_q, wrap_cmd(add_asset_q.add_asset_quantity))
github hyperledger / iroha-python / tests / transaction / test_command.py View on Github external
def test_wrap_cmd_create_account(self):
        create_ac = Command(
            create_account = Command.CreateAccount(
                account_name = "rihito",
                domain_id = "light.wing",
                main_pubkey = self.keypair.public_key
            )
        )
        self.assertEqual(create_ac,wrap_cmd(create_ac.create_account))
github hyperledger / iroha-python / iroha / transaction / command.py View on Github external
def wrap_cmd(cmd):
    if type(cmd) == type(Command.CreateAccount()):
        return Command(create_account = cmd)
    elif type(cmd) == type(Command.AddSignatory()):
        return Command(add_signatory = cmd)
    elif type(cmd) == type(Command.RemoveSignatory()):
        return Command(remove_signaotory = cmd)
    elif type(cmd) == type(Command.SetAccountQuorum()):
        return Command(set_account_quorum = cmd)
    elif type(cmd) == type(Command.CreateAsset()):
        return Command(create_asset = cmd)
    elif type(cmd) == type(Command.CreateDomain()):
        return Command(create_domain = cmd)
    elif type(cmd) == type(Command.AddAssetQuantity()):
        return Command(add_asset_quantity = cmd)
    elif type(cmd) == type(Command.TransferAsset()):
        return Command(transfer_asset = cmd)
    # TODO throw except
    logger.warning("Not Command Type")
    return False
github hyperledger / iroha-python / iroha / transaction / command.py View on Github external
def wrap_cmd(cmd):
    if type(cmd) == type(Command.CreateAccount()):
        return Command(create_account = cmd)
    elif type(cmd) == type(Command.AddSignatory()):
        return Command(add_signatory = cmd)
    elif type(cmd) == type(Command.RemoveSignatory()):
        return Command(remove_signaotory = cmd)
    elif type(cmd) == type(Command.SetAccountQuorum()):
        return Command(set_account_quorum = cmd)
    elif type(cmd) == type(Command.CreateAsset()):
        return Command(create_asset = cmd)
    elif type(cmd) == type(Command.CreateDomain()):
        return Command(create_domain = cmd)
    elif type(cmd) == type(Command.AddAssetQuantity()):
        return Command(add_asset_quantity = cmd)
    elif type(cmd) == type(Command.TransferAsset()):
        return Command(transfer_asset = cmd)
    # TODO throw except