Transaction Testing in Facebook

作者: Olly_Zhang | 来源:发表于2019-07-06 19:42 被阅读7次

Objective

Install Libra dependencies;

Implement a transaction between Jason and Verna.

Preparation

OS:Linux (Red Hat/Debian-based)

      MacOS

Git installed

Steps

1. Download and build Libra core source code;

1.1

git clone https://github.com/libra/libra.git

1.2 setup and active core

cd libra

./scripts/dev_setup.sh

2. Build Libra CLI, connect to testnest;

./scripts/cli/start_cli_testnet.sh

After connecting to testnet,you will see below output:

usage: <command> <args>

use the following commands:

account | a

Account operations

query | q

Query operations

transfer | transferb | t | tb

<sender_account_address>|<sender_account_ref_id> <receiver_account_address>|<receiver_account_ref_id> <number_of_coins> [gas_unit_price (default=0)] [max_gas_amount (default 10000)] Suffix 'b' is for blocking.

quit | q!

Exit this client

Input command Libra% validate if cli has been installed.

3. Create account for Jason and Verna using cli;

3.1 check account info

libra%account

usage:account<arg>

using following args:

create|c

Create an account. Returns reference ID to use in other operations

list | la

Print all accounts that were created or loaded

recover | r <file path>

Recover Libra wallet from the file path

write | w <file name>

Save Libra wallet mnemonic recovery seed to disk

mint | mintb | m | mb <receiver account> <number of coins>

Mint coins to the account. Suffix 'b' is for blocking

3.2 create Jason account

libra% account create

output:

>> Creating/retrieving next account from wallet

Created/retrieved account #0 address 975ed8e5fafae41687b2a105a0be2f819358883441cfaaf865nf93fc0868e7a02yih57

#0 is the index of Jason account, followed by his accounts address. Account index can be used in other clients commands to easily reference their accounts.This index has no means to blockchain.

3.3 create Verna account

libra% account create

Output:

>> Creating/retrieving next account from wallet

Created/retrieved account #1 address 8337aac709a41fe6be03cad8878a0d4209740b1608f8a81566c9a7d4b95a2ec7

4. Mint Libra coins for Jason and Verna accounts.

create and add coins is done using Faucet. Faucet is a service running with testnet. only served for creating coins for testnet.

4.1 Add 100 Libra to Jason

libra% account mint 0 100

>> Minting coins

Mint request submitted

After submitted, it means this transactions has been successfully added to mempool(valid node in testnet).

Same to Verna account...

5. Check account balance

libra% query balance 0

6. Transfer libra from Jason to Verna

libra% transfer 0 1 10

0 is Jason index

1 is Verna index

10 is the Libra amount transfer from Jason to Verna

output:

>> Transferring

Transaction submitted to validator

To query for transaction status, run: query txn_acc_seq 0 0 <fetch_events=true|false>

6.1 check sequence num after transfer

libra% query sequence 0

>> Getting current sequence number

Sequence number is: 1

libra% query sequence 1

>> Getting current sequence number

Sequence number is: 0

Jason account(index 0)s'sequence number is 1 : there is one transaction sent from Jason account.

Verna account(index1)s' sequence number is 0: there is no transaction initiated  from Verna account.

Every time there is a transaction sent from an account, the sequence number will be increased by 1.

Congratulations!

You have successfully done one transaction on the facebook Libra testnet.

相关文章

网友评论

    本文标题:Transaction Testing in Facebook

    本文链接:https://www.haomeiwen.com/subject/nclmhctx.html