mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-04 13:05:49 +00:00
test: run snippets in CI (#2345)
* run snippets in CI * add name, try to avoid building * better printing * refactors * fix getTransaction test
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Client, LedgerResponse, TxResponse } from '../../src'
|
||||
|
||||
const client = new Client('wss://s.altnet.rippletest.net:51233')
|
||||
const client = new Client('wss://s2.ripple.com:51233')
|
||||
|
||||
async function getTransaction(): Promise<void> {
|
||||
await client.connect()
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
AccountSet,
|
||||
convertStringToHex,
|
||||
SignerListSet,
|
||||
Wallet,
|
||||
} from '../../src'
|
||||
|
||||
const client = new Client('wss://s.altnet.rippletest.net:51233')
|
||||
@@ -15,12 +16,8 @@ async function multisigning(): Promise<void> {
|
||||
* In practice, users generally will not have all keys in one spot,
|
||||
* hence, users need to implement a way to get signatures.
|
||||
*/
|
||||
const { wallet: wallet1 } = await client.fundWallet(null, {
|
||||
usageContext: 'code snippets',
|
||||
})
|
||||
const { wallet: wallet2 } = await client.fundWallet(null, {
|
||||
usageContext: 'code snippets',
|
||||
})
|
||||
const wallet1 = Wallet.generate()
|
||||
const wallet2 = Wallet.generate()
|
||||
const { wallet: walletMaster } = await client.fundWallet(null, {
|
||||
usageContext: 'code snippets',
|
||||
})
|
||||
|
||||
@@ -32,9 +32,13 @@ function multisign(transactions: Array<Transaction | string>): string {
|
||||
throw new ValidationError('There were 0 transactions to multisign')
|
||||
}
|
||||
|
||||
transactions.forEach((txOrBlob) => {
|
||||
const tx: Transaction = getDecodedTransaction(txOrBlob)
|
||||
const decodedTransactions: Transaction[] = transactions.map(
|
||||
(txOrBlob: string | Transaction) => {
|
||||
return getDecodedTransaction(txOrBlob)
|
||||
},
|
||||
)
|
||||
|
||||
decodedTransactions.forEach((tx) => {
|
||||
/*
|
||||
* This will throw a more clear error for JS users if any of the supplied transactions has incorrect formatting
|
||||
*/
|
||||
@@ -53,12 +57,6 @@ function multisign(transactions: Array<Transaction | string>): string {
|
||||
}
|
||||
})
|
||||
|
||||
const decodedTransactions: Transaction[] = transactions.map(
|
||||
(txOrBlob: string | Transaction) => {
|
||||
return getDecodedTransaction(txOrBlob)
|
||||
},
|
||||
)
|
||||
|
||||
validateTransactionEquivalence(decodedTransactions)
|
||||
|
||||
return encode(getTransactionWithAllSigners(decodedTransactions))
|
||||
@@ -154,10 +152,11 @@ function compareSigners(left: Signer, right: Signer): number {
|
||||
)
|
||||
}
|
||||
|
||||
const NUM_BITS_IN_HEX = 16
|
||||
|
||||
function addressToBigNumber(address: string): BigNumber {
|
||||
const hex = Buffer.from(decodeAccountID(address)).toString('hex')
|
||||
const numberOfBitsInHex = 16
|
||||
return new BigNumber(hex, numberOfBitsInHex)
|
||||
return new BigNumber(hex, NUM_BITS_IN_HEX)
|
||||
}
|
||||
|
||||
function getDecodedTransaction(txOrBlob: Transaction | string): Transaction {
|
||||
|
||||
Reference in New Issue
Block a user