This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #992 from EOSIO/release/22.1.x
Merging release/22.1.x into master
- Loading branch information
Showing
23 changed files
with
1,879 additions
and
1,272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.DS_Store | ||
.idea | ||
.vscode | ||
dist/ | ||
dist-web/ | ||
node_modules/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,145 @@ | ||
import { skipOn } from '@cypress/skip-test'; | ||
|
||
describe('eosjs web test', () => { | ||
it('loads', () => { | ||
cy.visit(('./src/tests/web.html')); | ||
}); | ||
it('runs all tests successfully', () => { | ||
cy.visit(('./src/tests/web.html')) | ||
cy.get('div.tests>div>button').each((test) => { // iterate through all the tests | ||
cy.wrap(test).click(); // click the button to start the test | ||
cy.wrap(test).contains('Success', { timeout: 5000 }); // wait 5 seconds for success or treat as failure | ||
cy.wait(500); // allow time for transaction to confirm (prevents duplicate transactions) | ||
}); | ||
}); | ||
}) | ||
it('loads', () => { | ||
cy.visit(('./src/tests/web.html')); | ||
}); | ||
|
||
it('test Transact With Config Blocks Behind', () => { | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testTransactWithConfigBlocksBehind').click(); | ||
cy.get('#testTransactWithConfigBlocksBehind').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test Transact With Config Use Last Irreversible', () => { | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testTransactWithConfigUseLastIrreversible').click(); | ||
cy.get('#testTransactWithConfigUseLastIrreversible').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test Transact Without Config', () => { | ||
if (Cypress.env('NODEOS_VER')) skipOn(Cypress.env('NODEOS_VER') === 'release/2.0.x'); | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testTransactWithoutConfig').click(); | ||
cy.get('#testTransactWithoutConfig').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test Transact With Compression', () => { | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testTransactWithCompression').click(); | ||
cy.get('#testTransactWithCompression').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test Transact With Context Free Action', () => { | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testTransactWithContextFreeAction').click(); | ||
cy.get('#testTransactWithContextFreeAction').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test Transact With Context Free Data', () => { | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testTransactWithContextFreeData').click(); | ||
cy.get('#testTransactWithContextFreeData').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test Transact Without Broadcast', () => { | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testTransactWithoutBroadcast').click(); | ||
cy.get('#testTransactWithoutBroadcast').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test Broadcast Result', () => { | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testBroadcastResult').click(); | ||
cy.get('#testBroadcastResult').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test Shorthand With Api Json', () => { | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testShorthandWithApiJson').click(); | ||
cy.get('#testShorthandWithApiJson').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test Shorthand With Tx Json', () => { | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testShorthandWithTxJson').click(); | ||
cy.get('#testShorthandWithTxJson').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test Shorthand With Tx Json Context Free Action', () => { | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testShorthandWithTxJsonContextFreeAction').click(); | ||
cy.get('#testShorthandWithTxJsonContextFreeAction').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test Shorthand With Tx Json Context Free Data', () => { | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testShorthandWithTxJsonContextFreeData').click(); | ||
cy.get('#testShorthandWithTxJsonContextFreeData').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test With P256 Elliptic Curve', () => { | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testWithP256EllipticCurve').click(); | ||
cy.get('#testWithP256EllipticCurve').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test With Return Value Tx', () => { | ||
if (Cypress.env('NODEOS_VER')) skipOn(Cypress.env('NODEOS_VER') === 'release/2.0.x'); | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testWithReturnValueTx').click(); | ||
cy.get('#testWithReturnValueTx').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test With Resource Payer Tx', () => { | ||
if (Cypress.env('NODEOS_VER')) skipOn(Cypress.env('NODEOS_VER') === 'release/2.0.x' || Cypress.env('NODEOS_VER') === 'release/2.1.x'); | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testWithResourcePayerTx').click(); | ||
cy.get('#testWithResourcePayerTx').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test With Read Only Query', () => { | ||
if (Cypress.env('NODEOS_VER')) skipOn(Cypress.env('NODEOS_VER') === 'release/2.0.x' || Cypress.env('NODEOS_VER') === 'release/2.1.x'); | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testWithReadOnlyQuery').click(); | ||
cy.get('#testWithReadOnlyQuery').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test With Read Only Failure Trace', () => { | ||
if (Cypress.env('NODEOS_VER')) skipOn(Cypress.env('NODEOS_VER') === 'release/2.0.x' || Cypress.env('NODEOS_VER') === 'release/2.1.x'); | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testWithReadOnlyFailureTrace').click(); | ||
cy.get('#testWithReadOnlyFailureTrace').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test Transact Should Fail', () => { | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testTransactShouldFail').click(); | ||
cy.get('#testTransactShouldFail').contains('Success', { timeout: 5000 }); | ||
}); | ||
|
||
it('test Rpc Should Fail', () => { | ||
cy.visit(('./src/tests/web.html')); | ||
cy.wait(500); | ||
cy.get('#testRpcShouldFail').click(); | ||
cy.get('#testRpcShouldFail').contains('Success', { timeout: 5000 }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
After the release of v2.2 of nodeos, the resource payer feature is available to sponsor the resources for a transaction. To set a separate payer for the resources for a transaction, add a `resource_payer` object to your transaction that specifies the `payer`, `max_net_bytes`, `max_cpu_us`, and `max_memory_bytes`. This functionality requires the `RESOURCE_PAYER` protocol feature to be enabled on the chain. | ||
|
||
A typical use-case for this feature has a service or application pay for the resources of a transaction instead of their users. Since authorization is required for both the user in the transaction and the payer, a possible workflow would have the transaction signed by the user's wallet application and then also signed by the service/application before sent to nodeos. | ||
|
||
```javascript | ||
{ | ||
resource_payer: { | ||
payer: 'alice', | ||
max_net_bytes: 4096, | ||
max_cpu_us: 400, | ||
max_memory_bytes: 0 | ||
}, | ||
actions: [{ | ||
account: 'eosio.token', | ||
name: 'transfer', | ||
authorization: [{ | ||
actor: 'bob', | ||
permission: 'active', | ||
}, { | ||
actor: 'alice', | ||
permission: 'active', | ||
}], | ||
data: { | ||
from: 'bob', | ||
to: 'alice', | ||
quantity: '0.0001 SYS', | ||
memo: 'resource payer', | ||
}, | ||
}] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
When a call to the chain_api is performed and fails, it will result in an RPCError object being generated which contains information on why the transaction failed. | ||
|
||
The RPCError object will contain a concise error message, for instance 'Invalid transaction'. However additional details can be found in the `details` field and the `json` field. The `json` field holds the complete json response from nodeos. The `details` field specifically holds the error object in the `json` field. The data content of the `json` and `details` vary depending on the endpoint is used to call nodeos. Use the `details` field to quickly find error information. | ||
|
||
In the `details` and `json` examples below, you can see that the error message may not contain enough information to discern what caused the action to fail. The error message contains `eosio_assert_message` assertion failure. Looking further at the details you can see an `overdrawn balance` message. | ||
```javascript | ||
RpcError: eosio_assert_message assertion failure | ||
at new RpcError (eosjs-rpcerror.ts:20:13) | ||
at JsonRpc.<anonymous> (eosjs-jsonrpc.ts:90:23) | ||
at step (eosjs-jsonrpc.js:37:23) | ||
at Object.next (eosjs-jsonrpc.js:18:53) | ||
at fulfilled (eosjs-jsonrpc.js:9:58) | ||
at processTicksAndRejections (node:internal/process/task_queues:94:5) { | ||
details: { | ||
code: 3050003, | ||
name: 'eosio_assert_message_exception', | ||
message: 'eosio_assert_message assertion failure', | ||
stack: [ | ||
{ | ||
context: { | ||
level: 'error', | ||
file: 'cf_system.cpp', | ||
line: 14, | ||
method: 'eosio_assert', | ||
hostname: '', | ||
thread_name: 'nodeos', | ||
timestamp: '2021-06-16T05:26:03.665' | ||
}, | ||
format: 'assertion failure with message: ${s}', | ||
data: { s: 'overdrawn balance' } | ||
}, | ||
{ | ||
context: { | ||
level: 'warn', | ||
file: 'apply_context.cpp', | ||
line: 143, | ||
method: 'exec_one', | ||
hostname: '', | ||
thread_name: 'nodeos', | ||
timestamp: '2021-06-16T05:26:03.665' | ||
}, | ||
format: 'pending console output: ${console}', | ||
data: { console: '' } | ||
} | ||
] | ||
}, | ||
json: { | ||
head_block_num: 1079, | ||
head_block_id: '00003384ff2dd671472e8290e7ee0fbc00ee1f450ce5c10de0a9c245ab5b5b22', | ||
last_irreversible_block_num: 1070, | ||
last_irreversible_block_id: '00003383946519b67bac1a0f31898826b472d81fd40b7fccb49a2f486bd292d1', | ||
code_hash: '800bb7fedd86155047064bffdaa3c32cca76cda40eb80f5c4a7676c7f57da579', | ||
pending_transactions: [], | ||
result: { | ||
id: '01a0cbb6c0215df53f07ecdcf0fb750a4134938b38a72946a0f6f25cf3f43bcb', | ||
block_num: 1079, | ||
block_time: '2021-06-14T21:13:04.500', | ||
producer_block_id: null, | ||
receipt: null, | ||
elapsed: 189, | ||
net_usage: 137, | ||
scheduled: false, | ||
action_traces: [Array], | ||
account_ram_delta: null, | ||
except: [Object], | ||
error_code: '10000000000000000000', | ||
bill_to_accounts: [] | ||
} | ||
}, | ||
isFetchError: true | ||
} | ||
``` |
Oops, something went wrong.