- TESTING_PUBLIC_KEY
This public key is used to initialize all accounts in the local blockchain and via createAccount It should be used as the active and owner keys when updating auth on accounts you create
- eosjs :
object
This is the standard eosjs library at the core of this library. You have access to the rpc and api members.
- setupTestChain()
Sets up the test chain docker image. Must be the first function called in your suite. Only call once
- addTime(time, [fromBlockTime]) ⇒
Promise.<Number>
Increase time of chain. This function only adds time to the current block time (never reduces). Realize that it is not super accurate.You will definitely increase time by at least the number of seconds you indicate, but likely a few seconds more. So you should not be trying to do super precision tests with this function. Give your tests a few seconds leeway when checking behaviour that does NOT exceed some time span. It will work well for exceeding timeouts, or making large leaps in time, etc.
- getInfo()
Gets general information about the blockchain. Same as https://developers.eos.io/manuals/eos/latest/nodeos/plugins/chain_api_plugin/api-reference/index#operation/get_info
- getBlockHeight()
Gets the head block height
- waitTillBlock(target)
Waits until the specified block has arrived
- dedupeTapos() ⇒
Tapos
Generates the tapos fields for a transaction such that the expireSecods field is randomly generated. This allows for a weak way to deduplicate repeated transactions, which can happen a lot in testing.
- randomWamAccount() ⇒
string
Generates a random *.wam account name
- sleep(milliseconds) ⇒
Promise
Sleeps for the given milliseconds duration
- createAccount(account, [bytes]) ⇒
Promise.<TransactionReceipt>
Create an account on the blockchain
- setContract(account, wasmFile, abiFile) ⇒
Promise.<Contract>
Set a contract on a blockchain account
- updateAuth(account, permission, parent) ⇒
Promise.<TransactionReceipt>
Update permissions and keys on an account
- linkauth(account, requirement, permission, type) ⇒
Promise.<TransactionReceipt>
Link actions to an account permission
- transfer(from, to, quantity, memo) ⇒
Promise.<TransactionReceipt>
Transfer WAX
- getTableRows(code, table, scope, [limit]) ⇒
Promise.<Array>
Get rows from a smart contract table
- genericAction(account, name, data, authorization) ⇒
Promise.<authorization>
Run a generic blockchain action
Kind: global class
Contract
load data to contract table
Kind: instance method of Contract
Api: public
Param | Type | Description |
---|---|---|
tableName | string |
table name |
scopeRowsData | Object |
scope and rows data |
Example
{
scope: [{
id: 1,
name: "daniel111111"
}]
}
Load data to contract table from file
Kind: instance method of Contract
Api: public
Param | Type | Description |
---|---|---|
tableName | string |
table name |
filePath | string |
path to json file |
Call action of contract
Kind: instance method of Contract
Api: public
Param | Type | Description |
---|---|---|
actionName | string |
action name |
permission | Object |
permission to call |
data | Object |
data input to action |
This public key is used to initialize all accounts in the local blockchain and via createAccount It should be used as the active and owner keys when updating auth on accounts you create
This is the standard eosjs library at the core of this library. You have access to the rpc and api members.
Kind: global constant
Example
eosjs.rpc.get_table_rows(...)
eosjs.api.transact(...)
Sets up the test chain docker image. Must be the first function called in your suite. Only call once
Kind: global function
Api: public
Example
beforeAll(async () => {
await setupTestChain():
});
Increase time of chain. This function only adds time to the current block time (never reduces). Realize that it is not super accurate.You will definitely increase time by at least the number of seconds you indicate, but likely a few seconds more. So you should not be trying to do super precision tests with this function. Give your tests a few seconds leeway when checking behaviour that does NOT exceed some time span. It will work well for exceeding timeouts, or making large leaps in time, etc.
Kind: global function
Returns: Promise.<Number>
- The approximate number of milliseconds that the chain time has been increased by (not super reliable - it is usually more)
Api: public
Param | Type | Description |
---|---|---|
time | Number |
Number of seconds to increase the chain time by |
[fromBlockTime] | String |
Optional blocktime string. The time parameter will add to this absolute value as the target to increase. If this is missing, the time value just adds to the current blockchain time time to. |
Gets general information about the blockchain. Same as https://developers.eos.io/manuals/eos/latest/nodeos/plugins/chain_api_plugin/api-reference/index#operation/get_info
Kind: global function
Api: public
Gets the head block height
Kind: global function
Api: public
Waits until the specified block has arrived
Kind: global function
Api: public
Param | Type | Description |
---|---|---|
target | Number |
block height to wait for |
Generates the tapos fields for a transaction such that the expireSecods field is randomly generated. This allows for a weak way to deduplicate repeated transactions, which can happen a lot in testing.
Kind: global function
Returns: Tapos
- tapos object
Api: public
Example
eosjs.api.transact({
actions: [...],
},
dedupeTapos());
Generates a random *.wam account name
Kind: global function
Returns: string
- a random wam account
Api: public
Sleeps for the given milliseconds duration
Kind: global function
Api: public
Param | Type | Description |
---|---|---|
milliseconds | Number |
number of milliseconds to sleep |
Create an account on the blockchain
Kind: global function
Returns: Promise.<TransactionReceipt>
- transaction receipt
Api: public
Param | Type | Default | Description |
---|---|---|---|
account | string |
accouunt name to generate | |
[bytes] | Number |
1000000 |
number of RAM bytes to initialize the account with. Default 1000000 |
setContract(account, wasmFile, abiFile) ⇒ Promise.<Contract>
Set a contract on a blockchain account
Kind: global function
Returns: Promise.<Contract>
- contract instance
Api: public
Param | Type | Description |
---|---|---|
account | string |
accouunt to set the contract on |
wasmFile | string |
wasm file path to set |
abiFile | string |
abi file path to set |
Update permissions and keys on an account
Kind: global function
Returns: Promise.<TransactionReceipt>
- transaction receipt
Api: public
Param | Type | Description |
---|---|---|
account | string |
accouunt to update |
permission | string |
permission to affect. Ex. 'active' |
parent | string |
parent of the above permission. Ex. 'owner' |
Link actions to an account permission
Kind: global function
Returns: Promise.<TransactionReceipt>
- transaction receipt
Api: public
Param | Type | Description |
---|---|---|
account | string |
accouunt to update |
requirement | string |
permission required |
permission | string |
contract to associate |
type | string |
action to assocate on the code above |
Transfer WAX
Kind: global function
Returns: Promise.<TransactionReceipt>
- transaction receipt
Api: public
Param | Type | Description |
---|---|---|
from | string |
accouunt to send from |
to | string |
account to send to |
quantity | string |
amount of WAX to send. Ex: '1.00000000 WAX' |
memo | string |
arbitrary message |
Get rows from a smart contract table
Kind: global function
Returns: Promise.<Array>
- array of table entries
Api: public
Param | Type | Default | Description |
---|---|---|---|
code | string |
contract account to query | |
table | string |
table in the contract to query | |
scope | string |
scope for the table | |
[limit] | Number |
100 |
max rows to return. Default 100 |
Run a generic blockchain action
Kind: global function
Returns: Promise.<authorization>
- transaction receipt
Api: public
Param | Type | Description |
---|---|---|
account | string |
contract account |
name | string |
action to fire |
data | Object |
action data json |
authorization | Authorization |
authorization object. Ie the actor executing the action |