diff --git a/ts/wasm/__tests__/assets/mock/data/alice.ts b/ts/wasm/__tests__/assets/mock/data/alice.ts index 7811b5b9ca177b9ee163d4e0236214c3b4efc1f4..9dae992e96484444e790be1d2a322d5d14f7f4e4 100644 --- a/ts/wasm/__tests__/assets/mock/data/alice.ts +++ b/ts/wasm/__tests__/assets/mock/data/alice.ts @@ -99,7 +99,12 @@ export default { "precision": 6 }, "posting": { - "account_auths": [], + "account_auths": [ + [ + "guest4test8", + 1 + ] + ], "key_auths": [ [ "STM6a34GANY5LD8deYvvfySSWGd7sPahgVNYoFPapngMUD27pWb45", diff --git a/ts/wasm/__tests__/assets/mock/data/guest4test8.ts b/ts/wasm/__tests__/assets/mock/data/guest4test8.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ce1573986984ab014eb415f1b30364f2e49c1b5 --- /dev/null +++ b/ts/wasm/__tests__/assets/mock/data/guest4test8.ts @@ -0,0 +1,183 @@ +export default { + id: 1, + jsonrpc: '2.0', + result: { + accounts: [ + { + "active": { + "account_auths": [], + "key_auths": [ + [ + "STM7cUebxApQ9N4xFHtVrKKuLbUHCei5QoEhHX7WYx9tXHVCZGXVP", + 1 + ] + ], + "weight_threshold": 1 + }, + "balance": { + "amount": "2", + "nai": "@@000000021", + "precision": 3 + }, + "can_vote": true, + "comment_count": 0, + "created": "2023-05-26T03:07:12", + "curation_rewards": 72010, + "delayed_votes": [ + { + "time": "2024-10-09T23:28:45", + "val": 3339250806 + }, + { + "time": "2024-10-14T11:13:27", + "val": 1703102215 + }, + { + "time": "2024-10-16T09:49:03", + "val": 1702819483 + }, + { + "time": "2024-10-18T14:10:36", + "val": 1702501238 + }, + { + "time": "2024-10-20T11:08:09", + "val": 1702227839 + } + ], + "delegated_vesting_shares": { + "amount": "0", + "nai": "@@000000037", + "precision": 6 + }, + "downvote_manabar": { + "current_mana": 842487485158, + "last_update_time": 1730811981 + }, + "governance_vote_expiration_ts": "2025-10-05T02:07:33", + "hbd_balance": { + "amount": "12", + "nai": "@@000000013", + "precision": 3 + }, + "hbd_last_interest_payment": "1970-01-01T00:00:00", + "hbd_seconds": "0", + "hbd_seconds_last_update": "1970-01-01T00:00:00", + "id": 2458449, + "is_smt": false, + "json_metadata": "[]", + "last_account_recovery": "1970-01-01T00:00:00", + "last_account_update": "2024-03-08T01:31:24", + "last_owner_update": "2023-11-20T11:59:03", + "last_post": "2024-11-05T09:36:03", + "last_post_edit": "2024-11-05T09:36:03", + "last_root_post": "2024-10-29T14:59:36", + "last_vote_time": "2024-11-05T13:06:21", + "lifetime_vote_count": 0, + "memo_key": "STM8m7a4dNtBDAUXZQdjpjYQosEQA4ep1caTRSrwUwH7jhH5TCpJU", + "mined": false, + "name": "guest4test8", + "next_vesting_withdrawal": "1969-12-31T23:59:59", + "open_recurrent_transfers": 0, + "owner": { + "account_auths": [], + "key_auths": [ + [ + "STM6adcTdVnt4iWbfEfiKZmwt6pNsoQnVKheZchL7vnnpCWYwRWDh", + 1 + ] + ], + "weight_threshold": 1 + }, + "pending_claimed_accounts": 0, + "pending_transfers": 0, + "post_bandwidth": 0, + "post_count": 589, + "post_voting_power": { + "amount": "3369949940632", + "nai": "@@000000037", + "precision": 6 + }, + "posting": { + "account_auths": [], + "key_auths": [ + [ + "STM6ooSpKC7jEhujcCakiH881MSgJhddrVb1dNCc1h47wF2nqB9zb", + 1 + ] + ], + "weight_threshold": 1 + }, + "posting_json_metadata": "{\"profile\":{\"name\":\"Tattoo World\",\"about\":\"Tattoo World Community\",\"cover_image\":\"https://files.peakd.com/file/peakd-hive/tattooworld/Portada.jpg\",\"profile_image\":\"https://files.peakd.com/file/peakd-hive/tattooworld/IMG-20230514-WA0266.jpg\",\"website\":\"\",\"location\":\"\",\"pinned\":\"\",\"version\":2}}", + "posting_rewards": 857992, + "previous_owner_update": "2023-11-18T22:53:42", + "proxied_vsf_votes": [ + 0, + 0, + 0, + 0 + ], + "proxy": "", + "received_vesting_shares": { + "amount": "2365791627026", + "nai": "@@000000037", + "precision": 6 + }, + "recovery_account": "leo.voter", + "reset_account": "null", + "reward_hbd_balance": { + "amount": "0", + "nai": "@@000000013", + "precision": 3 + }, + "reward_hive_balance": { + "amount": "0", + "nai": "@@000000021", + "precision": 3 + }, + "reward_vesting_balance": { + "amount": "316265506", + "nai": "@@000000037", + "precision": 6 + }, + "reward_vesting_hive": { + "amount": "186", + "nai": "@@000000021", + "precision": 3 + }, + "savings_balance": { + "amount": "0", + "nai": "@@000000021", + "precision": 3 + }, + "savings_hbd_balance": { + "amount": "56582", + "nai": "@@000000013", + "precision": 3 + }, + "savings_hbd_last_interest_payment": "2024-10-17T22:02:27", + "savings_hbd_seconds": "20014995276", + "savings_hbd_seconds_last_update": "2024-10-22T00:42:27", + "savings_withdraw_requests": 0, + "to_withdraw": 0, + "vesting_shares": { + "amount": "1004158313606", + "nai": "@@000000037", + "precision": 6 + }, + "vesting_withdraw_rate": { + "amount": "0", + "nai": "@@000000037", + "precision": 6 + }, + "voting_manabar": { + "current_mana": 3000664392861, + "last_update_time": 1730811981 + }, + "withdraw_routes": 0, + "withdrawn": 0, + "witnesses_voted_for": 7 + } + ], + }, +}; diff --git a/ts/wasm/__tests__/assets/mock/jsonRpcMock.ts b/ts/wasm/__tests__/assets/mock/jsonRpcMock.ts index 332652e3f0c58591556dbb38a38d6841db2c5977..16151f4ee79389fb25d2852624f31c88d95f1994 100644 --- a/ts/wasm/__tests__/assets/mock/jsonRpcMock.ts +++ b/ts/wasm/__tests__/assets/mock/jsonRpcMock.ts @@ -8,6 +8,7 @@ import directSigners_5 from "./data/directSigners_5"; import directSigners_6 from "./data/directSigners_6"; import alice from "./data/alice"; import hivebuzz from "./data/hivebuzz"; +import guest4test8 from "./data/guest4test8"; export default { "database_api.find_accounts": (params: Record<string, any>) => { @@ -42,6 +43,9 @@ export default { if (accounts.length === 1 && accounts[0] === 'hivebuzz') return hivebuzz; + if (accounts.length === 1 && accounts[0] === 'guest4test8') + return guest4test8; + return; } } satisfies IJsonRpcMockData; diff --git a/ts/wasm/__tests__/detailed/mock_base.ts b/ts/wasm/__tests__/detailed/mock_base.ts index 3912d57c83b0dbe120994b98c6d6c4c9c58132cf..5a8736316326cde962b6f7dce7b751910d7db249 100644 --- a/ts/wasm/__tests__/detailed/mock_base.ts +++ b/ts/wasm/__tests__/detailed/mock_base.ts @@ -848,6 +848,108 @@ test.describe('Wax base mock tests', () => { ]); }); + test('Should be able to get authority trace with mock data for transaction with one required authority with threshold 2 (one signature direct and the other one redirected)', async ({ waxTest }) => { + const retVal = await waxTest(async({ chain }) => { + const sourceTx = chain.createTransactionFromJson({ + "ref_block_num": 55285, + "ref_block_prefix": 3183350724, + "expiration": "2025-03-04T09:40:37", + "operations": [ + { + "type": "vote_operation", + "value": { + "voter": "alice", + "author": "test", + "permlink": "test", + "weight": 10000 + } + } + ], + "signatures": [ + "20a5932916064c776785df77821b0aaaa442af49faab4304083764de0a25de4ab660aec343efdb443ffa479446dfd1f433f3b968ad8f821c9497e4671f762e0d3a", + "2068fd39a6a9751877b707e56adf1b8a814b02a7168e0be906e295daf4e35fbe072bf5dba4bfe5567239ed88aab84449bec09237b504ee5a0afaa1fb1e51770947" + ] + }); + + const tx = await chain.createTransaction(); + + const trace = await tx.generateAuthorityVerificationTrace(false, sourceTx); + + console.log(JSON.stringify(trace.collectedData)); + + return trace.collectedData; + }); + + expect(retVal).toStrictEqual([ + { + "finalAuthorityPath": { + "processedEntry": "alice", + "processedRole": "posting", + "threshold": 2, + "weight": 2, + "recursionDepth": 0, + "processingStatus": { + "entryAccepted": true, + "isOpenAuthority": false + }, + "visitedEntries": [ + { + "processedEntry": "STM5RqVBAVNp5ufMCetQtvLGLJo7unX9nyCBMMrTXRWQ9i1Zzzizh", + "processedRole": "posting", + "threshold": 2, + "weight": 1, + "recursionDepth": 0, + "processingStatus": { + "entryAccepted": false, + "accountAuthorityProcessingDepthExceeded": false, + "accountAuthorityCountExceeded": false, + "accountAuthorityPointsMissingAccount": false, + "hasAccountAuthorityCycle": false, + "hasInsufficientWeight": true, + "hasMatchingPublicKey": true + }, + "visitedEntries": [] + }, + { + "processedEntry": "guest4test8", + "processedRole": "posting", + "threshold": 1, + "weight": 1, + "recursionDepth": 1, + "processingStatus": { + "entryAccepted": true, + "isOpenAuthority": false + }, + "visitedEntries": [ + { + "processedEntry": "STM6ooSpKC7jEhujcCakiH881MSgJhddrVb1dNCc1h47wF2nqB9zb", + "processedRole": "posting", + "threshold": 1, + "weight": 1, + "recursionDepth": 1, + "processingStatus": { + "entryAccepted": true, + "isOpenAuthority": false + }, + "visitedEntries": [] + } + ] + } + ] + }, + "matchingSignatures": [ + { + "signature": "2068fd39a6a9751877b707e56adf1b8a814b02a7168e0be906e295daf4e35fbe072bf5dba4bfe5567239ed88aab84449bec09237b504ee5a0afaa1fb1e51770947", + "signatureKey": "STM5RqVBAVNp5ufMCetQtvLGLJo7unX9nyCBMMrTXRWQ9i1Zzzizh" + }, + { + "signature": "20a5932916064c776785df77821b0aaaa442af49faab4304083764de0a25de4ab660aec343efdb443ffa479446dfd1f433f3b968ad8f821c9497e4671f762e0d3a", + "signatureKey": "STM6ooSpKC7jEhujcCakiH881MSgJhddrVb1dNCc1h47wF2nqB9zb" + }] + } + ]); + }); + test.afterAll(async () => { await closeServer(); });