mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-18 11:15:48 +00:00
Merge branch 'main' into amm
This commit is contained in:
9
.github/pull_request_template.md
vendored
9
.github/pull_request_template.md
vendored
@@ -31,13 +31,6 @@ Please check relevant options, delete irrelevant ones.
|
||||
- [ ] Documentation Updates
|
||||
- [ ] Release
|
||||
|
||||
## Before / After
|
||||
|
||||
<!--
|
||||
If just refactoring / back-end changes, this can be just an in-English description of the change at a technical level.
|
||||
If a UI change, screenshots should be included.
|
||||
-->
|
||||
|
||||
## Test Plan
|
||||
|
||||
<!--
|
||||
@@ -47,4 +40,4 @@ Please describe the tests that you ran to verify your changes and provide instru
|
||||
<!--
|
||||
## Future Tasks
|
||||
For future tasks related to PR.
|
||||
-->
|
||||
-->
|
||||
|
||||
16
.github/workflows/nodejs.yml
vendored
16
.github/workflows/nodejs.yml
vendored
@@ -25,9 +25,9 @@ jobs:
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Setup npm version 7
|
||||
- name: Setup npm version 9
|
||||
run: |
|
||||
npm i -g npm@7 --registry=https://registry.npmjs.org
|
||||
npm i -g npm@9 --registry=https://registry.npmjs.org
|
||||
|
||||
- name: Cache node modules
|
||||
id: cache-nodemodules
|
||||
@@ -66,9 +66,9 @@ jobs:
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Setup npm version 7
|
||||
- name: Setup npm version 9
|
||||
run: |
|
||||
npm i -g npm@7 --registry=https://registry.npmjs.org
|
||||
npm i -g npm@9 --registry=https://registry.npmjs.org
|
||||
|
||||
- name: Cache node modules
|
||||
id: cache-nodemodules
|
||||
@@ -112,9 +112,9 @@ jobs:
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Setup npm version 7
|
||||
- name: Setup npm version 9
|
||||
run: |
|
||||
npm i -g npm@7 --registry=https://registry.npmjs.org
|
||||
npm i -g npm@9 --registry=https://registry.npmjs.org
|
||||
|
||||
- name: Cache node modules
|
||||
id: cache-nodemodules
|
||||
@@ -164,9 +164,9 @@ jobs:
|
||||
run: |
|
||||
docker run --detach --rm --name rippled-service -p 6006:6006 --volume "${{ github.workspace }}/.ci-config/":"/config/" --health-cmd="wget localhost:6006 || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s --env "ENV_ARGS=-a --start" --env GITHUB_ACTIONS=true --env CI=true xrpllabsofficial/xrpld:latest
|
||||
|
||||
- name: Setup npm version 7
|
||||
- name: Setup npm version 9
|
||||
run: |
|
||||
npm i -g npm@7 --registry=https://registry.npmjs.org
|
||||
npm i -g npm@9 --registry=https://registry.npmjs.org
|
||||
|
||||
- name: Cache node modules
|
||||
id: cache-nodemodules
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -69,7 +69,7 @@
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0",
|
||||
"npm": ">=7.0.0 < 9.0.0"
|
||||
"npm": ">=7.0.0 < 10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@ampproject/remapping": {
|
||||
|
||||
@@ -76,6 +76,6 @@
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12.0.0",
|
||||
"npm": ">=7.0.0 < 9.0.0"
|
||||
"npm": ">=7.0.0 < 10.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
## Unreleased
|
||||
|
||||
## 4.2.5 (2023-03-08)
|
||||
|
||||
### Added
|
||||
* Adds support for npm v9
|
||||
### Changed
|
||||
- All tests now use the Jest test runner and have been refactored for consistency across all packages
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
## Unreleased
|
||||
### Added
|
||||
- Allow custom type definitions to be used for encoding/decoding transactions at runtime (e.g. for sidechains/new amendments)
|
||||
* Adds support for npm v9
|
||||
|
||||
## 1.5.0 (2023-03-08)
|
||||
### Changed
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
* Adds support for npm v9
|
||||
|
||||
## 1.1.5 (2023-03-08)
|
||||
### Changed
|
||||
- All tests now use the Jest test runner and have been refactored for consistency across all packages
|
||||
|
||||
@@ -2,3 +2,5 @@ dist
|
||||
node_modules
|
||||
.github
|
||||
.vscode
|
||||
karma.config.js
|
||||
karma-setup.js
|
||||
|
||||
@@ -4,14 +4,15 @@ Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xr
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
* Guard check for signing algorithm used in `Wallet.generate()`
|
||||
* Null and undefined values in transactions are now treated as though the field was not passed in.
|
||||
* Adds support for npm v9
|
||||
|
||||
### Fixed
|
||||
* Fixed `ServerState.transitions` typing, it is now a string instead of a number. (Only used in return from `server_state` request)
|
||||
* Added `destination_amount` to `PathOption` which is returned as part of a `path_find` request
|
||||
* Removed the `decode(encode(tx)) == tx` check from the wallet signing process
|
||||
* Fixed the location of `signer_lists` in the `account_info` response so that it matches rippled
|
||||
* Guard check for signing algorithm used in `Wallet.generate()`
|
||||
* Null and undefined values in transactions are now treated as though the field was not passed in.
|
||||
|
||||
### Removed
|
||||
* RPCs and utils related to the old sidechain design
|
||||
|
||||
@@ -4,5 +4,9 @@ const base = require('../../jest.config.base.js')
|
||||
module.exports = {
|
||||
...base,
|
||||
roots: [...base.roots, '<rootDir>/test'],
|
||||
testMatch: [
|
||||
'<rootDir>/test/integration/**/*.test.ts',
|
||||
'<rootDir>/test/integration/*.test.ts',
|
||||
],
|
||||
displayName: 'xrpl.js',
|
||||
}
|
||||
13
packages/xrpl/jest.config.unit.js
Normal file
13
packages/xrpl/jest.config.unit.js
Normal file
@@ -0,0 +1,13 @@
|
||||
// Jest configuration for api
|
||||
const base = require('../../jest.config.base.js')
|
||||
|
||||
module.exports = {
|
||||
...base,
|
||||
roots: [...base.roots, '<rootDir>/test'],
|
||||
testMatch: ['<rootDir>/test/**/*.test.ts'],
|
||||
testPathIgnorePatterns: [
|
||||
'<rootDir>/test/integration',
|
||||
'<rootDir>/test/fixtures',
|
||||
],
|
||||
displayName: 'xrpl.js',
|
||||
}
|
||||
@@ -30,5 +30,15 @@ module.exports = function (config) {
|
||||
},
|
||||
|
||||
browsers: ['ChromeHeadless'],
|
||||
// runs only one browser at a time
|
||||
concurrency: 1,
|
||||
// CI mode
|
||||
singleRun: true,
|
||||
client: {
|
||||
jasmine: {
|
||||
// ensures that tests are run in order instead of a random order
|
||||
random: false,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@
|
||||
"clean": "rm -rf dist build coverage",
|
||||
"docgen": "tsc --build tsconfig.docs.json && typedoc && echo js.xrpl.org >> ../../docs/CNAME",
|
||||
"prepublish": "npx run-s clean build",
|
||||
"test": "jest --verbose false --silent=false ./test/**/*.test.ts --testPathIgnorePatterns=./test/integration --testPathIgnorePatterns=./test/fixtures",
|
||||
"test:integration": "TS_NODE_PROJECT=tsconfig.build.json jest --verbose false --silent=false --runInBand ./test/integration/**/*.test.ts",
|
||||
"test": "jest --config=jest.config.unit.js --verbose false --silent=false",
|
||||
"test:integration": "TS_NODE_PROJECT=tsconfig.build.json jest --config=jest.config.integration.js --verbose false --silent=false --runInBand",
|
||||
"test:browser": "npm run build && npm run build:browserTests && karma start ./karma.config.js --single-run",
|
||||
"test:watch": "jest --watch --verbose false --silent=false --runInBand ./test/**/*.test.ts --testPathIgnorePatterns=./test/integration --testPathIgnorePatterns=./test/fixtures",
|
||||
"format": "prettier --write '{src,test}/**/*.ts'",
|
||||
|
||||
@@ -437,6 +437,7 @@ describe('Connection', function () {
|
||||
try {
|
||||
await clientContext.client.connect()
|
||||
} catch (error) {
|
||||
// @ts-expect-error -- error.message is expected to be defined
|
||||
expect(error.message).toEqual(
|
||||
"Error: connect() timed out after 5000 ms. If your internet connection is working, the rippled server may be blocked or inaccessible. You can also try setting the 'connectionTimeout' option in the Client constructor.",
|
||||
)
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
/* eslint-disable import/export -- Tells webpack which files exist. */
|
||||
|
||||
// These go first because they're affected by the `ledger_accept`s
|
||||
export * from './transactions/escrowFinish.test'
|
||||
export * from './transactions/escrowCancel.test'
|
||||
|
||||
// Transactions
|
||||
export * from './transactions/accountSet.test'
|
||||
export * from './transactions/checkCancel.test'
|
||||
export * from './transactions/checkCash.test'
|
||||
export * from './transactions/checkCreate.test'
|
||||
export * from './transactions/depositPreauth.test'
|
||||
export * from './transactions/escrowCancel.test'
|
||||
export * from './transactions/escrowCreate.test'
|
||||
export * from './transactions/escrowFinish.test'
|
||||
export * from './transactions/offerCancel.test'
|
||||
export * from './transactions/offerCreate.test'
|
||||
export * from './transactions/payment.test'
|
||||
@@ -16,6 +20,7 @@ export * from './transactions/paymentChannelFund.test'
|
||||
export * from './transactions/signerListSet.test'
|
||||
export * from './transactions/trustSet.test'
|
||||
|
||||
// Requests
|
||||
export * from './requests/accountChannels.test'
|
||||
export * from './requests/accountCurrencies.test'
|
||||
export * from './requests/accountInfo.test'
|
||||
@@ -49,7 +54,6 @@ export * from './integration.test'
|
||||
export * from './onConnect.test'
|
||||
export * from './regularKey.test'
|
||||
export * from './submitAndWait.test'
|
||||
export * from './wallet.test'
|
||||
|
||||
// Because this does 256 ledger accepts, we do it last
|
||||
export * from './transactions/accountDelete.test'
|
||||
|
||||
@@ -8,21 +8,13 @@ import {
|
||||
type XrplIntegrationTestContext,
|
||||
} from '../setup'
|
||||
import {
|
||||
// calculateWaitTimeForTransaction,
|
||||
calculateWaitTimeForTransaction,
|
||||
generateFundedWallet,
|
||||
// getXRPBalance,
|
||||
getXRPBalance,
|
||||
testTransaction,
|
||||
submitTransaction,
|
||||
sendLedgerAccept,
|
||||
} from '../utils'
|
||||
|
||||
// TODO: Fix these tests
|
||||
// NOTE: Because ledger accept is called among multiple tests, the actual ledger close time is not
|
||||
// accurate. It can end up very far into the future. This means that the CancelAfter timer can potentially
|
||||
// need to wait for several minutes to be able to properly complete. Since we are not testing the functionaity
|
||||
// of rippled in this library, only that we are submitting commands properly, we can just test that the EscrowCancel
|
||||
// command was successfully received. If in the future we isolate tests to run on their own rippled instance,
|
||||
// we can uncomment the code in this file to test that the escrow was actually cancelled.
|
||||
|
||||
// how long before each test case times out
|
||||
const TIMEOUT = 50000
|
||||
|
||||
@@ -48,7 +40,7 @@ describe('EscrowCancel', function () {
|
||||
})
|
||||
).result.ledger.close_time
|
||||
|
||||
// const waitTimeInMs = calculateWaitTimeForTransaction(CLOSE_TIME)
|
||||
const waitTimeInMs = calculateWaitTimeForTransaction(CLOSE_TIME)
|
||||
|
||||
const createTx: EscrowCreate = {
|
||||
Account: testContext.wallet.classicAddress,
|
||||
@@ -61,10 +53,10 @@ describe('EscrowCancel', function () {
|
||||
|
||||
await testTransaction(testContext.client, createTx, testContext.wallet)
|
||||
|
||||
// const initialBalanceWallet1 = await getXRPBalance(
|
||||
// testContext.client,
|
||||
// wallet1,
|
||||
// )
|
||||
const initialBalanceWallet1 = await getXRPBalance(
|
||||
testContext.client,
|
||||
wallet1,
|
||||
)
|
||||
|
||||
// check that the object was actually created
|
||||
const accountObjects = (
|
||||
@@ -96,29 +88,25 @@ describe('EscrowCancel', function () {
|
||||
|
||||
// We set the CancelAfter timer to be 3 seconds after the last ledger close_time. We need to wait this long
|
||||
// before we can cancel the escrow.
|
||||
// const cancelAfterTimerPromise = new Promise((resolve) => {
|
||||
// setTimeout(resolve, waitTimeInMs)
|
||||
// })
|
||||
const cancelAfterTimerPromise = new Promise((resolve) => {
|
||||
setTimeout(resolve, waitTimeInMs)
|
||||
})
|
||||
|
||||
// Make sure we wait long enough before canceling the escrow.
|
||||
// await cancelAfterTimerPromise
|
||||
await cancelAfterTimerPromise
|
||||
|
||||
// await testTransaction(testContext.client, cancelTx, testContext.wallet, {
|
||||
// count: 20,
|
||||
// delayMs: 2000,
|
||||
// })
|
||||
|
||||
await submitTransaction({
|
||||
client: testContext.client,
|
||||
transaction: cancelTx,
|
||||
wallet: testContext.wallet,
|
||||
// rippled uses the close time of the previous ledger
|
||||
await sendLedgerAccept(testContext.client)
|
||||
await testTransaction(testContext.client, cancelTx, testContext.wallet, {
|
||||
count: 20,
|
||||
delayMs: 2000,
|
||||
})
|
||||
|
||||
// Make sure the Destination wallet did not receive any XRP.
|
||||
// assert.equal(
|
||||
// await getXRPBalance(testContext.client, wallet1),
|
||||
// initialBalanceWallet1,
|
||||
// )
|
||||
assert.equal(
|
||||
await getXRPBalance(testContext.client, wallet1),
|
||||
initialBalanceWallet1,
|
||||
)
|
||||
},
|
||||
TIMEOUT,
|
||||
)
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
calculateWaitTimeForTransaction,
|
||||
generateFundedWallet,
|
||||
getXRPBalance,
|
||||
sendLedgerAccept,
|
||||
testTransaction,
|
||||
} from '../utils'
|
||||
|
||||
@@ -84,6 +85,8 @@ describe('EscrowFinish', function () {
|
||||
|
||||
await finishAfterPromise
|
||||
|
||||
// rippled uses the close time of the previous ledger
|
||||
await sendLedgerAccept(testContext.client)
|
||||
await testTransaction(testContext.client, finishTx, testContext.wallet)
|
||||
|
||||
const expectedBalance = String(Number(initialBalance) + Number(AMOUNT))
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { TrustSet, percentToQuality } from '../../../src'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { TrustSet, percentToQuality, Wallet } from '../../../src'
|
||||
import serverUrl from '../serverUrl'
|
||||
import {
|
||||
setupClient,
|
||||
@@ -12,16 +14,21 @@ const TIMEOUT = 20000
|
||||
|
||||
describe('TrustSet', function () {
|
||||
let testContext: XrplIntegrationTestContext
|
||||
let wallet2: Wallet | undefined
|
||||
|
||||
beforeEach(async () => {
|
||||
testContext = await setupClient(serverUrl)
|
||||
if (!wallet2) {
|
||||
// eslint-disable-next-line require-atomic-updates -- race condition doesn't really matter
|
||||
wallet2 = await generateFundedWallet(testContext.client)
|
||||
}
|
||||
})
|
||||
afterEach(async () => teardownClient(testContext))
|
||||
|
||||
it(
|
||||
'base',
|
||||
async () => {
|
||||
const wallet2 = await generateFundedWallet(testContext.client)
|
||||
assert(wallet2 != null)
|
||||
const tx: TrustSet = {
|
||||
TransactionType: 'TrustSet',
|
||||
Account: testContext.wallet.classicAddress,
|
||||
@@ -40,14 +47,14 @@ describe('TrustSet', function () {
|
||||
it(
|
||||
'Quality < 1',
|
||||
async () => {
|
||||
const wallet2 = await generateFundedWallet(testContext.client)
|
||||
assert(wallet2 != null)
|
||||
const tx: TrustSet = {
|
||||
TransactionType: 'TrustSet',
|
||||
Account: testContext.wallet.address,
|
||||
QualityIn: percentToQuality('99%'),
|
||||
QualityOut: percentToQuality('99%'),
|
||||
LimitAmount: {
|
||||
currency: 'USD',
|
||||
currency: 'BTC',
|
||||
issuer: wallet2.address,
|
||||
value: '100',
|
||||
},
|
||||
@@ -61,14 +68,14 @@ describe('TrustSet', function () {
|
||||
it(
|
||||
'Quality > 1',
|
||||
async () => {
|
||||
const wallet2 = await generateFundedWallet(testContext.client)
|
||||
assert(wallet2 != null)
|
||||
const tx: TrustSet = {
|
||||
TransactionType: 'TrustSet',
|
||||
QualityIn: percentToQuality('101%'),
|
||||
QualityOut: percentToQuality('101%'),
|
||||
Account: testContext.wallet.address,
|
||||
LimitAmount: {
|
||||
currency: 'USD',
|
||||
currency: 'ETH',
|
||||
issuer: wallet2.address,
|
||||
value: '100',
|
||||
},
|
||||
|
||||
@@ -18,7 +18,7 @@ import { hashSignedTx } from '../../src/utils/hashes'
|
||||
const masterAccount = 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'
|
||||
const masterSecret = 'snoPBrXtMeMyMHUVTgbuqAfg1SUTb'
|
||||
|
||||
async function sendLedgerAccept(client: Client): Promise<unknown> {
|
||||
export async function sendLedgerAccept(client: Client): Promise<unknown> {
|
||||
return client.connection.request({ command: 'ledger_accept' })
|
||||
}
|
||||
|
||||
@@ -253,7 +253,6 @@ export async function testTransaction(
|
||||
},
|
||||
): Promise<SubmitResponse> {
|
||||
// Accept any un-validated changes.
|
||||
await ledgerAccept(client)
|
||||
|
||||
// sign/submit the transaction
|
||||
const response = await submitTransaction({
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import { Wallet } from '../../src'
|
||||
|
||||
const walletSecret = 'shK6YXzwYfnFVn3YZSaMh5zuAddKx'
|
||||
|
||||
const wallet = Wallet.fromSeed(walletSecret)
|
||||
|
||||
export default wallet
|
||||
Reference in New Issue
Block a user