# Test the registration · A simple Chromia app with Rell and React · Learn Chromia

> Follow these steps to test the new module:

Source: https://chromia.com/learn/my-news-feed/module-one/register-evm-accounts/test-registration/

A simple Chromia app with Rell and ReactLesson 21 of 27

1. [01Building a simple Chromia app with Rell, React and FT4](https://chromia.com/learn/my-news-feed/introduction/)
2. [02Project setup complete](https://chromia.com/learn/my-news-feed/setup/)

Module 1: A Rell backend with FT accounts

1. [03Overview](https://chromia.com/learn/my-news-feed/module-one/)
2. [04Part 1: Designing the database schema](https://chromia.com/learn/my-news-feed/module-one/data-modeling/)
3. [05The data model](https://chromia.com/learn/my-news-feed/module-one/data-modeling/tables/)
4. [06Code the model in Rell](https://chromia.com/learn/my-news-feed/module-one/data-modeling/model/)
5. [07Part 2: Set up accounts](https://chromia.com/learn/my-news-feed/module-one/create-accounts/)
6. [08FT4 accounts configuration](https://chromia.com/learn/my-news-feed/module-one/create-accounts/install-configure-ft4/)
7. [09Authentication with FT4 accounts](https://chromia.com/learn/my-news-feed/module-one/create-accounts/authentication/)
8. [10Part 3: A closer look at operations and queries](https://chromia.com/learn/my-news-feed/module-one/operations-queries/)
9. [11Basic operations](https://chromia.com/learn/my-news-feed/module-one/operations-queries/basic-operations/)
10. [12Basic queries](https://chromia.com/learn/my-news-feed/module-one/operations-queries/write-queries/)
11. [13Part 4: Validating and verifying input](https://chromia.com/learn/my-news-feed/module-one/input-verification/)
12. [14Verify inputs](https://chromia.com/learn/my-news-feed/module-one/input-verification/input-verification/)
13. [15Run unit tests](https://chromia.com/learn/my-news-feed/module-one/input-verification/tests/)
14. [16Part 5: How the dapp project is organized](https://chromia.com/learn/my-news-feed/module-one/project-structure/)
15. [17Work with Rell modules](https://chromia.com/learn/my-news-feed/module-one/project-structure/modules/)
16. [18Add modules to your dapp](https://chromia.com/learn/my-news-feed/module-one/project-structure/incorporate-modules/)
17. [19Part 6: Sign up users with an EVM wallet](https://chromia.com/learn/my-news-feed/module-one/register-evm-accounts/)
18. [20Sign up accounts with EVM wallets](https://chromia.com/learn/my-news-feed/module-one/register-evm-accounts/register-evm-accounts/)
19. [21Test the registration](https://chromia.com/learn/my-news-feed/module-one/register-evm-accounts/test-registration/)

Module 2: The React project

1. [22Overview](https://chromia.com/learn/my-news-feed/module-two/)
2. [23Set up the project](https://chromia.com/learn/my-news-feed/module-two/setup/)
3. [24Project scaffold](https://chromia.com/learn/my-news-feed/module-two/scaffold/)
4. [25Connect the client](https://chromia.com/learn/my-news-feed/module-two/connecting-the-client/)
5. [26Summary and manual testing](https://chromia.com/learn/my-news-feed/module-two/summary-and-tests/)

1. [27What is next?](https://chromia.com/learn/my-news-feed/what-next/)

[Learn](https://chromia.com/learn/)[A simple Chromia app with Rell and React](https://chromia.com/learn/my-news-feed/)

21 / 27Module 1: A Rell backend with FT accountsBeginner

# Test the registration

Follow these steps to test the new module:

1. Add a test file at `src/test/registration_test.rell`.
2. Register the test module in `chromia.yml` by listing it under the modules:

src/chromia.yml

```
blockchains:
  newschain:
    test:
      modules:
        - test
```

3. Open `registration_test.rell`, add the required imports, and declare the EVM address and private key the tests will use:

src/test/registration\_test.rell

```
@test module;

import registration. { register_user };
import news_feed. { make_post, user, post };
import lib.ft4.accounts. { single_sig_auth_descriptor };
import lib.ft4.auth. { evm_signatures };
import lib.ft4.core.accounts.strategies.open. { ras_open };
import lib.ft4.external.accounts.{ add_auth_descriptor };
import lib.ft4.external.accounts.strategies. { get_register_account_message };
import lib.ft4.test.core.{ ft_auth_operation_for, evm_auth_operation_for, evm_sign };

val evm_address = x"1337c28e95ce85175af66353fecccd676e3d273a";
val evm_privkey = x"18e2d37cd5b51555c52d454c22608dee5e7151384f2d7b7bc21616e2eadc3e6f";
```

4. Add a test case to `registration_test.rell` that registers an account with EVM signatures:

src/test/registration\_test.rell

```
function test_evm_registration() {
    val alice_auth_desc = single_sig_auth_descriptor(evm_address, set(["A", "T"]));
    val alice_session_1 = rell.test.keypairs.alice;
    val session1_auth_desc = single_sig_auth_descriptor(alice_session_1.pub, set(["S"]));

    val strategy_op = ras_open(alice_auth_desc, session1_auth_desc);
    val register_op = register_user("Alice");

    val message = get_register_account_message(
        strategy_op.to_gtx_operation(),
        register_op.to_gtx_operation()
    );
    val signature = evm_sign(message, evm_privkey);
    // Register account using evm address 
    rell.test.tx()
        .op(evm_signatures([evm_address], [signature]))
        .op(strategy_op)
        .op(register_op)
        .sign(alice_session_1)
        .run();

    assert_equals(user @ { } ( @sum 1 ), 1);

    // Make post using session key
    rell.test.tx()
        .op(ft_auth_operation_for(alice_session_1.pub))
        .op(make_post("My first post"))
        .sign(alice_session_1)
        .run();
    assert_equals(post @ { } ( @sum 1 ), 1);
    
    // Start a new session
    val alice_session_2 = rell.test.keypairs.bob;
    val session_auth_desc = single_sig_auth_descriptor(alice_session_2.pub, set(["S"]));
    val add_auth_descriptor_operation = add_auth_descriptor(session_auth_desc);

    // Add session token
    rell.test.tx()
        .op(evm_auth_operation_for(evm_privkey, add_auth_descriptor_operation))
        .op(add_auth_descriptor_operation)
        .sign(alice_session_2)
        .run();

    // Make another post using session key
    rell.test.tx()
        .op(ft_auth_operation_for(alice_session_2.pub))
        .op(make_post("My second post"))
        .sign(alice_session_2)
        .run();
    assert_equals(post @ { } ( @sum 1 ), 2);
}
```

The test mimics a user who signs up with an EVM address and a matching signature. It does the following:

* Builds an authentication descriptor for the EVM key carrying the "A" and "T" flags, which grant administrative and transfer access in the `ft` framework.
* Generates a session keypair and a matching authentication descriptor for Alice (`alice_session_1`).
* Produces the EVM registration signature with `evm_sign`, covering the operations the transaction will call.
* Assembles a transaction containing the `register_account` operations and signs it with Alice's session keypair.
* Checks that the registration succeeded.

### Posting with session keypair

As an extra check, the next test uses the session keypair to create a post:

rell

```
    // Make a post using the session keypair
    rell.test.tx()
        .op(ft_auth_operation_for(alice_session_1.pub))
        .op(make_post("My first post"))
        .sign(alice_session_1)
        .run();
    assert_equals(post @ { } ( @sum 1 ), 1);
```

Here the session keypair signs the transaction, and `ft_auth_operation_for` from the `ft` test module supplies the authentication properties. The test:

* Builds a new transaction, using `ft_auth_operation_for` to add the authentication properties.
* Signs it with Alice's session keypair.
* Checks that the post was created.

### Logging in with a new session keypair

To confirm the behavior holds across logins, the following test simulates a user signing in a second time. The user generates a fresh session keypair and registers it with the dapp through the `ft4.add_auth_descriptor` operation:

rell

```
    // Start a new session
    val alice_session_2 = rell.test.keypairs.bob;
    val session_auth_desc = single_sig_auth_descriptor(alice_session_2.pub, set(["MySession"]));
    val add_auth_descriptor_operation = add_auth_descriptor(session_auth_desc);

    // Add a session token
    rell.test.tx()
        .op(evm_auth_operation_for(evm_privkey, add_auth_descriptor_operation))
        .op(add_auth_descriptor_operation)
        .sign(alice_session_2)
        .run();

    // Make another post using the session key
    rell.test.tx()
        .op(ft_auth_operation_for(alice_session_2.pub))
        .op(make_post("My second post"))
        .sign(alice_session_2)
        .run();
    assert_equals(post @ { } ( @sum 1 ), 2);
```

The test:

* Generates a new session keypair and defines a single-signature auth descriptor with the "MySession" flag.
* Builds a transaction that adds the new session key.
* Signs that transaction with the EVM private key.
* Creates another post and checks that it was created.

warning

When you build the EVM auth operation, you have to reference it by its fully qualified name, including the `ft4.` prefix.

To learn more about how FT4 works, including authentication descriptors and session handling, see the [FT4 Accounts and Tokens documentation](https://docs.chromia.com/build/ft4/intro/).

You now have a module that registers user accounts through an EVM wallet, along with tests that confirm it works.

Written for this site from Chromia’s public course. Code samples are the course’s own.

[← Previous**Sign up accounts with EVM wallets**](https://chromia.com/learn/my-news-feed/module-one/register-evm-accounts/register-evm-accounts/)[Next →**Module 2: The React project**](https://chromia.com/learn/my-news-feed/module-two/)
