# Testing · Manage assets with FT4 · Learn Chromia

> This lesson shows you how to test your FT4 asset implementation.

Source: https://chromia.com/learn/ft4-asset/testing/

Manage assets with FT4Lesson 5 of 6

1. [01Asset management](https://chromia.com/learn/ft4-asset/introduction/)
2. [02Project setup and configuration](https://chromia.com/learn/ft4-asset/setup/)
3. [03Asset basics](https://chromia.com/learn/ft4-asset/ft4-basics/)
4. [04Asset functions, operations and queries](https://chromia.com/learn/ft4-asset/asset-operations/)
5. [05Testing](https://chromia.com/learn/ft4-asset/testing/)
6. [06Considerations and recommendations](https://chromia.com/learn/ft4-asset/consideration-recomendations/)

[Learn](https://chromia.com/learn/)[Manage assets with FT4](https://chromia.com/learn/ft4-asset/)

05 / 06Advanced

# Testing

This lesson shows you how to test your FT4 asset implementation.

### 1. End-to-end tests

The test cases are in `src/test/assets_test.rell` in the course [repository](https://bitbucket.org/chromawallet/ft4-course/src/main/). Copy that file into your project's `src/test/` folder.

Run the tests with this command:

bash

```nolines
chr build & chr test
```

### 2. Manual testing on local node

#### Start the node locally

bash

```nolines
chr node start
```

#### Generate keypairs of the test users

Create a key pair for each test user.

Alice:

bash

```nolines
chr keygen --file .chromia/alice_keypair
```

Trudy:

bash

```nolines
chr keygen --file .chromia/trudy_keypair
```

#### Initialize the dapp

Run the initialization with the admin key pair. This creates the pool account. You only need to do it once, and it is not strictly required.

bash

```nolines
chr tx initialize_dapp --secret .chromia/admin_keypair
```

#### Mint initial assets

Mint a starting supply of assets into the pool account:

bash

```nolines
chr tx mint --secret .chromia/admin_keypair
```

You should see output like this:

bash

```nolines
transaction with rid D6A1E290E9E00E25453D182742CB92D6707BD38B89712C8AE6A53EF9452BF55A was posted and confirmed
```

> Note: Each transaction execution produces a different transaction RID.

#### Check pool account balance

Confirm the pool account's balance with:

bash

```nolines
chr query get_pool_account_balance
```

Output:

bash

```nolines
1000000000L
```

#### Create user accounts

Operations require authentication, so each user needs an account.

Alice:

bash

```nolines
chr tx ft4.ras_open '[0, [["A","T"],x"ALICE_PUBKEY"], null]' 'null' --ft-register-account --secret .chromia/alice_keypair --await
```

For details on the auth descriptor's authorization flags, see the
[built-in authorization flags documentation](https://docs.chromia.com/build/ft4/account-management/auth-descriptors/#built-in-authorization-flags).

Trudy:

bash

```nolines
chr tx ft4.ras_open '[0, [["A","T"],x"TRUDY_PUBKEY"], null]' 'null' --ft-register-account --secret .chromia/trudy_keypair --await
```

#### Faucet assets

Request test assets from the faucet.

Alice:

bash

```nolines
chr tx faucet --ft-auth --secret .chromia/alice_keypair
```

Trudy:

bash

```nolines
chr tx faucet --ft-auth --secret .chromia/trudy_keypair
```

#### Transfer assets

Send assets to another account with:

bash

```nolines
chr tx transfer 'x"TRUDY_PUBKEY"' 100L --ft-auth --secret .chromia/alice_keypair
```

#### Lock/Unlock assets

Lock assets on a given account with:

bash

```nolines
chr tx lock_asset "FT4_LOCK" 'x"ALICE_PUBKEY"' 10L --secret .chromia/admin_keypair
```

`FT4_LOCK` is the default
[lock type in FT4](https://docs.chromia.com/build/ft4/backend/assets/locking-assets/#lock-account-overview).

Release locked assets with:

bash

```nolines
chr tx unlock_asset "FT4_LOCK" 'x"ALICE_PUBKEY"' 10L --secret .chromia/admin_keypair
```

#### Check user balances

Query a user's asset balance with:

bash

```nolines
chr query get_user_account_balance pubkey='x"ALICE_PUBKEY"'
```

Output:

bash

```nolines
99900L
```

> **Note:** Your balance may differ, since it depends on the account's current state and any transactions already made.

Query a user's locked asset balance with:

bash

```nolines
chr query get_user_lock_account_balance pubkey='x"ALICE_PUBKEY"'
```

Output:

bash

```nolines
[]
```

Sample output when locked balances are present:

bash

```
[
  [
    "data": [
      "amount": 20L,
      "type": "FT4_LOCK"
    ],
    "rowid": 31
  ]
]
```

> **Note:**
>
> * An empty array `[]` means the account has no locked balances
> * Each locked balance entry has these fields:
>   + `amount`: the locked quantity in the smallest unit, written with an `L` suffix
>   + `type`: the lock type, such as "FT4\_LOCK"
>   + `rowid`: a unique ID for the lock record

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

[← Previous**Asset functions, operations and queries**](https://chromia.com/learn/ft4-asset/asset-operations/)[Next →**Considerations and recommendations**](https://chromia.com/learn/ft4-asset/consideration-recomendations/)
