From 75bda7dc7c2c2bff993f69bc0d7b7a4b00d2e906 Mon Sep 17 00:00:00 2001 From: danielvo11 Date: Tue, 23 Jan 2024 18:10:47 +0700 Subject: [PATCH] increase precision --- src/index.ts | 2 +- ...60e2d23b39ecbea079594cfe71e9386e73d4d.json | 28 --- ...404e60cd35e9c913a791415a2b52624827dcf.json | 138 --------------- ...db8a082add2a0239f42aed4a1d2aa2435b27a.json | 32 ++++ ...1f669fd81c11ba85e234f2fc529f966cb2ec6.json | 32 ---- ...c990e6ea2e283c39d1f3a8d1b7680fedaed53.json | 18 ++ ...41863b9726fdd5151ef0a057fbc41ce5b1b1a.json | 18 -- ...ee4f1d7ff04f2dd45675f0f50a4e9094a5d13.json | 167 ++++++++++++++++++ test/powerup.ts | 113 ++++++------ test/rex.ts | 18 +- 10 files changed, 283 insertions(+), 283 deletions(-) delete mode 100644 test/data/0c060e2d23b39ecbea079594cfe71e9386e73d4d.json delete mode 100644 test/data/16e404e60cd35e9c913a791415a2b52624827dcf.json create mode 100644 test/data/207db8a082add2a0239f42aed4a1d2aa2435b27a.json delete mode 100644 test/data/4c61f669fd81c11ba85e234f2fc529f966cb2ec6.json create mode 100644 test/data/714c990e6ea2e283c39d1f3a8d1b7680fedaed53.json delete mode 100644 test/data/a5741863b9726fdd5151ef0a057fbc41ce5b1b1a.json create mode 100644 test/data/f81ee4f1d7ff04f2dd45675f0f50a4e9094a5d13.json diff --git a/src/index.ts b/src/index.ts index d9ce8c2..95ac78a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,7 +22,7 @@ export interface SampleUsage { net: UInt128 } -export const BNPrecision = new BN(1000 * 1000) +export const BNPrecision = new BN(100 * 1000 * 1000) export class Resources { static __className = 'Resources' diff --git a/test/data/0c060e2d23b39ecbea079594cfe71e9386e73d4d.json b/test/data/0c060e2d23b39ecbea079594cfe71e9386e73d4d.json deleted file mode 100644 index 92302dc..0000000 --- a/test/data/0c060e2d23b39ecbea079594cfe71e9386e73d4d.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "request": { - "path": "http://127.0.0.1:8888/v1/chain/get_account", - "params": { - "method": "POST", - "body": "{\"account_name\":\"b1\"}" - } - }, - "status": 500, - "json": { - "code": 500, - "message": "Internal Service Error", - "error": { - "code": 0, - "name": "exception", - "what": "unspecified", - "details": [ - { - "message": "unknown key (boost::tuples::tuple): (0 b1)", - "file": "http_plugin.cpp", - "line_number": 955, - "method": "handle_exception" - } - ] - } - }, - "text": "{\"code\":500,\"message\":\"Internal Service Error\",\"error\":{\"code\":0,\"name\":\"exception\",\"what\":\"unspecified\",\"details\":[{\"message\":\"unknown key (boost::tuples::tuple): (0 b1)\",\"file\":\"http_plugin.cpp\",\"line_number\":955,\"method\":\"handle_exception\"}]}}" -} \ No newline at end of file diff --git a/test/data/16e404e60cd35e9c913a791415a2b52624827dcf.json b/test/data/16e404e60cd35e9c913a791415a2b52624827dcf.json deleted file mode 100644 index deea53a..0000000 --- a/test/data/16e404e60cd35e9c913a791415a2b52624827dcf.json +++ /dev/null @@ -1,138 +0,0 @@ -{ - "request": { - "path": "http://127.0.0.1:8888/v1/chain/get_account", - "params": { - "method": "POST", - "body": "{\"account_name\":\"boost.wax\"}" - } - }, - "status": 200, - "json": { - "account_name": "boost.wax", - "head_block_num": 205984, - "head_block_time": "2023-11-21T15:46:41.500", - "privileged": false, - "last_code_update": "2023-11-20T11:10:15.500", - "created": "2023-11-20T11:10:12.500", - "core_liquid_balance": "100000.00000000 WAX", - "ram_quota": "10425432623", - "net_weight": 1000000000, - "cpu_weight": 1000000000, - "net_limit": { - "used": 23908, - "available": 1044064080, - "max": 1044087988 - }, - "cpu_limit": { - "used": 9113, - "available": 70058946, - "max": 70068059 - }, - "ram_usage": 577170, - "permissions": [ - { - "perm_name": "active", - "parent": "owner", - "required_auth": { - "threshold": 1, - "keys": [ - { - "key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "weight": 1 - } - ], - "accounts": [ - { - "permission": { - "actor": "boost.wax", - "permission": "eosio.code" - }, - "weight": 1 - } - ], - "waits": [] - }, - "linked_actions": [] - }, - { - "perm_name": "deploy", - "parent": "active", - "required_auth": { - "threshold": 1, - "keys": [ - { - "key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "weight": 1 - } - ], - "accounts": [], - "waits": [] - }, - "linked_actions": [ - { - "account": "eosio", - "action": "setcode" - }, - { - "account": "eosio", - "action": "setabi" - } - ] - }, - { - "perm_name": "owner", - "parent": "", - "required_auth": { - "threshold": 1, - "keys": [ - { - "key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "weight": 1 - } - ], - "accounts": [], - "waits": [] - }, - "linked_actions": [] - }, - { - "perm_name": "paybw", - "parent": "active", - "required_auth": { - "threshold": 1, - "keys": [ - { - "key": "EOS8cFt6PzBL79kp9vPwWoX8V6cjwgShbfUsyisiZ1M8QaFgZtep6", - "weight": 1 - } - ], - "accounts": [], - "waits": [] - }, - "linked_actions": [ - { - "account": "boost.wax", - "action": "noop" - } - ] - } - ], - "total_resources": { - "owner": "boost.wax", - "net_weight": "10.00000000 WAX", - "cpu_weight": "10.00000000 WAX", - "ram_bytes": "10425431223" - }, - "self_delegated_bandwidth": null, - "refund_request": null, - "voter_info": null, - "rex_info": null, - "subjective_cpu_bill_limit": { - "used": 0, - "available": 0, - "max": 0 - }, - "eosio_any_linked_actions": [] - }, - "text": "{\"account_name\":\"boost.wax\",\"head_block_num\":205984,\"head_block_time\":\"2023-11-21T15:46:41.500\",\"privileged\":false,\"last_code_update\":\"2023-11-20T11:10:15.500\",\"created\":\"2023-11-20T11:10:12.500\",\"core_liquid_balance\":\"100000.00000000 WAX\",\"ram_quota\":\"10425432623\",\"net_weight\":1000000000,\"cpu_weight\":1000000000,\"net_limit\":{\"used\":23908,\"available\":1044064080,\"max\":1044087988},\"cpu_limit\":{\"used\":9113,\"available\":70058946,\"max\":70068059},\"ram_usage\":577170,\"permissions\":[{\"perm_name\":\"active\",\"parent\":\"owner\",\"required_auth\":{\"threshold\":1,\"keys\":[{\"key\":\"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV\",\"weight\":1}],\"accounts\":[{\"permission\":{\"actor\":\"boost.wax\",\"permission\":\"eosio.code\"},\"weight\":1}],\"waits\":[]},\"linked_actions\":[]},{\"perm_name\":\"deploy\",\"parent\":\"active\",\"required_auth\":{\"threshold\":1,\"keys\":[{\"key\":\"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV\",\"weight\":1}],\"accounts\":[],\"waits\":[]},\"linked_actions\":[{\"account\":\"eosio\",\"action\":\"setcode\"},{\"account\":\"eosio\",\"action\":\"setabi\"}]},{\"perm_name\":\"owner\",\"parent\":\"\",\"required_auth\":{\"threshold\":1,\"keys\":[{\"key\":\"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV\",\"weight\":1}],\"accounts\":[],\"waits\":[]},\"linked_actions\":[]},{\"perm_name\":\"paybw\",\"parent\":\"active\",\"required_auth\":{\"threshold\":1,\"keys\":[{\"key\":\"EOS8cFt6PzBL79kp9vPwWoX8V6cjwgShbfUsyisiZ1M8QaFgZtep6\",\"weight\":1}],\"accounts\":[],\"waits\":[]},\"linked_actions\":[{\"account\":\"boost.wax\",\"action\":\"noop\"}]}],\"total_resources\":{\"owner\":\"boost.wax\",\"net_weight\":\"10.00000000 WAX\",\"cpu_weight\":\"10.00000000 WAX\",\"ram_bytes\":\"10425431223\"},\"self_delegated_bandwidth\":null,\"refund_request\":null,\"voter_info\":null,\"rex_info\":null,\"subjective_cpu_bill_limit\":{\"used\":0,\"available\":0,\"max\":0},\"eosio_any_linked_actions\":[]}" -} \ No newline at end of file diff --git a/test/data/207db8a082add2a0239f42aed4a1d2aa2435b27a.json b/test/data/207db8a082add2a0239f42aed4a1d2aa2435b27a.json new file mode 100644 index 0000000..b41ae51 --- /dev/null +++ b/test/data/207db8a082add2a0239f42aed4a1d2aa2435b27a.json @@ -0,0 +1,32 @@ +{ + "request": { + "path": "https://wax.greymass.com/v1/chain/get_info", + "params": { + "method": "GET" + } + }, + "status": 200, + "json": { + "server_version": "7aa24ce9", + "chain_id": "1064487b3cd1a897ce03ae5b6a865651747e2e152090f99c1d19d44e01aea5a4", + "head_block_num": 289066283, + "last_irreversible_block_num": 289065947, + "last_irreversible_block_id": "113acbdb0b088d60b5e6fb6c7c923ffdc1034ac6e452cc086b974248c7e82e5b", + "head_block_id": "113acd2bcd90ab0d5c167340fb660ce3deafd23d7c6a9f3c777790bc278efa4f", + "head_block_time": "2024-01-23T10:25:41.500", + "head_block_producer": "alohaeosprod", + "virtual_block_cpu_limit": 219406, + "virtual_block_net_limit": 1048576000, + "block_cpu_limit": 200000, + "block_net_limit": 1048576, + "server_version_string": "v5.0.0wax01", + "fork_db_head_block_num": 289066283, + "fork_db_head_block_id": "113acd2bcd90ab0d5c167340fb660ce3deafd23d7c6a9f3c777790bc278efa4f", + "server_full_version_string": "v5.0.0wax01-7aa24ce9d98c744564840e23833bdbf7ec00af33", + "total_cpu_weight": "41228592284233074", + "total_net_weight": "133497145042255682", + "earliest_available_block_num": 288892579, + "last_irreversible_block_time": "2024-01-23T10:22:53.500" + }, + "text": "{\"server_version\":\"7aa24ce9\",\"chain_id\":\"1064487b3cd1a897ce03ae5b6a865651747e2e152090f99c1d19d44e01aea5a4\",\"head_block_num\":289066283,\"last_irreversible_block_num\":289065947,\"last_irreversible_block_id\":\"113acbdb0b088d60b5e6fb6c7c923ffdc1034ac6e452cc086b974248c7e82e5b\",\"head_block_id\":\"113acd2bcd90ab0d5c167340fb660ce3deafd23d7c6a9f3c777790bc278efa4f\",\"head_block_time\":\"2024-01-23T10:25:41.500\",\"head_block_producer\":\"alohaeosprod\",\"virtual_block_cpu_limit\":219406,\"virtual_block_net_limit\":1048576000,\"block_cpu_limit\":200000,\"block_net_limit\":1048576,\"server_version_string\":\"v5.0.0wax01\",\"fork_db_head_block_num\":289066283,\"fork_db_head_block_id\":\"113acd2bcd90ab0d5c167340fb660ce3deafd23d7c6a9f3c777790bc278efa4f\",\"server_full_version_string\":\"v5.0.0wax01-7aa24ce9d98c744564840e23833bdbf7ec00af33\",\"total_cpu_weight\":\"41228592284233074\",\"total_net_weight\":\"133497145042255682\",\"earliest_available_block_num\":288892579,\"last_irreversible_block_time\":\"2024-01-23T10:22:53.500\"}" +} \ No newline at end of file diff --git a/test/data/4c61f669fd81c11ba85e234f2fc529f966cb2ec6.json b/test/data/4c61f669fd81c11ba85e234f2fc529f966cb2ec6.json deleted file mode 100644 index e887b36..0000000 --- a/test/data/4c61f669fd81c11ba85e234f2fc529f966cb2ec6.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "request": { - "path": "http://127.0.0.1:8888/v1/chain/get_info", - "params": { - "method": "GET" - } - }, - "status": 200, - "json": { - "server_version": "cde348e5", - "chain_id": "8a34ec7df1b8cd06ff4a8abbaa7cc50300823350cadc59ab296cb00d104d2b8f", - "head_block_num": 205984, - "last_irreversible_block_num": 205983, - "last_irreversible_block_id": "0003249fe452cd0b657241a1ee5fb15e1fdbb425042d3bf4b4ca53c2b2134a77", - "head_block_id": "000324a007c9c41e653a55b9710b2b6637b7138eadef32ec44f35e2b1ed978f9", - "head_block_time": "2023-11-21T15:46:41.500", - "head_block_producer": "eosio", - "virtual_block_cpu_limit": 200000000, - "virtual_block_net_limit": 1048576000, - "block_cpu_limit": 199900, - "block_net_limit": 1048576, - "server_version_string": "v3.1.4wax02", - "fork_db_head_block_num": 205984, - "fork_db_head_block_id": "000324a007c9c41e653a55b9710b2b6637b7138eadef32ec44f35e2b1ed978f9", - "server_full_version_string": "v3.1.4wax02-cde348e5e385d0a4c1fea4eca521c1008a4a4b9a", - "total_cpu_weight": "493234726004732", - "total_net_weight": "173542780661934", - "earliest_available_block_num": 1, - "last_irreversible_block_time": "2023-11-21T15:46:41.000" - }, - "text": "{\"server_version\":\"cde348e5\",\"chain_id\":\"8a34ec7df1b8cd06ff4a8abbaa7cc50300823350cadc59ab296cb00d104d2b8f\",\"head_block_num\":205984,\"last_irreversible_block_num\":205983,\"last_irreversible_block_id\":\"0003249fe452cd0b657241a1ee5fb15e1fdbb425042d3bf4b4ca53c2b2134a77\",\"head_block_id\":\"000324a007c9c41e653a55b9710b2b6637b7138eadef32ec44f35e2b1ed978f9\",\"head_block_time\":\"2023-11-21T15:46:41.500\",\"head_block_producer\":\"eosio\",\"virtual_block_cpu_limit\":200000000,\"virtual_block_net_limit\":1048576000,\"block_cpu_limit\":199900,\"block_net_limit\":1048576,\"server_version_string\":\"v3.1.4wax02\",\"fork_db_head_block_num\":205984,\"fork_db_head_block_id\":\"000324a007c9c41e653a55b9710b2b6637b7138eadef32ec44f35e2b1ed978f9\",\"server_full_version_string\":\"v3.1.4wax02-cde348e5e385d0a4c1fea4eca521c1008a4a4b9a\",\"total_cpu_weight\":\"493234726004732\",\"total_net_weight\":\"173542780661934\",\"earliest_available_block_num\":1,\"last_irreversible_block_time\":\"2023-11-21T15:46:41.000\"}" -} \ No newline at end of file diff --git a/test/data/714c990e6ea2e283c39d1f3a8d1b7680fedaed53.json b/test/data/714c990e6ea2e283c39d1f3a8d1b7680fedaed53.json new file mode 100644 index 0000000..0186988 --- /dev/null +++ b/test/data/714c990e6ea2e283c39d1f3a8d1b7680fedaed53.json @@ -0,0 +1,18 @@ +{ + "request": { + "path": "https://wax.greymass.com/v1/chain/get_table_rows", + "params": { + "method": "POST", + "body": "{\"code\":\"eosio\",\"scope\":\"\",\"table\":\"powup.state\",\"key_type\":\"name\",\"json\":false}" + } + }, + "status": 200, + "json": { + "rows": [ + "000092a87508d51305009f1c75a7c183030042f8c30ce420d5010080c6a47e8d030000404c948b320300411caf6500f6b265000000000000004080510100006e10bacb000000085741580000000000e4eccddf170000085741580000000048628c5a000000008c93765a00000000cd85af6500cf8c9e7e4c9201009f1c75a7c18303001619a2ac0e3291000080c6a47e8d030000404c948b320300411caf6500f6b265000000000000004080510100006e10bacb000000085741580000000000e4eccddf17000008574158000000004bb34c9000000000a356344100000000cd85af650100000001000000000000000857415800000000" + ], + "more": false, + "next_key": "" + }, + "text": "{\"rows\":[\"000092a87508d51305009f1c75a7c183030042f8c30ce420d5010080c6a47e8d030000404c948b320300411caf6500f6b265000000000000004080510100006e10bacb000000085741580000000000e4eccddf170000085741580000000048628c5a000000008c93765a00000000cd85af6500cf8c9e7e4c9201009f1c75a7c18303001619a2ac0e3291000080c6a47e8d030000404c948b320300411caf6500f6b265000000000000004080510100006e10bacb000000085741580000000000e4eccddf17000008574158000000004bb34c9000000000a356344100000000cd85af650100000001000000000000000857415800000000\"],\"more\":false,\"next_key\":\"\"}" +} \ No newline at end of file diff --git a/test/data/a5741863b9726fdd5151ef0a057fbc41ce5b1b1a.json b/test/data/a5741863b9726fdd5151ef0a057fbc41ce5b1b1a.json deleted file mode 100644 index 1e47be7..0000000 --- a/test/data/a5741863b9726fdd5151ef0a057fbc41ce5b1b1a.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "request": { - "path": "http://127.0.0.1:8888/v1/chain/get_table_rows", - "params": { - "method": "POST", - "body": "{\"code\":\"eosio\",\"scope\":\"\",\"table\":\"powup.state\",\"key_type\":\"name\",\"json\":false}" - } - }, - "status": 200, - "json": { - "rows": [ - "0000ae59812cc99d00000080dd62b22102008506c2c2adec00000080dd62b22102000080dd62b2210200a23e5b65a23e5b65000000000000004080510100006e10bacb000000085741580000000000e4eccddf170000085741580000000018d18c01000000004d2c8b01000000002a405b6500fc5058418bc001000080dd62b22102007a7904e2d0a002000080dd62b22102000080dd62b2210200a23e5b65a23e5b65000000000000004080510100006e10bacb000000085741580000000000e4eccddf1700000857415800000000869054d5000000008784e7d4000000002a405b650100000001000000000000000857415800000000" - ], - "more": false, - "next_key": "" - }, - "text": "{\"rows\":[\"0000ae59812cc99d00000080dd62b22102008506c2c2adec00000080dd62b22102000080dd62b2210200a23e5b65a23e5b65000000000000004080510100006e10bacb000000085741580000000000e4eccddf170000085741580000000018d18c01000000004d2c8b01000000002a405b6500fc5058418bc001000080dd62b22102007a7904e2d0a002000080dd62b22102000080dd62b2210200a23e5b65a23e5b65000000000000004080510100006e10bacb000000085741580000000000e4eccddf1700000857415800000000869054d5000000008784e7d4000000002a405b650100000001000000000000000857415800000000\"],\"more\":false,\"next_key\":\"\"}" -} \ No newline at end of file diff --git a/test/data/f81ee4f1d7ff04f2dd45675f0f50a4e9094a5d13.json b/test/data/f81ee4f1d7ff04f2dd45675f0f50a4e9094a5d13.json new file mode 100644 index 0000000..7808287 --- /dev/null +++ b/test/data/f81ee4f1d7ff04f2dd45675f0f50a4e9094a5d13.json @@ -0,0 +1,167 @@ +{ + "request": { + "path": "https://wax.greymass.com/v1/chain/get_account", + "params": { + "method": "POST", + "body": "{\"account_name\":\"boost.wax\"}" + } + }, + "status": 200, + "json": { + "account_name": "boost.wax", + "head_block_num": 289066137, + "head_block_time": "2024-01-23T10:24:28.500", + "privileged": false, + "last_code_update": "2022-11-01T21:44:57.500", + "created": "2020-04-09T20:28:34.500", + "core_liquid_balance": "3796281.54208477 WAX", + "ram_quota": 106721149, + "net_weight": "30001100000000", + "cpu_weight": "770055200000000", + "net_limit": { + "used": 2960305, + "available": "40717140941", + "max": "40720101246", + "last_usage_update_time": "2024-01-23T10:24:26.000", + "current_used": 2960219 + }, + "cpu_limit": { + "used": 10699884, + "available": 890363982, + "max": 901063866, + "last_usage_update_time": "2024-01-23T10:24:26.000", + "current_used": 10699574 + }, + "ram_usage": 13138871, + "permissions": [ + { + "perm_name": "active", + "parent": "owner", + "required_auth": { + "threshold": 1, + "keys": [], + "accounts": [ + { + "permission": { + "actor": "admin.wax", + "permission": "active" + }, + "weight": 1 + }, + { + "permission": { + "actor": "boost.wax", + "permission": "eosio.code" + }, + "weight": 1 + } + ], + "waits": [] + }, + "linked_actions": [] + }, + { + "perm_name": "deploy", + "parent": "active", + "required_auth": { + "threshold": 1, + "keys": [], + "accounts": [ + { + "permission": { + "actor": "deploy.wax", + "permission": "all" + }, + "weight": 1 + } + ], + "waits": [] + }, + "linked_actions": [ + { + "account": "eosio", + "action": "setcode" + }, + { + "account": "eosio", + "action": "setabi" + } + ] + }, + { + "perm_name": "owner", + "parent": "", + "required_auth": { + "threshold": 1, + "keys": [], + "accounts": [ + { + "permission": { + "actor": "admin.wax", + "permission": "active" + }, + "weight": 1 + } + ], + "waits": [] + }, + "linked_actions": [] + }, + { + "perm_name": "paybw", + "parent": "active", + "required_auth": { + "threshold": 1, + "keys": [ + { + "key": "EOS5B2c2wNjaq342758aYvE71dTxpBVqHocnRU1aWxUdZAuxbgM6f", + "weight": 1 + } + ], + "accounts": [], + "waits": [] + }, + "linked_actions": [ + { + "account": "boost.wax", + "action": "noop" + } + ] + } + ], + "total_resources": { + "owner": "boost.wax", + "net_weight": "300011.00000000 WAX", + "cpu_weight": "7700552.00000000 WAX", + "ram_bytes": 106719749 + }, + "self_delegated_bandwidth": null, + "refund_request": null, + "voter_info": { + "owner": "boost.wax", + "proxy": "", + "producers": [], + "staked": 0, + "unpaid_voteshare": "0.00000000000000000", + "unpaid_voteshare_last_updated": "1970-01-01T00:00:00.000", + "unpaid_voteshare_change_rate": "0.00000000000000000", + "last_claim_time": "1970-01-01T00:00:00.000", + "last_vote_weight": "0.00000000000000000", + "proxied_vote_weight": "0.00000000000000000", + "is_proxy": 0, + "flags1": 0, + "reserved2": 0, + "reserved3": "0 " + }, + "rex_info": null, + "subjective_cpu_bill_limit": { + "used": 55504, + "available": 0, + "max": 0, + "last_usage_update_time": "2000-01-01T00:00:00.000", + "current_used": 0 + }, + "eosio_any_linked_actions": [] + }, + "text": "{\"account_name\":\"boost.wax\",\"head_block_num\":289066137,\"head_block_time\":\"2024-01-23T10:24:28.500\",\"privileged\":false,\"last_code_update\":\"2022-11-01T21:44:57.500\",\"created\":\"2020-04-09T20:28:34.500\",\"core_liquid_balance\":\"3796281.54208477 WAX\",\"ram_quota\":106721149,\"net_weight\":\"30001100000000\",\"cpu_weight\":\"770055200000000\",\"net_limit\":{\"used\":2960305,\"available\":\"40717140941\",\"max\":\"40720101246\",\"last_usage_update_time\":\"2024-01-23T10:24:26.000\",\"current_used\":2960219},\"cpu_limit\":{\"used\":10699884,\"available\":890363982,\"max\":901063866,\"last_usage_update_time\":\"2024-01-23T10:24:26.000\",\"current_used\":10699574},\"ram_usage\":13138871,\"permissions\":[{\"perm_name\":\"active\",\"parent\":\"owner\",\"required_auth\":{\"threshold\":1,\"keys\":[],\"accounts\":[{\"permission\":{\"actor\":\"admin.wax\",\"permission\":\"active\"},\"weight\":1},{\"permission\":{\"actor\":\"boost.wax\",\"permission\":\"eosio.code\"},\"weight\":1}],\"waits\":[]},\"linked_actions\":[]},{\"perm_name\":\"deploy\",\"parent\":\"active\",\"required_auth\":{\"threshold\":1,\"keys\":[],\"accounts\":[{\"permission\":{\"actor\":\"deploy.wax\",\"permission\":\"all\"},\"weight\":1}],\"waits\":[]},\"linked_actions\":[{\"account\":\"eosio\",\"action\":\"setcode\"},{\"account\":\"eosio\",\"action\":\"setabi\"}]},{\"perm_name\":\"owner\",\"parent\":\"\",\"required_auth\":{\"threshold\":1,\"keys\":[],\"accounts\":[{\"permission\":{\"actor\":\"admin.wax\",\"permission\":\"active\"},\"weight\":1}],\"waits\":[]},\"linked_actions\":[]},{\"perm_name\":\"paybw\",\"parent\":\"active\",\"required_auth\":{\"threshold\":1,\"keys\":[{\"key\":\"EOS5B2c2wNjaq342758aYvE71dTxpBVqHocnRU1aWxUdZAuxbgM6f\",\"weight\":1}],\"accounts\":[],\"waits\":[]},\"linked_actions\":[{\"account\":\"boost.wax\",\"action\":\"noop\"}]}],\"total_resources\":{\"owner\":\"boost.wax\",\"net_weight\":\"300011.00000000 WAX\",\"cpu_weight\":\"7700552.00000000 WAX\",\"ram_bytes\":106719749},\"self_delegated_bandwidth\":null,\"refund_request\":null,\"voter_info\":{\"owner\":\"boost.wax\",\"proxy\":\"\",\"producers\":[],\"staked\":0,\"unpaid_voteshare\":\"0.00000000000000000\",\"unpaid_voteshare_last_updated\":\"1970-01-01T00:00:00.000\",\"unpaid_voteshare_change_rate\":\"0.00000000000000000\",\"last_claim_time\":\"1970-01-01T00:00:00.000\",\"last_vote_weight\":\"0.00000000000000000\",\"proxied_vote_weight\":\"0.00000000000000000\",\"is_proxy\":0,\"flags1\":0,\"reserved2\":0,\"reserved3\":\"0 \"},\"rex_info\":null,\"subjective_cpu_bill_limit\":{\"used\":55504,\"available\":0,\"max\":0,\"last_usage_update_time\":\"2000-01-01T00:00:00.000\",\"current_used\":0},\"eosio_any_linked_actions\":[]}" +} \ No newline at end of file diff --git a/test/powerup.ts b/test/powerup.ts index f5134f2..3a497cc 100644 --- a/test/powerup.ts +++ b/test/powerup.ts @@ -14,8 +14,8 @@ const resources_jungle = new Resources({ api: makeClient('https://jungle4.greymass.com'), }) -const resources_local = new Resources({ - api: makeClient('http://127.0.0.1:8888'), +const resources_wax = new Resources({ + api: makeClient('https://wax.greymass.com'), sampleAccount: 'boost.wax' }) @@ -44,12 +44,12 @@ suite('[eos] powerup - cpu calculations', function () { test('powerup.cpu.us_to_weight', async function () { const powerup = await resources_eos.v1.powerup.get_state() const sample = await resources_eos.getSampledUsage() - assert.equal(powerup.cpu.us_to_weight(sample.cpu, 35868), 403011235) + assert.equal(powerup.cpu.us_to_weight(sample.cpu, 35868), 397914355) }) test('powerup.cpu.weight_to_us', async function () { const powerup = await resources_eos.v1.powerup.get_state() const sample = await resources_eos.getSampledUsage() - assert.equal(powerup.cpu.weight_to_us(sample.cpu, 12930064), 1151) + assert.equal(powerup.cpu.weight_to_us(sample.cpu, 12930064), 1166) }) test('powerup.cpu.allocated', async function () { const powerup = await resources_eos.v1.powerup.get_state() @@ -67,7 +67,7 @@ suite('[eos] powerup - cpu calculations', function () { const powerup = await resources_eos.v1.powerup.get_state() const sample = await resources_eos.getSampledUsage() const price = powerup.cpu.price_per_ms(sample, 60, this.testFixture) - assert.equal(price, 0.0146) + assert.equal(price, 0.0144) }) test('powerup.cpu.price_per_us(1)', async function () { const powerup = await resources_eos.v1.powerup.get_state() @@ -103,22 +103,22 @@ suite('[eos] powerup - cpu calculations', function () { const sample = await resources_eos.getSampledUsage() const price = powerup.cpu.price_per_ms(sample, 1000, this.testFixture) - assert.equal(price, 0.2421) + assert.equal(price, 0.239) const asset = Asset.from(price, '4,EOS') - assert.equal(String(asset), '0.2421 EOS') - assert.equal(asset.value, 0.2421) - assert.equal(Number(asset.units), 2421) + assert.equal(String(asset), '0.2390 EOS') + assert.equal(asset.value, 0.239) + assert.equal(Number(asset.units), 2390) }) test('powerup.cpu.frac()', async function () { const powerup = await resources_eos.v1.powerup.get_state() const sample = await resources_eos.getSampledUsage() const frac1 = powerup.cpu.frac(sample, 100) - assert.equal(frac1, 2942764) + assert.equal(frac1, 2905547) const frac1000 = powerup.cpu.frac(sample, 1000000) - assert.equal(frac1000, 29427660509) + assert.equal(frac1000, 29055489074) }) }) @@ -192,127 +192,126 @@ suite('[jungle] powerup - cpu calculations', function () { const price_us = powerup.cpu.price_per_us(sample, 1000000, this.testFixture) const price_ms = powerup.cpu.price_per_ms(sample, 1000, this.testFixture) assert.equal(price_us, price_ms) - assert.equal(price_ms, 0.466) + assert.equal(price_ms, 0.4601) }) test('powerup.cpu.price_per_ms(1000)', async function () { const powerup = await resources_jungle.v1.powerup.get_state() const sample = await resources_eos.getSampledUsage() const price = powerup.cpu.price_per_ms(sample, 1000, this.testFixture) - assert.equal(price, 0.466) + assert.equal(price, 0.4601) const asset = Asset.from(price, '4,EOS') - assert.equal(String(asset), '0.4660 EOS') - assert.equal(asset.value, 0.466) - assert.equal(Number(asset.units), 4660) + assert.equal(String(asset), '0.4601 EOS') + assert.equal(asset.value, 0.4601) + assert.equal(Number(asset.units), 4601) }) test('powerup.cpu.price_per_ms(1000000)', async function () { const powerup = await resources_jungle.v1.powerup.get_state() const sample = await resources_eos.getSampledUsage() const price = powerup.cpu.price_per_ms(sample, 1000000, this.testFixture) - assert.equal(price, 932.4653) + assert.equal(price, 914.8417) const asset = Asset.from(price, '4,EOS') - assert.equal(String(asset), '932.4653 EOS') - assert.equal(asset.value, 932.4653) - assert.equal(Number(asset.units), 9324653) + assert.equal(String(asset), '914.8417 EOS') + assert.equal(asset.value, 914.8417) + assert.equal(Number(asset.units), 9148417) }) }) -suite('[local] powerup - cpu calculations', function () { +suite('[wax] powerup - cpu calculations', function () { this.slow(200) setup(async function () { - const info = await resources_local.api.v1.chain.get_info() + const info = await resources_wax.api.v1.chain.get_info() this.testFixture = Object.assign({}, defaultFixture, { virtual_block_cpu_limit: info.virtual_block_cpu_limit, virtual_block_net_limit: info.virtual_block_net_limit, }) }) test('powerup.cpu.allocated', async function () { - const powerup = await resources_local.v1.powerup.get_state() + const powerup = await resources_wax.v1.powerup.get_state() - assert.equal(powerup.cpu.allocated, 0.99) + assert.equal(powerup.cpu.allocated, 0.9890078589830127) // 99% represented as float }) test('powerup.cpu.reserved', async function () { - const powerup = await resources_local.v1.powerup.get_state() + const powerup = await resources_wax.v1.powerup.get_state() - assert.equal(powerup.cpu.reserved, 0.000007257176013718749) - // 0.032428358627099564% represented as float + assert.equal(powerup.cpu.reserved, 0.000005473139080385654) }) test('powerup.cpu.price_per_us(1000000)', async function () { - const powerup = await resources_local.v1.powerup.get_state() - const sample = await resources_eos.getSampledUsage() + const powerup = await resources_wax.v1.powerup.get_state() + const sample = await resources_wax.getSampledUsage() const price_us = powerup.cpu.price_per_us(sample, 1000000, this.testFixture) const price_ms = powerup.cpu.price_per_ms(sample, 1000, this.testFixture) assert.equal(price_us, price_ms) - assert.equal(price_ms, 0.19945642) + assert.equal(price_ms, 17.53764085) }) test('powerup.cpu.price_per_ms(1000)', async function () { - const powerup = await resources_local.v1.powerup.get_state() - const sample = await resources_eos.getSampledUsage() + const powerup = await resources_wax.v1.powerup.get_state() + const sample = await resources_wax.getSampledUsage() const price = powerup.cpu.price_per_ms(sample, 1000, this.testFixture) - assert.equal(price, 0.19945642) + assert.equal(price, 17.53764085) const asset = Asset.from(price, '8,WAX') - assert.equal(String(asset), '0.19945642 WAX') - assert.equal(asset.value, 0.19945642) - assert.equal(Number(asset.units), 19945642) + assert.equal(String(asset), '17.53764085 WAX') + assert.equal(asset.value, 17.53764085) + assert.equal(Number(asset.units), 1753764085) }) test('powerup.cpu.price_per_ms(1000000)', async function () { - const powerup = await resources_local.v1.powerup.get_state() - const sample = await resources_local.getSampledUsage() + const powerup = await resources_wax.v1.powerup.get_state() + const sample = await resources_wax.getSampledUsage() const price = powerup.cpu.price_per_ms(sample, 1000000, this.testFixture) - assert.equal(price, 0.2533747) + assert.equal(price, 498962.40065742) const asset = Asset.from(price, '8,WAX') - assert.equal(String(asset), '0.25337470 WAX') - assert.equal(asset.value, 0.2533747) - assert.equal(Number(asset.units), 25337470) + assert.equal(String(asset), '498962.40065742 WAX') + assert.equal(asset.value, 498962.40065742) + assert.equal(Number(asset.units), 49896240065742) }) }) -suite('[local] powerup - net calculations', function () { +suite('[wax] powerup - net calculations', function () { this.slow(200) setup(async function () { - const info = await resources_local.api.v1.chain.get_info() + const info = await resources_wax.api.v1.chain.get_info() this.testFixture = Object.assign({}, defaultFixture, { virtual_block_cpu_limit: info.virtual_block_cpu_limit, virtual_block_net_limit: info.virtual_block_net_limit, }) }) test('powerup.net.allocated', async function () { - const powerup = await resources_local.v1.powerup.get_state() + const powerup = await resources_wax.v1.powerup.get_state() - assert.equal(powerup.net.allocated, 0.99) + assert.equal(powerup.net.allocated, 0.9890078589830127) // 99% represented as float }) test('powerup.net.reserved', async function () { - const powerup = await resources_local.v1.powerup.get_state() + const powerup = await resources_wax.v1.powerup.get_state() - assert.equal(powerup.net.reserved, 0.0000001499001650654894) + assert.equal(powerup.net.reserved, 0.0000010629515032355908) }) test('powerup.net.price_per_kb(1000000000000)', async function () { - const powerup = await resources_local.v1.powerup.get_state() - const sample = await resources_local.getSampledUsage() + const powerup = await resources_wax.v1.powerup.get_state() + const sample = await resources_wax.getSampledUsage() const price = powerup.net.price_per_kb(sample, 1000, this.testFixture) - assert.equal(price, 0.00004831) + assert.equal(price, 0.00451099) const asset = Asset.from(price, '8,WAX') - assert.equal(String(asset), '0.00004831 WAX') - assert.equal(asset.value, 0.00004831) - assert.equal(Number(asset.units), 4831) + assert.equal(String(asset), '0.00451099 WAX') + assert.equal(asset.value, 0.00451099) + assert.equal(Number(asset.units), 451099) }) test('powerup.net.frac()', async function () { - const powerup = await resources_local.v1.powerup.get_state() - const sample = await resources_local.getSampledUsage() + const powerup = await resources_wax.v1.powerup.get_state() + const sample = await resources_wax.getSampledUsage() const frac1000 = powerup.net.frac(sample, 1000000) - assert.equal(frac1000, 5520719) + assert.equal(frac1000, 515521337) }) }) diff --git a/test/rex.ts b/test/rex.ts index 4d990cc..2ab996f 100644 --- a/test/rex.ts +++ b/test/rex.ts @@ -36,9 +36,9 @@ suite('[eos] rex calculations', function () { const price = rex.price_per(usage, 1000) const asset = Asset.from(price, '4,EOS') - assert.equal(String(asset), '0.0671 EOS') - assert.equal(asset.value, 0.0671) - assert.equal(Number(asset.units), 671) + assert.equal(String(asset), '0.0662 EOS') + assert.equal(asset.value, 0.0662) + assert.equal(Number(asset.units), 662) }) test('rex.price_per(10000)', async function () { const rex = await resources.v1.rex.get_state() @@ -46,9 +46,9 @@ suite('[eos] rex calculations', function () { const price = rex.price_per(usage, 10000) const asset = Asset.from(price, '4,EOS') - assert.equal(String(asset), '0.6709 EOS') - assert.equal(asset.value, 0.6709) - assert.equal(Number(asset.units), 6709) + assert.equal(String(asset), '0.6624 EOS') + assert.equal(asset.value, 0.6624) + assert.equal(Number(asset.units), 6624) }) test('rex.price_per(1000000)', async function () { const rex = await resources.v1.rex.get_state() @@ -56,8 +56,8 @@ suite('[eos] rex calculations', function () { const price = rex.price_per(usage, 1000000) const asset = Asset.from(price, '4,EOS') - assert.equal(String(asset), '67.0870 EOS') - assert.equal(asset.value, 67.087) - assert.equal(Number(asset.units), 670870) + assert.equal(String(asset), '66.2386 EOS') + assert.equal(asset.value, 66.2386) + assert.equal(Number(asset.units), 662386) }) })