This repository has been archived by the owner on Dec 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Konstantin Shuplenkov
authored
May 5, 2020
1 parent
e34ea52
commit 100d50d
Showing
20 changed files
with
1,929 additions
and
1,031 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
exit: true | ||
timeout: 150000 | ||
file: | ||
- ./lib/test/bootstrap.js |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const { | ||
Transaction, | ||
} = require('@dashevo/dashcore-lib'); | ||
|
||
const wait = require('../wait'); | ||
|
||
/** | ||
* | ||
* @param {DAPIClient} dapiClient | ||
* @param {Address} faucetAddress | ||
* @param {PrivateKey} faucetPrivateKey | ||
* @param {Address} address | ||
* @param {number} amount | ||
* @return {Promise<string>} | ||
*/ | ||
async function fundAddress(dapiClient, faucetAddress, faucetPrivateKey, address, amount) { | ||
const { items: inputs } = await dapiClient.getUTXO(faucetAddress); | ||
|
||
const transaction = new Transaction(); | ||
|
||
transaction.from(inputs.slice(-1)[0]) | ||
.to(address, amount) | ||
.change(faucetAddress) | ||
.fee(668) | ||
.sign(faucetPrivateKey); | ||
|
||
let { blocks: currentBlockHeight } = await dapiClient.getStatus(); | ||
|
||
const transactionId = await dapiClient.sendTransaction(transaction.toBuffer()); | ||
|
||
const desiredBlockHeight = currentBlockHeight + 2; | ||
|
||
do { | ||
({ blocks: currentBlockHeight } = await dapiClient.getStatus()); | ||
await wait(30000); | ||
} while (currentBlockHeight < desiredBlockHeight); | ||
|
||
return transactionId; | ||
} | ||
|
||
module.exports = fundAddress; |
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,3 +1,3 @@ | ||
module.exports = function wait(ms) { | ||
return new Promise(res => setTimeout(res, ms)); | ||
return new Promise((res) => setTimeout(res, ms)); | ||
}; |
Oops, something went wrong.