Skip to content

Test scenarios

Sergey Morozov edited this page Apr 26, 2019 · 2 revisions

Execute wallet smart contract, transfer coins

You can use an insolar command line tool to perform API requests. As each smart contract request has to be signed with the user key, this tool makes it simpler than using JSON-RPC API directly.

First, run an interactive shell inside the insolard container:

$ docker-compose exec insolard bash
$ cd /opt/bin

Then we can get info about network domains:

$ ./insolar -c get_info

Create two new users:

$ ./insolar -c create_member Satoshi > satoshi.json
$ ./insolar -c create_member Vitalik > vitalik.json

Now we have a JSON file with a key pair and ID for each user.

Let’s check the balances of their wallets:

$ ./insolar -c send_request -g satoshi.json -p -
{"method":"GetMyBalance"}
<Ctrl+D>
$ ./insolar -c send_request -g vitalik.json -p -
{"method":"GetMyBalance"}
<Ctrl+D>

Both users have an initial amount of 1,000,000,000 coins.

Now let’s transfer some coins:

$ cat vitalik.json

We need the caller field from the file. It is a user ID.

Transfer coins from one user to another:

$ ./insolar -c send_request -g satoshi.json -p -
{"method":"Transfer", "params":[12345,"<insert user ID from vitalik.json here>"]}
<Ctrl+D>

Now when we check balances again:

$ ./insolar -c send_request -g satoshi.json -p -
{"method":"GetMyBalance"}
<Ctrl+D>
$ ./insolar -c send_request -g vitalik.json -p -
{"method":"GetMyBalance"}
<Ctrl+D>

we see that one has been been debited and the other credited by the specific transfer amount.

Additional tools

You can run the benchmark tool to test network performance. This tool creates users with wallets and transfers money between them.

$ docker-compose exec insolard       \
    /opt/bin/benchmark               \
        -u http://insolard:19191/api \
        -k /etc/insolar/keys.json    \
        -c 20                        \
        -r 20
  • -u: Node API URL.
  • -k: Path to node’s key pair.
  • -c: Number of concurrent threads in which requests will be sent.
  • -r: Number of transfer requests that will be sent in each thread.

API requester tool runs a scenario in which it creates a number of users with wallets, then transfers some money between these users. On the first occasion, the script does the transfers sequentially, on the second time — concurrently.

$ docker-compose exec insolard       \
    /opt/bin/apirequester            \
        -u http://insolard:19191/api \
        -k /etc/insolar/keys.json
  • -u: Node API URL.
  • -k: Path to node’s key pair.
Clone this wiki locally
You can’t perform that action at this time.