This repository has been archived by the owner on Dec 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
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 #9 from stellar/sep10signers
Add tests for SEP10 Signer Support
- Loading branch information
Showing
4 changed files
with
191 additions
and
3 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
reports | ||
reports | ||
junit.xml |
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,36 @@ | ||
import { fetch } from "./fetchShim"; | ||
import StellarSdk from "stellar-sdk"; | ||
|
||
const friends = []; | ||
async function friendbot(keyPair) { | ||
const response = await fetch( | ||
`https://friendbot.stellar.org/?addr=${keyPair.publicKey()}` | ||
); | ||
friends.push(keyPair); | ||
expect(response.status).toEqual(200); | ||
} | ||
|
||
friendbot.destroyAllFriends = async function() { | ||
if (friends.length === 0) return; | ||
const accountData = await server.loadAccount(friends[0].publicKey()); | ||
const transactionBuilder = new StellarSDK.TransactionBuilder(accountData, { | ||
fee: StellarSDK.BASE_FEE, | ||
networkPassphrase: StellarSDK.Networks.TESTNET | ||
}); | ||
friends.forEach(keyPair => { | ||
transactionBuilder.addOperation( | ||
StellarSdk.Operations.accountMerge({ | ||
destination: "GAIH3ULLFQ4DGSECF2AR555KZ4KNDGEKN4AFI4SU2M7B43MGK3QJZNSR", | ||
source: keyPair.publicKey() | ||
}) | ||
); | ||
}); | ||
|
||
const tx = transactionBuilder.setTimeout(30).build(); | ||
friends.forEach(keyPair => { | ||
tx.sign(keyPair); | ||
}); | ||
await server.submitTransaction(tx); | ||
}; | ||
|
||
export default friendbot; |
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