def test_serialize_create(self):
        command = CreateCommand('Pending.AccountRequest', dict(owner='SomeParty'))

        expected = G.Command()
        expected.create.template_id.MergeFrom(
            TestProtobufSerialize.get_identifier('Pending.AccountRequest'))
        expected.create.create_arguments.fields.append(
            G.RecordField(label='owner', value=G.Value(party='SomeParty')))
        actual = self.sut.serialize_command(command)

        self.assertEqual(expected, actual)
    def test_serialize_exercise_by_key(self):
        command = ExerciseByKeyCommand('Pending.Counter', 'SomeParty', 'Increment', {})

        expected = G.Command()
        expected.exerciseByKey.template_id.MergeFrom(
            TestProtobufSerialize.get_identifier('Pending.Counter'))
        expected.exerciseByKey.contract_key.party = 'SomeParty'
        expected.exerciseByKey.choice = 'Increment'
        expected.exerciseByKey.choice_argument.record.SetInParent()
        actual = self.sut.serialize_command(command)

        self.assertEqual(expected, actual)
Ejemplo n.º 3
0
def test_serialize_create(dar_fixture):
    sut = ProtobufSerializer(dar_fixture.store)

    command = CreateCommand('Pending.AccountRequest', dict(owner='SomeParty'))

    expected = G.Command()
    expected.create.template_id.MergeFrom(
        dar_fixture.get_identifier('Pending.AccountRequest'))
    expected.create.create_arguments.fields.append(
        G.RecordField(label='owner', value=G.Value(party='SomeParty')))
    actual = sut.serialize_command(command)

    assert expected == actual
Ejemplo n.º 4
0
def test_serialize_exercise_by_key(dar_fixture):
    sut = ProtobufSerializer(dar_fixture.lookup)

    command = ExerciseByKeyCommand("Pending:Counter", "SomeParty", "Increment", {})

    expected = G.Command()
    expected.exerciseByKey.template_id.MergeFrom(dar_fixture.get_identifier("Pending:Counter"))
    expected.exerciseByKey.contract_key.party = "SomeParty"
    expected.exerciseByKey.choice = "Increment"
    expected.exerciseByKey.choice_argument.record.SetInParent()
    actual = sut.serialize_command(command)

    assert expected == actual
Ejemplo n.º 5
0
def test_serialize_create(dar_fixture):
    sut = ProtobufSerializer(dar_fixture.lookup)

    command = CreateCommand("Pending:AccountRequest", dict(owner="SomeParty"))

    expected = G.Command()
    expected.create.template_id.MergeFrom(dar_fixture.get_identifier("Pending:AccountRequest"))
    expected.create.create_arguments.fields.append(
        G.RecordField(label="owner", value=G.Value(party="SomeParty"))
    )
    actual = sut.serialize_command(command)

    assert expected == actual
Ejemplo n.º 6
0
def test_serialize_exercise_by_key(dar_fixture):
    sut = ProtobufSerializer(dar_fixture.store)

    command = ExerciseByKeyCommand('Pending.Counter', 'SomeParty', 'Increment',
                                   {})

    expected = G.Command()
    expected.exerciseByKey.template_id.MergeFrom(
        dar_fixture.get_identifier('Pending.Counter'))
    expected.exerciseByKey.contract_key.party = 'SomeParty'
    expected.exerciseByKey.choice = 'Increment'
    expected.exerciseByKey.choice_argument.record.SetInParent()
    actual = sut.serialize_command(command)

    assert expected == actual
    def test_serialize_create_and_exercise(self):
        command = CreateAndExerciseCommand(
            'Pending.AccountRequest', dict(owner='SomeParty'), 'CreateAccount', dict(accountId=42))

        expected = G.Command()
        expected.createAndExercise.template_id.MergeFrom(
            TestProtobufSerialize.get_identifier('Pending.AccountRequest'))
        expected.createAndExercise.create_arguments.fields.append(
            G.RecordField(label='owner', value=G.Value(party='SomeParty')))
        expected.createAndExercise.choice = 'CreateAccount'
        expected.createAndExercise.choice_argument.record.fields.append(
            G.RecordField(label='accountId', value=G.Value(int64=42)))
        actual = self.sut.serialize_command(command)

        self.assertEqual(expected, actual)
    def test_serialize_exercise(self):
        tref = TestProtobufSerialize.get_template_type('Pending.AccountRequest')
        cid = ContractId('#1:0', tref)
        command = ExerciseCommand(cid, 'CreateAccount', dict(accountId=42))

        expected = G.Command()
        expected.exercise.contract_id = '#1:0'
        expected.exercise.template_id.MergeFrom(
            TestProtobufSerialize.get_identifier('Pending.AccountRequest'))
        expected.exercise.choice = 'CreateAccount'
        expected.exercise.choice_argument.record.fields.append(
            G.RecordField(label='accountId', value=G.Value(int64=42)))
        actual = self.sut.serialize_command(command)

        self.assertEqual(expected, actual)
Ejemplo n.º 9
0
def test_serialize_exercise(dar_fixture):
    sut = ProtobufSerializer(dar_fixture.store)

    tref = dar_fixture.get_template_type('Pending.AccountRequest')
    cid = ContractId('#1:0', tref)
    command = ExerciseCommand(cid, 'CreateAccount', dict(accountId=42))

    expected = G.Command()
    expected.exercise.contract_id = '#1:0'
    expected.exercise.template_id.MergeFrom(
        dar_fixture.get_identifier('Pending.AccountRequest'))
    expected.exercise.choice = 'CreateAccount'
    expected.exercise.choice_argument.record.fields.append(
        G.RecordField(label='accountId', value=G.Value(int64=42)))
    actual = sut.serialize_command(command)

    assert expected == actual
Ejemplo n.º 10
0
def test_serialize_exercise(dar_fixture):
    sut = ProtobufSerializer(dar_fixture.lookup)

    tref = dar_fixture.lookup.data_type_name("Pending:AccountRequest")
    cid = ContractId(tref, "#1:0")
    command = ExerciseCommand(cid, "CreateAccount", dict(accountId=42))

    expected = G.Command()
    expected.exercise.contract_id = "#1:0"
    expected.exercise.template_id.MergeFrom(dar_fixture.get_identifier("Pending:AccountRequest"))
    expected.exercise.choice = "CreateAccount"
    expected.exercise.choice_argument.record.fields.append(
        G.RecordField(label="accountId", value=G.Value(int64=42))
    )
    actual = sut.serialize_command(command)

    assert expected == actual
def test_serialize_create_and_exercise(dar_fixture):
    sut = ProtobufSerializer(dar_fixture.store)

    command = CreateAndExerciseCommand('Pending:AccountRequest',
                                       dict(owner='SomeParty'),
                                       'CreateAccount', dict(accountId=42))

    expected = G.Command()
    expected.createAndExercise.template_id.MergeFrom(
        dar_fixture.get_identifier('Pending:AccountRequest'))
    expected.createAndExercise.create_arguments.fields.append(
        G.RecordField(label='owner', value=G.Value(party='SomeParty')))
    expected.createAndExercise.choice = 'CreateAccount'
    expected.createAndExercise.choice_argument.record.fields.append(
        G.RecordField(label='accountId', value=G.Value(int64=42)))
    actual = sut.serialize_command(command)

    assert expected == actual