@waves/js-test-env
Advanced tools
Comparing version 0.4.2 to 0.5.0
@@ -140,2 +140,9 @@ import { | ||
* By default has 20s timeout and uses current environment node | ||
* | ||
* ### Usage | ||
* ```ts | ||
* const tx = ..... | ||
* await broadcast(tx) | ||
* await waitForTx(tx.id) | ||
* ``` | ||
*/ | ||
@@ -276,2 +283,17 @@ export function waitForTx(txId: string, options?: INodeRequestOptions): Promise<TTx> | ||
* By default uses current environment node and seed as masterSeed | ||
* | ||
* ### Usage | ||
* ```ts | ||
* const wvs = 10 ** 8 | ||
* describe('some suite', () => { | ||
* before(async ()) => { | ||
* await setupAccounts({foo: 1 * wvs, bar: 2 * wvs}) | ||
* }) | ||
* | ||
* it('logs balances', async () => { | ||
* console.log(await balance(address(accounts.foo))) | ||
* console.log(await balance(address(accounts.bar))) | ||
* }) | ||
* }) | ||
* ``` | ||
*/ | ||
@@ -278,0 +300,0 @@ export function setupAccounts(balances: Record<string, number>, options?: ISetupAccountsOptions): Promise<Record<string, string>> |
@@ -98,6 +98,9 @@ "use strict"; | ||
}); | ||
const mtt = global.massTransfer({ transfers }, masterSeed); | ||
await global.broadcast(mtt); | ||
await global.waitForTx(mtt.id); | ||
global.console.log(`Accounts successfully funded`); | ||
const totalAmount = transfers.reduce((acc, { amount }) => acc + +amount, 0); | ||
if (totalAmount > 0) { | ||
const mtt = global.massTransfer({ transfers }, masterSeed); | ||
await global.broadcast(mtt); | ||
await global.waitForTx(mtt.id); | ||
global.console.log(`Accounts successfully funded`); | ||
} | ||
return Object.assign({}, global.env.accounts); | ||
@@ -104,0 +107,0 @@ }; |
{ | ||
"name": "@waves/js-test-env", | ||
"version": "0.4.2", | ||
"version": "0.5.0", | ||
"description": "", | ||
@@ -16,3 +16,5 @@ "main": "dist/index.js", | ||
}, | ||
"files": ["dist"], | ||
"files": [ | ||
"dist" | ||
], | ||
"author": "", | ||
@@ -19,0 +21,0 @@ "license": "ISC", |
18560
391