# assert_events · Rell standard library · Chromia Docs (concept)

> function assert_ events(expected: ( text , gtv )...): unit Assert that the given events were emitted during the construction of the last block, in the
spec

Source: https://docs.chromia.com/pages/rell-stdlib/-rell-system-library/rell.test/assert_events/

FUNCTION

# assert\_events

```signature
function assert_events(expected: (text, gtv)...): unit
```

Assert that the given events were emitted during the construction of the last block, in the
specified order.

Events are emitted in application code using `op_context.emit_event()`.

#### Example - single event:

##### Application code

Rell

```
operation main() {
    op_context.emit_event("my_message_type", "my_data".to_gtv());
}
```

##### Test code

Rell

```
function test_main() {
    main().run();
    // Assertion passes
    rell.test.assert_events(("my_message_type", "my_data".to_gtv()));
}
function test_main_bad_1() {
    main().run();
    // Assertion fails - wrong message type
    rell.test.assert_events(("other_message_type", "my_data".to_gtv()));
}
function test_main_bad_2() {
    main().run();
    // Assertion fails - wrong message content
    rell.test.assert_events(("my_message_type", "other_data".to_gtv()));
}
```

#### Example - multiple events:

##### Application code

Rell

```
operation main() {
    op_context.emit_event("my_message_type", "my_data".to_gtv());
    op_context.emit_event("other_message_type", "other_data".to_gtv());
}
```

##### Test code

Rell

```
function test_main() {
    main().run();
    // Assertion passes
    rell.test.assert_events(
        ("my_message_type", "my_data".to_gtv()),
        ("other_message_type", "other_data".to_gtv())
    );
}
function test_main_bad() {
    main().run();
    // Assertion fails - event order incorrect
    rell.test.assert_events(
        ("other_message_type", "other_data".to_gtv()),
        ("my_message_type", "my_data".to_gtv())
    );
}
```

To assert a subset of events, or to assert independently of event order, use
`rell.test.get_events()` and make assertions over elements of the returned list.

**Parameters**

* **expected** — expected event sequence

**See Also**

1. [`op_context.emit_event()` - Rell Standard Library](https://docs.chromia.com/pages/rell-stdlib/-rell-system-library/op_context/emit_event/)
2. [`rell.test.get_events()` - Rell Standard Library](https://docs.chromia.com/pages/rell-stdlib/-rell-system-library/rell.test/get_events/)

Since 0.13.0

[View this page on docs.chromia.com](https://docs.chromia.com/pages/rell-stdlib/-rell%20-system%20-library/rell.test/assert_events.html)Generated API reference, mirrored from the live docs
