Esempio n. 1
0
def test_capture_handles_unknown_templates():
    parties = list('ABC')
    capture = LedgerCapture()
    capture.capture('A', ContractId('0:0',
                                    template_id='some_unknown_template'),
                    dict(some_field='some_value'), datetime.utcnow())

    lines = fmt_pretty.format_entries(capture, parties)
    output = '\n'.join(lines) + '\n'
    assert output, 'some lines of output expected'
    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)
Esempio n. 3
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
Esempio n. 4
0
def test_choice_meta_deconstructed(subtests):
    for test_name, Sample in codegen_backends().items():
        with subtests.test(test_name):
            cid = ContractId('1:0')
            command = exercise(cid, Sample.Archive, {})
            assert command.choice == 'Archive'