Add instructions to run CLI tests (#58)
All checks were successful
Publish npm package to gitea / npm_publish (18.x) (release) Successful in 1m23s

Part of https://www.notion.so/Create-laconic-registry-SDK-d3a636d4aba44f7cbba3bd99b7146811

Co-authored-by: neeraj <neeraj.rtly@gmail.com>
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Reviewed-on: #58
Co-authored-by: Prathamesh Musale <prathamesh@noreply.git.vdb.to>
Co-committed-by: Prathamesh Musale <prathamesh@noreply.git.vdb.to>
This commit is contained in:
Prathamesh Musale 2024-03-21 11:19:14 +00:00 committed by nabarun
parent 9c992ebe71
commit 2e4dcf7e63
4 changed files with 84 additions and 17 deletions

1
.env.example Normal file
View File

@ -0,0 +1 @@
TEST_ACCOUNT=

View File

@ -2,12 +2,42 @@
CLI utility written in TS, used to interact with laconicd. Depends on [registry-sdk](https://git.vdb.to/cerc-io/registry-sdk).
## Install
- Add `.npmrc` file in desired project to resolve package
```bash
@cerc-io:registry=https://git.vdb.to/api/packages/cerc-io/npm/
```
This will set the registry for `cerc-io` scoped packages in the project
- Install the CLI using package manager
```bash
yarn add @cerc-io/laconic-registry-cli
```
- For installing CLI globally add `.npmrc` file above in home directory and run
```bash
yarn global add @cerc-io/laconic-registry-cli
```
## Setup
* Run `yarn` to install all dependencies.
* Run `yarn build`.
* Create a `config.yml` file from [config.example.yml](./config.example.yml) file.
* Add CLI cmd to path
```bash
export PATH="$PWD/bin:$PATH"
```
## Account Setup
Run the chain:
@ -15,13 +45,13 @@ Run the chain:
- In laconicd repo run:
```bash
TEST_AUCTION_ENABLED=true ./init.sh
TEST_AUCTION_ENABLED=true ./scripts/init.sh clean
```
Registering records in registry requires an account. To get account private key run:
```bash
$ laconicd keys export mykey --unarmored-hex --unsafe
laconic2d keys export alice --keyring-backend test --unarmored-hex --unsafe
```
In `config.yml` file assign the account private key to `userKey`.
@ -82,10 +112,10 @@ $ laconic registry status
Get account details:
```bash
$ laconic registry account get --address ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52
$ laconic registry account get --address laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k
[
{
"address": "ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52",
"address": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
"pubKey": "A2BeFMnq4h0v5/hP+trvQbCtVWwGGYNSHWRJ7Ae60biS",
"number": "0",
"sequence": "37",
@ -102,10 +132,10 @@ $ laconic registry account get --address ethm133y09mveksh76uc99h4rl38nd033tk4e3y
Send tokens:
```bash
$ laconic registry tokens send --address ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu --type photon --quantity 1000000000
$ laconic registry tokens send --address laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k --type photon --quantity 1000000000
[
{
"address": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8",
"address": "laconic1pmuxrcnuhhf8qdllzuf2ctj2tnwwcg6yswqnyd",
"pubKey": "A68/q7/xazFzNj+rrvE07ALxkMgqw1ugL35VECkWAYvt",
"number": "0",
"sequence": "16",
@ -117,7 +147,7 @@ $ laconic registry tokens send --address ethm1vc62ysqu504at932jjq8pwrqgjt67rx6gg
]
},
{
"address": "ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu",
"address": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
"pubKey": null,
"number": "12",
"sequence": "0",
@ -220,7 +250,7 @@ $ laconic registry authority whois laconic
"auction": {
"id": "0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48",
"status": "commit",
"ownerAddress": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8",
"ownerAddress": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
"createTime": "2022-04-26T11:43:45.679728594",
"commitsEndTime": "2022-04-26T11:44:45.679728594",
"revealsEndTime": "2022-04-26T11:45:45.679728594",
@ -259,7 +289,7 @@ $ laconic registry auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2
{
"id": "0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48",
"status": "commit",
"ownerAddress": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8",
"ownerAddress": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
"createTime": "2022-04-26T11:42:05.256059269",
"commitsEndTime": "2022-04-26T11:44:45.679728594",
"revealsEndTime": "2022-04-26T11:45:45.679728594",
@ -318,7 +348,7 @@ $ laconic registry authority reserve echo.laconic
Create sub-authority (custom owner for sub-authority):
```bash
$ laconic registry authority reserve kube.laconic --owner ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu
$ laconic registry authority reserve kube.laconic --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k
```
Set name:
@ -406,7 +436,7 @@ $ laconic registry bond list
[
{
"id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785",
"owner": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8",
"owner": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
"balance": [
{
"type": "photon",
@ -416,7 +446,7 @@ $ laconic registry bond list
},
{
"id": "5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0",
"owner": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8",
"owner": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
"balance": [
{
"type": "photon",
@ -434,7 +464,7 @@ $ laconic registry bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa1953
[
{
"id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785",
"owner": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8",
"owner": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
"balance": [
{
"type": "photon",
@ -448,11 +478,11 @@ $ laconic registry bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa1953
Query bonds by owner:
```bash
$ laconic registry bond list --owner ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8
$ laconic registry bond list --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k
[
{
"id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785",
"owner": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8",
"owner": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
"balance": [
{
"type": "photon",
@ -462,7 +492,7 @@ $ laconic registry bond list --owner ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8
},
{
"id": "5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0",
"owner": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8",
"owner": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
"balance": [
{
"type": "photon",

View File

@ -1,7 +1,9 @@
services:
registry:
restEndpoint: 'http://localhost:1317'
restEndpoint: 'http://localhost:26657'
gqlEndpoint: 'http://localhost:9473/api'
userKey:
bondId:
chainId: laconic_9000-1
gas: 200000
fees: 200000photon

34
test/README.md Normal file
View File

@ -0,0 +1,34 @@
## Run CLI tests
* Follow the project `Setup` and `Account Setup` from root [README](./../README.md)
* Add laconic cmd to path
```bash
export PATH="$PWD/bin:$PATH"
```
* Create a .env file using [.env.example](./.env.example):
```bash
cp .env.example .env
```
* Get account address of test account:
```bash
laconic2d keys list --keyring-backend test
# - address: laconic10er85pyd7ukw732e88fzv7k0jq205764hye2dx
# name: alice
# pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AsDoWlNIr3W013pOiwmopaB/SaWQj6r3g56xb2d9GxYK"}'
# type: local
```
Use the `address` field from the result and assign it in `TEST_ACCOUNT` field of `.env` file
* Run CLI tests:
```bash
yarn test
```