From 30e21feaf0a70be529d494ef4b7d0a98bf3a1729 Mon Sep 17 00:00:00 2001 From: fjchen7 Date: Thu, 16 Dec 2021 15:17:57 +0800 Subject: [PATCH 1/9] chore: Add Github Action for integration test --- .github/workflows/integration-test.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/integration-test.yml diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 000000000..b0248b507 --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,18 @@ +name: Integration test + +on: + workflow_dispatch: + +jobs: + run-integration-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Prepare environment + run: | + curl -LO https://github.com/Orange-OpenSource/hurl/releases/download/1.5.0/hurl_1.5.0_amd64.deb + sudo dpkg -i hurl_1.5.0_amd64.deb # install hurl + - name: Run integration test + run: | + shopt -s globstar # enable globstart (**) + hurl --variable mercury_testnet_host="${{ secrets.MERCURY_TESTNET_HOST }}" --test ./integration-test/**/*hurl --summary From 19316521d8e432637cf02fa0efc62dae814fd5d2 Mon Sep 17 00:00:00 2001 From: fjchen7 Date: Thu, 16 Dec 2021 15:18:36 +0800 Subject: [PATCH 2/9] chore: init integration test files --- integration-test/README.md | 81 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 integration-test/README.md diff --git a/integration-test/README.md b/integration-test/README.md new file mode 100644 index 000000000..0e525195b --- /dev/null +++ b/integration-test/README.md @@ -0,0 +1,81 @@ +# Integration-test for mercury + +## Quick start for RPC integration test + +### 1. Install `hurl` +This RPC integration-test uses [`hurl`](https://hurl.dev/docs/samples.html), a convenient CLI tools for calling and testing HTTP requests. + +[Here](https://hurl.dev/docs/installation.html) is the installation documentation for `hurl`. + +### 2. Run tests + +The test files are named as `*.hurl`. Each test file has ONE JSONRPC HTTP call. + +Execute the command below to run all tests under `./rpc`. All test data are in testnet and your must specify the `mercury_testnet_host`. + +```bash +hurl --variable mercury_testnet_host="" ./**/*.hurl --test +``` + +Output + +``` +./rpc/get_balance/get_balance_ok_address_all.hurl: RUNNING [1/3] +./rpc/get_balance/get_balance_ok_address_all.hurl: SUCCESS +./rpc/get_balance/get_balance_ok_address_ckb.hurl: RUNNING [2/3] +./rpc/get_balance/get_balance_ok_address_ckb.hurl: SUCCESS +./rpc/get_balance/get_balance_ok_address_udt.hurl: RUNNING [3/3] +./rpc/get_balance/get_balance_ok_address_udt.hurl: SUCCESS +-------------------------------------------------------------------------------- +Executed: 3 +Succeeded: 3 (100.0%) +Failed: 0 (0.0%) +Duration: 1924ms +``` + + +If you want to see what the response looks like for a single test, just run the command below + +```bash +hurl --variable mercury_testnet_host="" ./rpc/get_balance/get_balance_ok_address_udt.hurl | jq +``` +output +```json +{ + "jsonrpc": "2.0", + "result": { + "balances": [ + { + "ownership": { + "type": "Address", + "value": "ckt1qq6pngwqn6e9vlm92th84rk0l4jp2h8lurchjmnwv8kq3rt5psf4vq06y24q4tc4tfkgze35cc23yprtpzfrzygsptkzn" + }, + "asset_info": { + "asset_type": "UDT", + "udt_hash": "0xf21e7350fa9518ed3cbb008e0e8c941d7e01a12181931d5608aa366ee22228bd" + }, + "free": "60", + "occupied": "0", + "freezed": "0", + "claimable": "0" + } + ], + "tip_block_number": 3767610 + }, + "id": 100 +} +``` + + +If you want to ignore assert and just want to print RPC response, just run the command below: + + +```bash +hurl --variable mercury_testnet_host="" ./rpc/get_balance/get_balance_ok_address_udt.hurl --ignore-asserts | jq +``` + +## Contributing + +Writing hurl file is very easy. Just check the existent tests under [`test_testnet`](./test_testnet) and you will know how to write. + +For more please check the [samples in hurl official site](https://hurl.dev/docs/samples.html). From 37183a114515073df92e935f7baab6a9da121cb9 Mon Sep 17 00:00:00 2001 From: fjchen7 Date: Fri, 17 Dec 2021 10:38:12 +0800 Subject: [PATCH 3/9] feat: Add get_block_info integration test cases --- .../get_balance_ok_block_hash.hurl | 20 +++++++++++++++++++ .../get_balance_ok_block_number.hurl | 20 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 integration-test/rpc/get_block_info/get_balance_ok_block_hash.hurl create mode 100644 integration-test/rpc/get_block_info/get_balance_ok_block_number.hurl diff --git a/integration-test/rpc/get_block_info/get_balance_ok_block_hash.hurl b/integration-test/rpc/get_block_info/get_balance_ok_block_hash.hurl new file mode 100644 index 000000000..25f0bfe2c --- /dev/null +++ b/integration-test/rpc/get_block_info/get_balance_ok_block_hash.hurl @@ -0,0 +1,20 @@ +POST {{mercury_testnet_host}} +{ + "jsonrpc": "2.0", + "method": "get_block_info", + "params": [ + { + "block_hash": "0x87405a4f39154fadb13bc23cf147985208ba33d61c277ec8409722434a694e70" + } + ], + "id": 100 +} + +HTTP/1.1 200 +[Asserts] +jsonpath "$.result.block_number" == 508609 +jsonpath "$.result.block_hash" == "0x87405a4f39154fadb13bc23cf147985208ba33d61c277ec8409722434a694e70" + +jsonpath "$.result.transactions" count == 1 +jsonpath "$.result.transactions[0].tx_hash" == "0x32cc46179aa3d7b6eb29b9c692a9fc0b9c56d16751e42258193486d86e0fb5af" +jsonpath "$.result.transactions[0].timestamp" == 1601357943712 diff --git a/integration-test/rpc/get_block_info/get_balance_ok_block_number.hurl b/integration-test/rpc/get_block_info/get_balance_ok_block_number.hurl new file mode 100644 index 000000000..99ef9a40b --- /dev/null +++ b/integration-test/rpc/get_block_info/get_balance_ok_block_number.hurl @@ -0,0 +1,20 @@ +POST {{mercury_testnet_host}} +{ + "jsonrpc": "2.0", + "method": "get_block_info", + "params": [ + { + "block_number": 508609 + } + ], + "id": 100 +} + +HTTP/1.1 200 +[Asserts] +jsonpath "$.result.block_number" == 508609 +jsonpath "$.result.block_hash" == "0x87405a4f39154fadb13bc23cf147985208ba33d61c277ec8409722434a694e70" + +jsonpath "$.result.transactions" count == 1 +jsonpath "$.result.transactions[0].tx_hash" == "0x32cc46179aa3d7b6eb29b9c692a9fc0b9c56d16751e42258193486d86e0fb5af" +jsonpath "$.result.transactions[0].timestamp" == 1601357943712 From cd790a6b8e505dd103d0208a0bcaf6767c95f540 Mon Sep 17 00:00:00 2001 From: fjchen7 Date: Fri, 17 Dec 2021 10:40:21 +0800 Subject: [PATCH 4/9] feat: Add get_mercury_info integration test cases --- .../rpc/get_mercury_info/get_mercury_info_ok.hurl | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 integration-test/rpc/get_mercury_info/get_mercury_info_ok.hurl diff --git a/integration-test/rpc/get_mercury_info/get_mercury_info_ok.hurl b/integration-test/rpc/get_mercury_info/get_mercury_info_ok.hurl new file mode 100644 index 000000000..0f1f6fa91 --- /dev/null +++ b/integration-test/rpc/get_mercury_info/get_mercury_info_ok.hurl @@ -0,0 +1,11 @@ +POST {{mercury_testnet_host}} +{ + "jsonrpc": "2.0", + "method": "get_mercury_info", + "params": [], + "id": 100 +} + +HTTP/1.1 200 +[Asserts] +jsonpath "$.result.network_type" == "Testnet" From a461b60eb3074e0a3793d14e7bd6c2692609cf1e Mon Sep 17 00:00:00 2001 From: fjchen7 Date: Fri, 17 Dec 2021 10:41:39 +0800 Subject: [PATCH 5/9] feat: Add get_db_info integration test cases --- integration-test/rpc/get_db_info/get_db_info_ok.hurl | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 integration-test/rpc/get_db_info/get_db_info_ok.hurl diff --git a/integration-test/rpc/get_db_info/get_db_info_ok.hurl b/integration-test/rpc/get_db_info/get_db_info_ok.hurl new file mode 100644 index 000000000..fa9c1cd53 --- /dev/null +++ b/integration-test/rpc/get_db_info/get_db_info_ok.hurl @@ -0,0 +1,11 @@ +POST {{mercury_testnet_host}} +{ + "jsonrpc": "2.0", + "method": "get_db_info", + "params": [], + "id": 100 +} + +HTTP/1.1 200 +[Asserts] +jsonpath "$.result.db" == "PostgreSQL" From 543101c92daf373a19001f6419ab43ebcce5b838 Mon Sep 17 00:00:00 2001 From: fjchen7 Date: Fri, 17 Dec 2021 11:05:42 +0800 Subject: [PATCH 6/9] feat: Add get_sync_state integration test cases --- .../rpc/get_sync_state/get_sync_state_ok.hurl | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 integration-test/rpc/get_sync_state/get_sync_state_ok.hurl diff --git a/integration-test/rpc/get_sync_state/get_sync_state_ok.hurl b/integration-test/rpc/get_sync_state/get_sync_state_ok.hurl new file mode 100644 index 000000000..b806ef4b7 --- /dev/null +++ b/integration-test/rpc/get_sync_state/get_sync_state_ok.hurl @@ -0,0 +1,13 @@ +POST {{mercury_testnet_host}} +{ + "jsonrpc": "2.0", + "method": "get_sync_state", + "params": [], + "id": 100 +} + +HTTP/1.1 200 +[Asserts] +jsonpath "$.result.value" exists +jsonpath "$.result.value.current" isInteger +jsonpath "$.result.value.target" isInteger From 7bdedc0261da5b71a497e40094db7ad9dd9885f8 Mon Sep 17 00:00:00 2001 From: fjchen7 Date: Fri, 17 Dec 2021 15:46:40 +0800 Subject: [PATCH 7/9] feat: Add get_spent_transaction integration test cases --- ...transaction_fail_nonexistent_outpoint.hurl | 18 +++++++++ ...ent_transaction_fail_unspent_outpoint.hurl | 18 +++++++++ .../get_spent_transaction_ok_doubleEntry.hurl | 31 ++++++++++++++++ .../get_spent_transaction_ok_native.hurl | 37 +++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 integration-test/rpc/get_spent_transaction/get_spent_transaction_fail_nonexistent_outpoint.hurl create mode 100644 integration-test/rpc/get_spent_transaction/get_spent_transaction_fail_unspent_outpoint.hurl create mode 100644 integration-test/rpc/get_spent_transaction/get_spent_transaction_ok_doubleEntry.hurl create mode 100644 integration-test/rpc/get_spent_transaction/get_spent_transaction_ok_native.hurl diff --git a/integration-test/rpc/get_spent_transaction/get_spent_transaction_fail_nonexistent_outpoint.hurl b/integration-test/rpc/get_spent_transaction/get_spent_transaction_fail_nonexistent_outpoint.hurl new file mode 100644 index 000000000..2be882716 --- /dev/null +++ b/integration-test/rpc/get_spent_transaction/get_spent_transaction_fail_nonexistent_outpoint.hurl @@ -0,0 +1,18 @@ +POST {{mercury_testnet_host}} +{ + "id": 42, + "jsonrpc": "2.0", + "method": "get_spent_transaction", + "params": [{ + "outpoint": { + "tx_hash": "0x1f8c79eb3671709633fe6a46de93c0fedc9c1b8a6527a18d3983879542635c9f", + "index": "0x1" + }, + "structure_type": "Native" + }] +} + + +HTTP/1.1 200 +[Asserts] +jsonpath "$.error" exists diff --git a/integration-test/rpc/get_spent_transaction/get_spent_transaction_fail_unspent_outpoint.hurl b/integration-test/rpc/get_spent_transaction/get_spent_transaction_fail_unspent_outpoint.hurl new file mode 100644 index 000000000..cdd6cf019 --- /dev/null +++ b/integration-test/rpc/get_spent_transaction/get_spent_transaction_fail_unspent_outpoint.hurl @@ -0,0 +1,18 @@ +POST {{mercury_testnet_host}} +{ + "id": 42, + "jsonrpc": "2.0", + "method": "get_spent_transaction", + "params": [{ + "outpoint": { + "tx_hash": "0x8f8c79eb6671709633fe6a46de93c0fedc9c1b8a6527a18d3983879542635c9f", + "index": "0x1" + }, + "structure_type": "Native" + }] +} + + +HTTP/1.1 200 +[Asserts] +jsonpath "$.error" exists diff --git a/integration-test/rpc/get_spent_transaction/get_spent_transaction_ok_doubleEntry.hurl b/integration-test/rpc/get_spent_transaction/get_spent_transaction_ok_doubleEntry.hurl new file mode 100644 index 000000000..965ec0a49 --- /dev/null +++ b/integration-test/rpc/get_spent_transaction/get_spent_transaction_ok_doubleEntry.hurl @@ -0,0 +1,31 @@ +POST {{mercury_testnet_host}} +{ + "id": 42, + "jsonrpc": "2.0", + "method": "get_spent_transaction", + "params": [{ + "outpoint": { + "tx_hash": "0xa4aee7ae950d7fb74271816566827832d50ebf3fc04234927314fd332c4cd112", + "index": "0x2" + }, + "structure_type": "DoubleEntry" + }] +} + +# The returned tx: https://explorer.nervos.org/aggron/transaction/0x3020e90284f2d4f51b79471245939d043e958c60ba5dc95b212f8cbd8b875bd1 +HTTP/1.1 200 +[Asserts] +jsonpath "$.result.type" == "TransactionInfo" +jsonpath "$.result.value" exists +jsonpath "$.result.value.tx_hash" == "0x3020e90284f2d4f51b79471245939d043e958c60ba5dc95b212f8cbd8b875bd1" + +jsonpath "$.result.value.records[*]" count == 8 + +# input #1 +jsonpath "$.result.value.records[?(@.amount=='-561599924694')].ownership.value" == "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqdrhpvcu82numz73852ed45cdxn4kcn72cr4338a" + +# output #0 +jsonpath "$.result.value.records[?(@.amount=='100')].ownership.value" == "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqv8c706nuqkxchp0sw996qqunhmkkgesqs0rppmc" + +# output #2 +jsonpath "$.result.value.records[?(@.amount=='545399923736')].ownership.value" == "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqdrhpvcu82numz73852ed45cdxn4kcn72cr4338a" diff --git a/integration-test/rpc/get_spent_transaction/get_spent_transaction_ok_native.hurl b/integration-test/rpc/get_spent_transaction/get_spent_transaction_ok_native.hurl new file mode 100644 index 000000000..e95d43ae3 --- /dev/null +++ b/integration-test/rpc/get_spent_transaction/get_spent_transaction_ok_native.hurl @@ -0,0 +1,37 @@ +POST {{mercury_testnet_host}} +{ + "id": 42, + "jsonrpc": "2.0", + "method": "get_spent_transaction", + "params": [{ + "outpoint": { + "tx_hash": "0xa4aee7ae950d7fb74271816566827832d50ebf3fc04234927314fd332c4cd112", + "index": "0x2" + }, + "structure_type": "Native" + }] +} + +# The returned tx: https://explorer.nervos.org/aggron/transaction/0x3020e90284f2d4f51b79471245939d043e958c60ba5dc95b212f8cbd8b875bd1 +HTTP/1.1 200 +[Asserts] +jsonpath "$.result.type" == "TransactionWithRichStatus" +jsonpath "$.result.value" exists +jsonpath "$.result.value.transaction" exists +jsonpath "$.result.value.transaction.hash" == "0x3020e90284f2d4f51b79471245939d043e958c60ba5dc95b212f8cbd8b875bd1" + +jsonpath "$.result.value.transaction.inputs" count == 2 +jsonpath "$.result.value.transaction.inputs[1].previous_output.tx_hash" == "0xa4aee7ae950d7fb74271816566827832d50ebf3fc04234927314fd332c4cd112" +jsonpath "$.result.value.transaction.inputs[1].previous_output.index" == "0x2" + +jsonpath "$.result.value.transaction.outputs" count == 3 +jsonpath "$.result.value.transaction.outputs[?(@.capacity=='0x7efc5e6418')].lock.args" == "0xa3b8598e1d53e6c5e89e8acb6b4c34d3adb13f2b" +jsonpath "$.result.value.transaction.outputs[?(@.capacity=='0x7efc5e6418')].type" == null +jsonpath "$.result.value.transaction.outputs[?(@.capacity=='0x34e62ce00')].lock.args" == "0xa3b8598e1d53e6c5e89e8acb6b4c34d3adb13f2b" + + +jsonpath "$.result.value.transaction.outputs_data" count == 3 +jsonpath "$.result.value.transaction.witnesses" count == 2 + +jsonpath "$.result.value.tx_status.status" == "committed" +jsonpath "$.result.value.tx_status.block_hash" == "0x54af022e0fdebed3690ee6d6e2368f3c976c6ad6cfcdbfa307869fd57c2d5129" From 650e9689ae3a2f947ee958c0774c213d97a48ced Mon Sep 17 00:00:00 2001 From: fjchen7 Date: Fri, 17 Dec 2021 16:02:09 +0800 Subject: [PATCH 8/9] feat: Add get_transaction_info integration test cases --- ..._transaction_info_fail_nonexistent_tx.hurl | 13 ++++++++++ .../get_transaction_info_ok.hurl | 26 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 integration-test/rpc/get_transaction_info/get_transaction_info_fail_nonexistent_tx.hurl create mode 100644 integration-test/rpc/get_transaction_info/get_transaction_info_ok.hurl diff --git a/integration-test/rpc/get_transaction_info/get_transaction_info_fail_nonexistent_tx.hurl b/integration-test/rpc/get_transaction_info/get_transaction_info_fail_nonexistent_tx.hurl new file mode 100644 index 000000000..b9e1b93c9 --- /dev/null +++ b/integration-test/rpc/get_transaction_info/get_transaction_info_fail_nonexistent_tx.hurl @@ -0,0 +1,13 @@ +POST {{mercury_testnet_host}} +{ + "id": 42, + "jsonrpc": "2.0", + "method": "get_transaction_info", + "params": [ + "0xd82e3050472d5b5f7603cb8142a57caffdcb2c20bd88577f77da23822d4d42a3" + ] +} + +HTTP/1.1 200 +[Asserts] +jsonpath "$.error" exists diff --git a/integration-test/rpc/get_transaction_info/get_transaction_info_ok.hurl b/integration-test/rpc/get_transaction_info/get_transaction_info_ok.hurl new file mode 100644 index 000000000..642b61236 --- /dev/null +++ b/integration-test/rpc/get_transaction_info/get_transaction_info_ok.hurl @@ -0,0 +1,26 @@ +POST {{mercury_testnet_host}} +{ + "id": 42, + "jsonrpc": "2.0", + "method": "get_transaction_info", + "params": [ + "0xd82e3050472d5b5f7603cb8141a57caffdcb2c20bd88577f77da23822d4d42a3" + ] +} + +HTTP/1.1 200 +[Asserts] +jsonpath "$.result.transaction" exists +jsonpath "$.result.transaction.tx_hash" == "0xd82e3050472d5b5f7603cb8141a57caffdcb2c20bd88577f77da23822d4d42a3" + +# input #0 +jsonpath "$.result.transaction.records[0].amount" == "-14367400000" +jsonpath "$.result.transaction.records[0].occupied" == 14200000000 +jsonpath "$.result.transaction.records[0].block_number" == 3418132 + +# output #0 +jsonpath "$.result.transaction.records[1].amount" == "14367200000" +jsonpath "$.result.transaction.records[1].occupied" == 14200000000 +jsonpath "$.result.transaction.records[1].block_number" == 3418281 + +jsonpath "$.result.status" == "committed" From 6def6cd10b431471983cde447fe8f257604cd181 Mon Sep 17 00:00:00 2001 From: fjchen7 Date: Fri, 17 Dec 2021 17:56:19 +0800 Subject: [PATCH 9/9] feat: Add get_balance integration test cases --- .../get_balance_fail_illegal_address.hurl | 20 ++++++++++ .../get_balance_ok_address_all.hurl | 26 +++++++++++++ .../get_balance_ok_address_ckb.hurl | 34 +++++++++++++++++ .../get_balance_ok_address_udt.hurl | 38 +++++++++++++++++++ .../get_balance_ok_identity_all.hurl | 27 +++++++++++++ .../get_balance_ok_identity_ckb.hurl | 31 +++++++++++++++ .../get_balance_ok_identity_udt.hurl | 33 ++++++++++++++++ .../get_balance/get_balance_ok_record.hurl | 25 ++++++++++++ 8 files changed, 234 insertions(+) create mode 100644 integration-test/rpc/get_balance/get_balance_fail_illegal_address.hurl create mode 100644 integration-test/rpc/get_balance/get_balance_ok_address_all.hurl create mode 100644 integration-test/rpc/get_balance/get_balance_ok_address_ckb.hurl create mode 100644 integration-test/rpc/get_balance/get_balance_ok_address_udt.hurl create mode 100644 integration-test/rpc/get_balance/get_balance_ok_identity_all.hurl create mode 100644 integration-test/rpc/get_balance/get_balance_ok_identity_ckb.hurl create mode 100644 integration-test/rpc/get_balance/get_balance_ok_identity_udt.hurl create mode 100644 integration-test/rpc/get_balance/get_balance_ok_record.hurl diff --git a/integration-test/rpc/get_balance/get_balance_fail_illegal_address.hurl b/integration-test/rpc/get_balance/get_balance_fail_illegal_address.hurl new file mode 100644 index 000000000..4dacb20b3 --- /dev/null +++ b/integration-test/rpc/get_balance/get_balance_fail_illegal_address.hurl @@ -0,0 +1,20 @@ +POST {{mercury_testnet_host}} +{ + "jsonrpc": "2.0", + "method": "get_balance", + "params": [ + { + "item": { + "type": "Address", + "value": "ckt1q" + }, + "asset_infos": [], + "tip_block_number": 3767610 + } + ], + "id": 100 +} + +HTTP/1.1 200 +[Asserts] +jsonpath "$.error" exists diff --git a/integration-test/rpc/get_balance/get_balance_ok_address_all.hurl b/integration-test/rpc/get_balance/get_balance_ok_address_all.hurl new file mode 100644 index 000000000..700709bdc --- /dev/null +++ b/integration-test/rpc/get_balance/get_balance_ok_address_all.hurl @@ -0,0 +1,26 @@ +POST {{mercury_testnet_host}} +{ + "jsonrpc": "2.0", + "method": "get_balance", + "params": [ + { + "item": { + "type": "Address", + "value": "ckt1qq6pngwqn6e9vlm92th84rk0l4jp2h8lurchjmnwv8kq3rt5psf4vq06y24q4tc4tfkgze35cc23yprtpzfrzygsptkzn" + }, + "asset_infos": [], + "tip_block_number": 3767610 + } + ], + "id": 100 +} + +HTTP/1.1 200 +[Asserts] +jsonpath "$.result.balances" count == 2 + +jsonpath "$.result.balances[?(@.free=='60')].asset_info.asset_type" == "UDT" +jsonpath "$.result.balances[?(@.free=='60')].ownership.value" == "ckt1qq6pngwqn6e9vlm92th84rk0l4jp2h8lurchjmnwv8kq3rt5psf4vq06y24q4tc4tfkgze35cc23yprtpzfrzygsptkzn" + +jsonpath "$.result.balances[?(@.free=='985799999470')].asset_info.asset_type" == "CKB" +jsonpath "$.result.balances[?(@.free=='985799999470')].ownership.value" == "ckt1qq6pngwqn6e9vlm92th84rk0l4jp2h8lurchjmnwv8kq3rt5psf4vq06y24q4tc4tfkgze35cc23yprtpzfrzygsptkzn" diff --git a/integration-test/rpc/get_balance/get_balance_ok_address_ckb.hurl b/integration-test/rpc/get_balance/get_balance_ok_address_ckb.hurl new file mode 100644 index 000000000..3032f4f65 --- /dev/null +++ b/integration-test/rpc/get_balance/get_balance_ok_address_ckb.hurl @@ -0,0 +1,34 @@ +POST {{mercury_testnet_host}} +{ + "jsonrpc": "2.0", + "method": "get_balance", + "params": [ + { + "item": { + "type": "Address", + "value": "ckt1qyqg88ccqm59ksxp85788pnqg4rkejdgcg2qxcu2qf" + }, + "asset_infos": [ + { + "asset_type": "CKB", + "udt_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } + ], + "tip_block_number": 3636218 + } + ], + "id": 100 +} + +HTTP/1.1 200 +[Asserts] +jsonpath "$.result.balances" count == 1 + +jsonpath "$.result.balances[0].ownership.type" == "Address" +jsonpath "$.result.balances[0].ownership.value" == "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqvrnuvqd6zmgrqn60rnsesy23mvex5vy9q0g8hfd" + +jsonpath "$.result.balances[0].asset_info.asset_type" == "CKB" +jsonpath "$.result.balances[0].asset_info.udt_hash" == "0x0000000000000000000000000000000000000000000000000000000000000000" + +jsonpath "$.result.balances[0].free" == "6053944763147" +jsonpath "$.result.tip_block_number" == 3636218 diff --git a/integration-test/rpc/get_balance/get_balance_ok_address_udt.hurl b/integration-test/rpc/get_balance/get_balance_ok_address_udt.hurl new file mode 100644 index 000000000..74c774cda --- /dev/null +++ b/integration-test/rpc/get_balance/get_balance_ok_address_udt.hurl @@ -0,0 +1,38 @@ +POST {{mercury_testnet_host}} +{ + "jsonrpc": "2.0", + "method": "get_balance", + "params": [ + { + "item": { + "type": "Address", + "value": "ckt1qq6pngwqn6e9vlm92th84rk0l4jp2h8lurchjmnwv8kq3rt5psf4vq06y24q4tc4tfkgze35cc23yprtpzfrzygsptkzn" + }, + "asset_infos": [ + { + "asset_type": "UDT", + "udt_hash": "0xf21e7350fa9518ed3cbb008e0e8c941d7e01a12181931d5608aa366ee22228bd" + } + ], + "tip_block_number": 3767610 + } + ], + "id": 100 +} + +HTTP/1.1 200 +[Asserts] +jsonpath "$.result.balances" count == 1 + +jsonpath "$.result.balances[0].ownership.type" == "Address" +jsonpath "$.result.balances[0].ownership.value" == "ckt1qq6pngwqn6e9vlm92th84rk0l4jp2h8lurchjmnwv8kq3rt5psf4vq06y24q4tc4tfkgze35cc23yprtpzfrzygsptkzn" + +jsonpath "$.result.balances[0].asset_info.asset_type" == "UDT" +jsonpath "$.result.balances[0].asset_info.udt_hash" == "0xf21e7350fa9518ed3cbb008e0e8c941d7e01a12181931d5608aa366ee22228bd" + +jsonpath "$.result.balances[0].free" == "60" +jsonpath "$.result.balances[0].occupied" == "0" +jsonpath "$.result.balances[0].freezed" == "0" +jsonpath "$.result.balances[0].claimable" == "0" + +jsonpath "$.result.tip_block_number" == 3767610 diff --git a/integration-test/rpc/get_balance/get_balance_ok_identity_all.hurl b/integration-test/rpc/get_balance/get_balance_ok_identity_all.hurl new file mode 100644 index 000000000..dda2178bf --- /dev/null +++ b/integration-test/rpc/get_balance/get_balance_ok_identity_all.hurl @@ -0,0 +1,27 @@ +POST {{mercury_testnet_host}} +{ + "jsonrpc": "2.0", + "method": "get_balance", + "params": [ + { + "item": { + "type":"Identity", + "value":"0x00fa22aa0aaf155a6c816634c61512046b08923111" + }, + "asset_infos": [], + "tip_block_number": 3769130 + } + ], + "id": 100 +} + +HTTP/1.1 200 +[Asserts] +jsonpath "$.result.balances" count == 3 + +jsonpath "$.result.balances[?(@.free=='60')].asset_info.asset_type" == "UDT" +jsonpath "$.result.balances[?(@.free=='60')].ownership.value" == "ckt1qq6pngwqn6e9vlm92th84rk0l4jp2h8lurchjmnwv8kq3rt5psf4vq06y24q4tc4tfkgze35cc23yprtpzfrzygsptkzn" +jsonpath "$.result.balances[?(@.free=='1000000000000')].asset_info.asset_type" == "CKB" +jsonpath "$.result.balances[?(@.free=='1000000000000')].ownership.value" == "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq06y24q4tc4tfkgze35cc23yprtpzfrzygljdjh9" +jsonpath "$.result.balances[?(@.free=='1979699999470')].asset_info.asset_type" == "CKB" +jsonpath "$.result.balances[?(@.free=='1979699999470')].ownership.value" == "ckt1qq6pngwqn6e9vlm92th84rk0l4jp2h8lurchjmnwv8kq3rt5psf4vq06y24q4tc4tfkgze35cc23yprtpzfrzygsptkzn" diff --git a/integration-test/rpc/get_balance/get_balance_ok_identity_ckb.hurl b/integration-test/rpc/get_balance/get_balance_ok_identity_ckb.hurl new file mode 100644 index 000000000..95eb3b46b --- /dev/null +++ b/integration-test/rpc/get_balance/get_balance_ok_identity_ckb.hurl @@ -0,0 +1,31 @@ +POST {{mercury_testnet_host}} +{ + "jsonrpc": "2.0", + "method": "get_balance", + "params": [ + { + "item": { + "type":"Identity", + "value":"0x00fa22aa0aaf155a6c816634c61512046b08923111" + }, + "asset_infos": [ + { + "asset_type": "CKB", + "udt_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } + ], + "tip_block_number": 3769130 + } + ], + "id": 100 +} + +HTTP/1.1 200 +[Asserts] +jsonpath "$.result.balances" count == 2 + +jsonpath "$.result.balances[?(@.free=='1979699999470')].asset_info.asset_type" == "CKB" +jsonpath "$.result.balances[?(@.free=='1979699999470')].ownership.value" == "ckt1qq6pngwqn6e9vlm92th84rk0l4jp2h8lurchjmnwv8kq3rt5psf4vq06y24q4tc4tfkgze35cc23yprtpzfrzygsptkzn" + +jsonpath "$.result.balances[?(@.free=='1000000000000')].asset_info.asset_type" == "CKB" +jsonpath "$.result.balances[?(@.free=='1000000000000')].ownership.value" == "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq06y24q4tc4tfkgze35cc23yprtpzfrzygljdjh9" diff --git a/integration-test/rpc/get_balance/get_balance_ok_identity_udt.hurl b/integration-test/rpc/get_balance/get_balance_ok_identity_udt.hurl new file mode 100644 index 000000000..70051c973 --- /dev/null +++ b/integration-test/rpc/get_balance/get_balance_ok_identity_udt.hurl @@ -0,0 +1,33 @@ +POST {{mercury_testnet_host}} +{ + "jsonrpc": "2.0", + "method": "get_balance", + "params": [ + { + "item": { + "type":"Identity", + "value":"0x00fa22aa0aaf155a6c816634c61512046b08923111" + }, + "asset_infos": [ + { + "asset_type": "UDT", + "udt_hash": "0xf21e7350fa9518ed3cbb008e0e8c941d7e01a12181931d5608aa366ee22228bd" + } + ], + "tip_block_number": 3769130 + } + ], + "id": 100 +} + +HTTP/1.1 200 +[Asserts] +jsonpath "$.result.balances" count == 1 + +jsonpath "$.result.balances[0].ownership.type" == "Address" +jsonpath "$.result.balances[0].ownership.value" == "ckt1qq6pngwqn6e9vlm92th84rk0l4jp2h8lurchjmnwv8kq3rt5psf4vq06y24q4tc4tfkgze35cc23yprtpzfrzygsptkzn" + +jsonpath "$.result.balances[0].asset_info.asset_type" == "UDT" +jsonpath "$.result.balances[0].asset_info.udt_hash" == "0xf21e7350fa9518ed3cbb008e0e8c941d7e01a12181931d5608aa366ee22228bd" + +jsonpath "$.result.balances[0].free" == "60" diff --git a/integration-test/rpc/get_balance/get_balance_ok_record.hurl b/integration-test/rpc/get_balance/get_balance_ok_record.hurl new file mode 100644 index 000000000..b7eb51e38 --- /dev/null +++ b/integration-test/rpc/get_balance/get_balance_ok_record.hurl @@ -0,0 +1,25 @@ +POST {{mercury_testnet_host}} +{ + "jsonrpc": "2.0", + "method": "get_balance", + "params": [ + { + "item": { + "type": "Record", + "value": "ea0b230104fd3be2cc33ab50c3d591dc6cefbe8ed83f7e63c8142de4b5a0ee720000000000636b7431717a646130637230386d38356863386a6c6e6670337a65723778756c656a79777434396b7432727230767468797761613530787773717736766a7a79396b616878336c79766c67617038647038657764386738307063676365787a726a" + }, + "asset_infos": [] + } + ], + "id": 100 +} +# live cell of the given record: output #0 in tx 0xea0b230104fd3be2cc33ab50c3d591dc6cefbe8ed83f7e63c8142de4b5a0ee72 + +HTTP/1.1 200 +[Asserts] +jsonpath "$.result.balances" count == 1 + +jsonpath "$.result.balances[0].ownership.type" == "Address" +jsonpath "$.result.balances[0].ownership.value" == "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqw6vjzy9kahx3lyvlgap8dp8ewd8g80pcgcexzrj" +jsonpath "$.result.balances[0].asset_info.asset_type" == "CKB" +jsonpath "$.result.balances[0].free" == "194703317445"