Removes methods that were just rippled wrappers (#1550)

* remove getAccountInfo

* remove getAccountObjects

* remove getBalanceSheet (gateway_balances)

* remove getLedger

* remove getOrders (account_orders)

* remove getPaymentChannel (ledger_entry)

* remove getTransaction(s) (tx/account_tx)

* remove getSettings (account_info)

* remove getServerInfo (server_info)

* fix integ tests

* remove submit (also deprecated)

* fix integ tests

* add TODO
This commit is contained in:
Mayukha Vadari
2021-08-23 12:27:37 -04:00
parent 59396c3f8f
commit 0b08de5956
40 changed files with 160 additions and 1948 deletions

View File

@@ -26,7 +26,7 @@ describe('BroadcastClient', function () {
this.mocks.forEach((mock) => mock.expect(Object.assign({}, expected)))
assert(this.client.isConnected())
return this.client
.getServerInfo()
.request({command: "server_info"})
.then(response => {
return checkResult(responses.getServerInfo, response.result.info)
})

View File

@@ -4,6 +4,10 @@ import responses from '../../fixtures/responses'
import {assertResultMatch, TestSuite} from '../../utils'
const {computeLedgerHash: REQUEST_FIXTURES} = requests
function getNewLedger() {
return JSON.parse(JSON.stringify(responses.getLedger.full))
}
/**
* Every test suite exports their tests in the default object.
* - Check out the "TestSuite" type for documentation on the interface.
@@ -11,18 +15,12 @@ const {computeLedgerHash: REQUEST_FIXTURES} = requests
*/
export default <TestSuite>{
'given corrupt data - should fail': async (client, address) => {
const request = {
includeTransactions: true,
includeState: true,
includeAllData: true,
ledgerVersion: 38129
}
const ledger = await client.getLedger(request)
assert.strictEqual(
// @ts-ignore
ledger.transactions[0].rawTransaction,
'{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Amount":"10000000000","Destination":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Fee":"10","Flags":0,"Sequence":62,"SigningPubKey":"034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E","TransactionType":"Payment","TxnSignature":"3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639","hash":"3B1A4E1C9BB6A7208EB146BCDB86ECEA6068ED01466D933528CA2B4C64F753EF","meta":{"AffectedNodes":[{"CreatedNode":{"LedgerEntryType":"AccountRoot","LedgerIndex":"4C6ACBD635B0F07101F7FA25871B0925F8836155462152172755845CE691C49E","NewFields":{"Account":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Balance":"10000000000","Sequence":1}}},{"ModifiedNode":{"FinalFields":{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Balance":"981481999380","Flags":0,"OwnerCount":0,"Sequence":63},"LedgerEntryType":"AccountRoot","LedgerIndex":"B33FDD5CF3445E1A7F2BE9B06336BEBD73A5E3EE885D3EF93F7E3E2992E46F1A","PreviousFields":{"Balance":"991481999390","Sequence":62},"PreviousTxnID":"2485FDC606352F1B0785DA5DE96FB9DBAF43EB60ECBB01B7F6FA970F512CDA5F","PreviousTxnLgrSeq":31317}}],"TransactionIndex":0,"TransactionResult":"tesSUCCESS"},"ledger_index":38129}'
)
const ledger = getNewLedger()
// assert.strictEqual(
// // @ts-ignore
// ledger.transactions[0].rawTransaction,
// '{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Amount":"10000000000","Destination":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Fee":"10","Flags":0,"Sequence":62,"SigningPubKey":"034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E","TransactionType":"Payment","TxnSignature":"3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639","hash":"3B1A4E1C9BB6A7208EB146BCDB86ECEA6068ED01466D933528CA2B4C64F753EF","meta":{"AffectedNodes":[{"CreatedNode":{"LedgerEntryType":"AccountRoot","LedgerIndex":"4C6ACBD635B0F07101F7FA25871B0925F8836155462152172755845CE691C49E","NewFields":{"Account":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Balance":"10000000000","Sequence":1}}},{"ModifiedNode":{"FinalFields":{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Balance":"981481999380","Flags":0,"OwnerCount":0,"Sequence":63},"LedgerEntryType":"AccountRoot","LedgerIndex":"B33FDD5CF3445E1A7F2BE9B06336BEBD73A5E3EE885D3EF93F7E3E2992E46F1A","PreviousFields":{"Balance":"991481999390","Sequence":62},"PreviousTxnID":"2485FDC606352F1B0785DA5DE96FB9DBAF43EB60ECBB01B7F6FA970F512CDA5F","PreviousTxnLgrSeq":31317}}],"TransactionIndex":0,"TransactionResult":"tesSUCCESS"},"ledger_index":38129}'
// )
// @ts-ignore - Change Amount to 12000000000
ledger.transactions[0].rawTransaction =
'{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Amount":"12000000000","Destination":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Fee":"10","Flags":0,"Sequence":62,"SigningPubKey":"034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E","TransactionType":"Payment","TxnSignature":"3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639","hash":"3B1A4E1C9BB6A7208EB146BCDB86ECEA6068ED01466D933528CA2B4C64F753EF","meta":{"AffectedNodes":[{"CreatedNode":{"LedgerEntryType":"AccountRoot","LedgerIndex":"4C6ACBD635B0F07101F7FA25871B0925F8836155462152172755845CE691C49E","NewFields":{"Account":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Balance":"10000000000","Sequence":1}}},{"ModifiedNode":{"FinalFields":{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Balance":"981481999380","Flags":0,"OwnerCount":0,"Sequence":63},"LedgerEntryType":"AccountRoot","LedgerIndex":"B33FDD5CF3445E1A7F2BE9B06336BEBD73A5E3EE885D3EF93F7E3E2992E46F1A","PreviousFields":{"Balance":"991481999390","Sequence":62},"PreviousTxnID":"2485FDC606352F1B0785DA5DE96FB9DBAF43EB60ECBB01B7F6FA970F512CDA5F","PreviousTxnLgrSeq":31317}}],"TransactionIndex":0,"TransactionResult":"tesSUCCESS"},"ledger_index":38129}'
@@ -54,18 +52,12 @@ export default <TestSuite>{
client,
address
) => {
const request = {
includeTransactions: true,
includeState: true,
includeAllData: true,
ledgerVersion: 38129
}
const ledger = await client.getLedger(request)
assert.strictEqual(
// @ts-ignore
ledger.transactions[0].rawTransaction,
'{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Amount":"10000000000","Destination":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Fee":"10","Flags":0,"Sequence":62,"SigningPubKey":"034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E","TransactionType":"Payment","TxnSignature":"3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639","hash":"3B1A4E1C9BB6A7208EB146BCDB86ECEA6068ED01466D933528CA2B4C64F753EF","meta":{"AffectedNodes":[{"CreatedNode":{"LedgerEntryType":"AccountRoot","LedgerIndex":"4C6ACBD635B0F07101F7FA25871B0925F8836155462152172755845CE691C49E","NewFields":{"Account":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Balance":"10000000000","Sequence":1}}},{"ModifiedNode":{"FinalFields":{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Balance":"981481999380","Flags":0,"OwnerCount":0,"Sequence":63},"LedgerEntryType":"AccountRoot","LedgerIndex":"B33FDD5CF3445E1A7F2BE9B06336BEBD73A5E3EE885D3EF93F7E3E2992E46F1A","PreviousFields":{"Balance":"991481999390","Sequence":62},"PreviousTxnID":"2485FDC606352F1B0785DA5DE96FB9DBAF43EB60ECBB01B7F6FA970F512CDA5F","PreviousTxnLgrSeq":31317}}],"TransactionIndex":0,"TransactionResult":"tesSUCCESS"},"ledger_index":38129}'
)
const ledger = getNewLedger()
// assert.strictEqual(
// // @ts-ignore
// ledger.transactions[0].rawTransaction,
// '{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Amount":"10000000000","Destination":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Fee":"10","Flags":0,"Sequence":62,"SigningPubKey":"034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E","TransactionType":"Payment","TxnSignature":"3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639","hash":"3B1A4E1C9BB6A7208EB146BCDB86ECEA6068ED01466D933528CA2B4C64F753EF","meta":{"AffectedNodes":[{"CreatedNode":{"LedgerEntryType":"AccountRoot","LedgerIndex":"4C6ACBD635B0F07101F7FA25871B0925F8836155462152172755845CE691C49E","NewFields":{"Account":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Balance":"10000000000","Sequence":1}}},{"ModifiedNode":{"FinalFields":{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Balance":"981481999380","Flags":0,"OwnerCount":0,"Sequence":63},"LedgerEntryType":"AccountRoot","LedgerIndex":"B33FDD5CF3445E1A7F2BE9B06336BEBD73A5E3EE885D3EF93F7E3E2992E46F1A","PreviousFields":{"Balance":"991481999390","Sequence":62},"PreviousTxnID":"2485FDC606352F1B0785DA5DE96FB9DBAF43EB60ECBB01B7F6FA970F512CDA5F","PreviousTxnLgrSeq":31317}}],"TransactionIndex":0,"TransactionResult":"tesSUCCESS"},"ledger_index":38129}'
// )
// Delete rawTransaction
// @ts-ignore - Delete rawTransaction
delete ledger.transactions[0].rawTransaction
@@ -91,13 +83,7 @@ export default <TestSuite>{
client,
address
) => {
const request = {
includeTransactions: true,
includeState: true,
includeAllData: true,
ledgerVersion: 38129
}
const ledger = await client.getLedger(request)
const ledger = getNewLedger()
assert.strictEqual(
// @ts-ignore
ledger.transactions[0].rawTransaction,
@@ -136,14 +122,8 @@ export default <TestSuite>{
},
'wrong hash': async (client, address) => {
const request = {
includeTransactions: true,
includeState: true,
includeAllData: true,
ledgerVersion: 38129
}
const ledger = await client.getLedger(request)
assertResultMatch(ledger, responses.getLedger.full, 'getLedger')
const ledger = getNewLedger()
assertResultMatch(ledger, getNewLedger(), 'getLedger')
const newLedger = {
...ledger,
parentCloseTime: ledger.closeTime,

View File

@@ -1,35 +0,0 @@
import assert from 'assert'
import _ from 'lodash'
import responses from '../../fixtures/rippled'
import {assertRejects, TestSuite} from '../../utils'
/**
* Every test suite exports their tests in the default object.
* - Check out the "TestSuite" type for documentation on the interface.
* - Check out "test/client/index.ts" for more information about the test runner.
*/
export default <TestSuite>{
'getAccountInfo': async (client, address) => {
const response = await client.getAccountInfo(address)
assert.deepEqual(
_.omit(response, 'id'),
_.omit(responses.account_info.normal, 'id'),
)
},
'getAccountInfo - options undefined': async (client, address) => {
const response = await client.getAccountInfo(address, undefined)
assert.deepEqual(
_.omit(response, 'id'),
_.omit(responses.account_info.normal, 'id'),
)
},
'getAccountInfo - invalid options': async (client, address) => {
await assertRejects(
// @ts-ignore - This is intentionally invalid
client.getAccountInfo(address, {invalid: 'options'}),
client.errors.ValidationError
)
}
}

View File

@@ -1,21 +0,0 @@
import responses from '../../fixtures/responses'
import {TestSuite, assertResultMatch} from '../../utils'
const {getAccountObjects: RESPONSE_FIXTURES} = responses
/**
* Every test suite exports their tests in the default object.
* - Check out the "TestSuite" type for documentation on the interface.
* - Check out "test/client/index.ts" for more information about the test runner.
*/
export default <TestSuite>{
'getAccountObjects': async (client, address) => {
const result = await client.getAccountObjects(address)
assertResultMatch(result.result, RESPONSE_FIXTURES, 'AccountObjectsResponse')
},
'getAccountObjects - invalid options': async (client, address) => {
// @ts-ignore - This is intentionally invalid
const result = await client.getAccountObjects(address, {invalid: 'options'})
assertResultMatch(result.result, RESPONSE_FIXTURES, 'AccountObjectsResponse')
}
}

View File

@@ -1,26 +0,0 @@
import {assertRejects, assertResultMatch, TestSuite} from '../../utils'
/**
* Every test suite exports their tests in the default object.
* - Check out the "TestSuite" type for documentation on the interface.
* - Check out "test/client/index.ts" for more information about the test runner.
*/
export default <TestSuite>{
'getBalanceSheet': async (client, address) => {
await client.getBalanceSheet(address)
},
'getBalanceSheet - invalid options': async (client, address) => {
await assertRejects(
// @ts-ignore - This is intentionally invalid
client.getBalanceSheet(address, {invalid: 'options'}),
client.errors.ValidationError
)
},
'getBalanceSheet - empty': async (client, address) => {
const options = {ledgerVersion: 123456}
const result = await client.getBalanceSheet(address, options)
assertResultMatch(result, {}, 'getBalanceSheet')
}
}

View File

@@ -1,91 +0,0 @@
import assert from 'assert-diff'
import {assertResultMatch, TestSuite} from '../../utils'
import responses from '../../fixtures/responses'
const {getLedger: RESPONSE_FIXTURES} = responses
/**
* Every test suite exports their tests in the default object.
* - Check out the "TestSuite" type for documentation on the interface.
* - Check out "test/client/index.ts" for more information about the test runner.
*/
export default <TestSuite>{
'simple test': async (client) => {
const response = await client.getLedger()
assertResultMatch(response, RESPONSE_FIXTURES.header, 'getLedger')
},
'by hash': async (client) => {
const response = await client.getLedger({
ledgerHash:
'15F20E5FA6EA9770BBFFDBD62787400960B04BE32803B20C41F117F41C13830D'
})
assertResultMatch(response, RESPONSE_FIXTURES.headerByHash, 'getLedger')
},
'future ledger version': async (client) => {
const response = await client.getLedger({ledgerVersion: 14661789})
assert(!!response)
},
'with state as hashes': async (client) => {
const request = {
includeTransactions: true,
includeAllData: false,
includeState: true,
ledgerVersion: 6
}
const response = await client.getLedger(request)
assertResultMatch(
response,
RESPONSE_FIXTURES.withStateAsHashes,
'getLedger'
)
},
'with settings transaction': async (client) => {
const request = {
includeTransactions: true,
includeAllData: true,
ledgerVersion: 4181996
}
const response = await client.getLedger(request)
assertResultMatch(response, RESPONSE_FIXTURES.withSettingsTx, 'getLedger')
},
'with partial payment': async (client) => {
const request = {
includeTransactions: true,
includeAllData: true,
ledgerVersion: 22420574
}
const response = await client.getLedger(request)
assertResultMatch(response, RESPONSE_FIXTURES.withPartial, 'getLedger')
},
'pre 2014 with partial payment': async (client) => {
const request = {
includeTransactions: true,
includeAllData: true,
ledgerVersion: 100001
}
const response = await client.getLedger(request)
assertResultMatch(
response,
RESPONSE_FIXTURES.pre2014withPartial,
'getLedger'
)
},
'full, then computeLedgerHash': async (client) => {
const request = {
includeTransactions: true,
includeState: true,
includeAllData: true,
ledgerVersion: 38129
}
const response = await client.getLedger(request)
assertResultMatch(response, RESPONSE_FIXTURES.full, 'getLedger')
const ledger = {
...response,
parentCloseTime: response.closeTime
}
const hash = client.computeLedgerHash(ledger, {computeTreeHashes: true})
assert.strictEqual(
hash,
'E6DB7365949BF9814D76BCC730B01818EB9136A89DB224F3F9F5AAE4569D758E'
)
}
}

View File

@@ -1,34 +0,0 @@
import responses from '../../fixtures/responses'
import {assertRejects, assertResultMatch, TestSuite} from '../../utils'
export const config = {
// TODO: The mock server right now returns a hard-coded string, no matter
// what "Account" value you pass. We'll need it to support more accurate
// responses before we can turn these tests on.
skipXAddress: true
}
/**
* Every test suite exports their tests in the default object.
* - Check out the "TestSuite" type for documentation on the interface.
* - Check out "test/client/index.ts" for more information about the test runner.
*/
export default <TestSuite>{
'getOrders': async (client, address) => {
const result = await client.getOrders(address)
assertResultMatch(result, responses.getOrders, 'getOrders')
},
'getOrders - limit': async (client, address) => {
const result = await client.getOrders(address, {limit: 20})
assertResultMatch(result, responses.getOrders, 'getOrders')
},
'getOrders - invalid options': async (client, address) => {
await assertRejects(
// @ts-ignore - This is intentionally invalid
client.getOrders(address, {invalid: 'options'}),
client.errors.ValidationError
)
}
}

View File

@@ -1,44 +0,0 @@
import responses from '../../fixtures/responses'
import {assertRejects, assertResultMatch, TestSuite} from '../../utils'
const {getPaymentChannel: RESPONSE_FIXTURES} = responses
/**
* Every test suite exports their tests in the default object.
* - Check out the "TestSuite" type for documentation on the interface.
* - Check out "test/client/index.ts" for more information about the test runner.
*/
export default <TestSuite>{
'getPaymentChannel': async (client, address) => {
const channelId =
'E30E709CF009A1F26E0E5C48F7AA1BFB79393764F15FB108BDC6E06D3CBD8415'
const result = await client.getPaymentChannel(channelId)
assertResultMatch(result, RESPONSE_FIXTURES.normal, 'getPaymentChannel')
},
'getPaymentChannel - full': async (client, address) => {
const channelId =
'D77CD4713AA08195E6B6D0E5BC023DA11B052EBFF0B5B22EDA8AE85345BCF661'
const result = await client.getPaymentChannel(channelId)
assertResultMatch(result, RESPONSE_FIXTURES.full, 'getPaymentChannel')
},
'getPaymentChannel - not found': async (client, address) => {
const channelId =
'DFA557EA3497585BFE83F0F97CC8E4530BBB99967736BB95225C7F0C13ACE708'
await assertRejects(
client.getPaymentChannel(channelId),
client.errors.RippledError,
'entryNotFound'
)
},
'getPaymentChannel - wrong type': async (client, address) => {
const channelId =
'8EF9CCB9D85458C8D020B3452848BBB42EAFDDDB69A93DD9D1223741A4CA562B'
await assertRejects(
client.getPaymentChannel(channelId),
client.errors.NotFoundError,
'Payment channel ledger entry not found'
)
}
}

View File

@@ -1,46 +0,0 @@
import assert from 'assert-diff'
import responses from '../../fixtures/responses'
import {assertResultMatch, TestSuite, assertRejects} from '../../utils'
/**
* Every test suite exports their tests in the default object.
* - Check out the "TestSuite" type for documentation on the interface.
* - Check out "test/client/index.ts" for more information about the test runner.
*/
export default <TestSuite>{
'default': async (client, address) => {
const serverInfo = await client.getServerInfo()
assertResultMatch(serverInfo.result.info, responses.getServerInfo, 'getServerInfo')
},
'error': async (client, address) => {
client.connection.request({
// @ts-ignore TODO: resolve
command: 'config',
data: {returnErrorOnServerInfo: true}
})
try {
await client.getServerInfo()
throw new Error('Should throw NetworkError')
} catch (err) {
assert(err instanceof client.errors.RippledError)
assert.equal(err.message, 'You are placing too much load on the server.')
assert.equal(err.data.error, 'slowDown')
}
},
'no validated ledger': async (client, address) => {
client.connection.request({
// @ts-ignore TODO: resolve
command: 'config',
data: {serverInfoWithoutValidated: true}
})
const serverInfo = await client.getServerInfo()
assert.strictEqual(serverInfo.result.info.network_ledger, 'waiting')
},
'getServerInfo - offline': async (client, address) => {
await client.disconnect()
return assertRejects(client.getServerInfo(), client.errors.NotConnectedError)
}
}

View File

@@ -1,28 +0,0 @@
import responses from '../../fixtures/responses'
import {assertRejects, assertResultMatch, TestSuite} from '../../utils'
const {getSettings: RESPONSE_FIXTURES} = responses
/**
* Every test suite exports their tests in the default object.
* - Check out the "TestSuite" type for documentation on the interface.
* - Check out "test/client/index.ts" for more information about the test runner.
*/
export default <TestSuite>{
'getSettings': async (client, address) => {
const result = await client.getSettings(address)
assertResultMatch(result, RESPONSE_FIXTURES, 'getSettings')
},
'getSettings - options undefined': async (client, address) => {
const result = await client.getSettings(address, undefined)
assertResultMatch(result, RESPONSE_FIXTURES, 'getSettings')
},
'getSettings - invalid options': async (client, address) => {
await assertRejects(
// @ts-ignore - This is intentionally invalid
client.getSettings(address, {invalid: 'options'}),
client.errors.ValidationError
)
}
}

View File

@@ -1,508 +0,0 @@
// import assert from 'assert-diff'
import {
MissingLedgerHistoryError,
NotFoundError,
// UnexpectedError
} from 'xrpl-local/common/errors'
import {PendingLedgerVersionError} from '../../../src/common/errors'
import hashes from '../../fixtures/hashes.json'
// import responses from '../../fixtures/responses'
import ledgerClosed from '../../fixtures/rippled/ledger-close-newer.json'
import {assertRejects, TestSuite} from '../../utils'
// const {getTransaction: RESPONSE_FIXTURES} = responses
function closeLedger(connection) {
connection._ws.emit('message', JSON.stringify(ledgerClosed))
}
/**
* Every test suite exports their tests in the default object.
* - Check out the "TestSuite" type for documentation on the interface.
* - Check out "test/client/index.ts" for more information about the test runner.
*/
export default <TestSuite>{
// 'payment': async (client, address) => {
// const response = await client.getTransaction(hashes.VALID_TRANSACTION_HASH)
// assertResultMatch(response, RESPONSE_FIXTURES.payment, 'getTransaction')
// },
// 'payment - include raw transaction': async (client, address) => {
// const options = {
// includeRawTransaction: true
// }
// const response = await client.getTransaction(
// hashes.VALID_TRANSACTION_HASH,
// options
// )
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.paymentIncludeRawTransaction,
// 'getTransaction'
// )
// },
// 'settings': async (client, address) => {
// const hash =
// '4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA1B'
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.settings, 'getTransaction')
// },
// 'settings - include raw transaction': async (client, address) => {
// const hash =
// '4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA1B'
// const options = {
// includeRawTransaction: true
// }
// const expected = Object.assign({}, RESPONSE_FIXTURES.settings) // Avoid mutating test fixture
// expected.rawTransaction =
// '{"Account":"rLVKsA4F9iJBbA6rX2x4wCmkj6drgtqpQe","Fee":"10","Flags":2147483648,"Sequence":1,"SetFlag":2,"SigningPubKey":"03EA3ADCA632F125EC2CC4F7F6A82DE0DCE2B65290CAC1F22242C5163F0DA9652D","TransactionType":"AccountSet","TxnSignature":"3045022100DE8B666B1A31EA65011B0F32130AB91A5747E32FA49B3054CEE8E8362DBAB98A022040CF0CF254677A8E5CD04C59CA2ED7F6F15F7E184641BAE169C561650967B226","date":460832270,"hash":"4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA1B","inLedger":8206418,"ledger_index":8206418,"meta":{"AffectedNodes":[{"ModifiedNode":{"FinalFields":{"Account":"rLVKsA4F9iJBbA6rX2x4wCmkj6drgtqpQe","Balance":"29999990","Flags":786432,"OwnerCount":0,"Sequence":2},"LedgerEntryType":"AccountRoot","LedgerIndex":"3F5072C4875F32ED770DAF3610A716600ED7C7BB0348FADC7A98E011BB2CD36F","PreviousFields":{"Balance":"30000000","Flags":4194304,"Sequence":1},"PreviousTxnID":"3FB0350A3742BBCC0D8AA3C5247D1AEC01177D0A24D9C34762BAA2FEA8AD88B3","PreviousTxnLgrSeq":8206397}}],"TransactionIndex":5,"TransactionResult":"tesSUCCESS"},"validated":true}'
// const response = await client.getTransaction(hash, options)
// assertResultMatch(response, expected, 'getTransaction')
// },
// 'order': async (client, address) => {
// const hash =
// '10A6FB4A66EE80BED46AAE4815D7DC43B97E944984CCD5B93BCF3F8538CABC51'
// closeLedger(client.connection)
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.order, 'getTransaction')
// },
// 'order with memo': async (client, address) => {
// const hash = hashes.WITH_MEMOS_OFFER_CREATE_TRANSACTION_HASH
// closeLedger(client.connection)
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.orderWithMemo, 'getTransaction')
// },
// 'sell order': async (client, address) => {
// const hash =
// '458101D51051230B1D56E9ACAFAA34451BF65FA000F95DF6F0FF5B3A62D83FC2'
// closeLedger(client.connection)
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.orderSell, 'getTransaction')
// },
// 'order cancellation': async (client, address) => {
// const hash =
// '809335DD3B0B333865096217AA2F55A4DF168E0198080B3A090D12D88880FF0E'
// closeLedger(client.connection)
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.orderCancellation,
// 'getTransaction'
// )
// },
// 'order with expiration cancellation': async (client, address) => {
// const hash =
// '097B9491CC76B64831F1FEA82EAA93BCD728106D90B65A072C933888E946C40B'
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.orderWithExpirationCancellation,
// 'getTransaction'
// )
// },
// 'order cancellation with memo': async (client, address) => {
// const hash = hashes.WITH_MEMOS_ORDER_CANCELLATION_TRANSACTION_HASH
// closeLedger(client.connection)
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.orderCancellationWithMemo,
// 'getTransaction'
// )
// },
// 'trustline set': async (client, address) => {
// const hash =
// '635A0769BD94710A1F6A76CDE65A3BC661B20B798807D1BBBDADCEA26420538D'
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.trustline, 'getTransaction')
// },
// 'trustline frozen off': async (client, address) => {
// const hash =
// 'FE72FAD0FA7CA904FB6C633A1666EDF0B9C73B2F5A4555D37EEF2739A78A531B'
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.trustlineFrozenOff,
// 'getTransaction'
// )
// },
// 'trustline no quality': async (client, address) => {
// const hash =
// 'BAF1C678323C37CCB7735550C379287667D8288C30F83148AD3C1CB019FC9002'
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.trustlineNoQuality,
// 'getTransaction'
// )
// },
// 'trustline add memo': async (client, address) => {
// const hash =
// '9D6AC5FD6545B2584885B85E36759EB6440CDD41B6C55859F84AFDEE2B428220'
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.trustlineAddMemo,
// 'getTransaction'
// )
// },
// 'not validated': async (client, address) => {
// const hash =
// '4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA10'
// await assertRejects(
// client.getTransaction(hash),
// NotFoundError,
// 'Transaction not found'
// )
// },
// 'tracking on': async (client, address) => {
// const hash =
// '8925FC8844A1E930E2CC76AD0A15E7665AFCC5425376D548BB1413F484C31B8C'
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.trackingOn, 'getTransaction')
// },
// 'tracking off': async (client, address) => {
// const hash =
// 'C8C5E20DFB1BF533D0D81A2ED23F0A3CBD1EF2EE8A902A1D760500473CC9C582'
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.trackingOff, 'getTransaction')
// },
// 'set regular key': async (client, address) => {
// const hash =
// '278E6687C1C60C6873996210A6523564B63F2844FB1019576C157353B1813E60'
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.setRegularKey,
// 'getTransaction'
// )
// },
'not found in range': async (client, address) => {
const hash =
'809335DD3B0B333865096217AA2F55A4DF168E0198080B3A090D12D88880FF0E'
const options = {
minLedgerVersion: 32570,
maxLedgerVersion: 32571
}
await assertRejects(client.getTransaction(hash, options), NotFoundError)
},
'not found by hash': async (client, address) => {
const hash = hashes.NOTFOUND_TRANSACTION_HASH
await assertRejects(client.getTransaction(hash), NotFoundError)
},
'missing ledger history': async (client, address) => {
const hash = hashes.NOTFOUND_TRANSACTION_HASH
// make gaps in history
closeLedger(client.connection)
await assertRejects(client.getTransaction(hash), MissingLedgerHistoryError)
},
'missing ledger history with ledger range': async (client, address) => {
const hash = hashes.NOTFOUND_TRANSACTION_HASH
const options = {
minLedgerVersion: 32569,
maxLedgerVersion: 32571
}
await assertRejects(
client.getTransaction(hash, options),
MissingLedgerHistoryError
)
},
'not found - future maxLedgerVersion': async (client, address) => {
const hash = hashes.NOTFOUND_TRANSACTION_HASH
const options = {
maxLedgerVersion: 99999999999
}
await assertRejects(
client.getTransaction(hash, options),
PendingLedgerVersionError,
"maxLedgerVersion is greater than server's most recent validated ledger"
)
},
'transaction not validated': async (client, address) => {
const hash =
'4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA11'
await assertRejects(
client.getTransaction(hash),
NotFoundError,
/Transaction has not been validated yet/
)
},
// 'transaction ledger not found': async (client, address) => {
// const hash =
// '4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA12'
// await assertRejects(
// client.getTransaction(hash),
// NotFoundError,
// /ledger not found/
// )
// },
// 'ledger missing close time': async (client, address) => {
// const hash =
// '0F7ED9F40742D8A513AE86029462B7A6768325583DF8EE21B7EC663019DD6A04'
// closeLedger(client.connection)
// await assertRejects(client.getTransaction(hash), UnexpectedError)
// },
// Checks
// 'CheckCreate': async (client, address) => {
// const hash =
// '605A2E2C8E48AECAF5C56085D1AEAA0348DC838CE122C9188F94EB19DA05C2FE'
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.checkCreate, 'getTransaction')
// },
// 'CheckCreate with memo': async (client, address) => {
// const hash = hashes.WITH_MEMOS_CHECK_CREATE_TRANSACTION_HASH
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.checkCreateWithMemo, 'getTransaction')
// },
// 'CheckCancel': async (client, address) => {
// const hash =
// 'B4105D1B2D83819647E4692B7C5843D674283F669524BD50C9614182E3A12CD4'
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.checkCancel, 'getTransaction')
// },
// 'CheckCancel with memo': async (client, address) => {
// const hash = hashes.WITH_MEMOS_CHECK_CANCEL_TRANSACTION_HASH
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.checkCancelWithMemo, 'getTransaction')
// },
// 'CheckCash': async (client, address) => {
// const hash =
// '8321208465F70BA52C28BCC4F646BAF3B012BA13B57576C0336F42D77E3E0749'
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.checkCash, 'getTransaction')
// },
// 'CheckCash with memo': async (client, address) => {
// const hash = hashes.WITH_MEMOS_CHECK_CASH_TRANSACTION_HASH
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.checkCashWithMemo, 'getTransaction')
// },
// Escrows
// 'EscrowCreation': async (client, address) => {
// const hash =
// '144F272380BDB4F1BD92329A2178BABB70C20F59042C495E10BF72EBFB408EE1'
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.escrowCreation,
// 'getTransaction'
// )
// },
// 'EscrowCancellation': async (client, address) => {
// const hash =
// 'F346E542FFB7A8398C30A87B952668DAB48B7D421094F8B71776DA19775A3B22'
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.escrowCancellation,
// 'getTransaction'
// )
// },
// 'EscrowExecution': async (client, address) => {
// const options = {
// minLedgerVersion: 10,
// maxLedgerVersion: 15
// }
// const hash =
// 'CC5277137B3F25EE8B86259C83CB0EAADE818505E4E9BCBF19B1AC6FD136993B'
// const response = await client.getTransaction(hash, options)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.escrowExecution,
// 'getTransaction'
// )
// },
// 'EscrowExecution simple': async (client, address) => {
// const hash =
// 'CC5277137B3F25EE8B86259C83CB0EAADE818505E4E9BCBF19B1AC6FD1369931'
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.escrowExecutionSimple,
// 'getTransaction'
// )
// },
// 'PaymentChannelCreate': async (client, address) => {
// const hash =
// '0E9CA3AB1053FC0C1CBAA75F636FE1EC92F118C7056BBEF5D63E4C116458A16D'
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.paymentChannelCreate,
// 'getTransaction'
// )
// },
// 'PaymentChannelCreate with memo': async (client, address) => {
// const hash = hashes.WITH_MEMOS_PAYMENT_CHANNEL_CREATE_TRANSACTION_HASH
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.paymentChannelCreateWithMemo,
// 'getTransaction'
// )
// },
// 'PaymentChannelFund': async (client, address) => {
// const hash =
// 'CD053D8867007A6A4ACB7A432605FE476D088DCB515AFFC886CF2B4EB6D2AE8B'
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.paymentChannelFund,
// 'getTransaction'
// )
// },
// 'PaymentChannelFund with memo': async (client, address) => {
// const hash = hashes.WITH_MEMOS_PAYMENT_CHANNEL_FUND_TRANSACTION_HASH
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.paymentChannelFundWithMemo,
// 'getTransaction'
// )
// },
// 'PaymentChannelClaim': async (client, address) => {
// const hash =
// '81B9ECAE7195EB6E8034AEDF44D8415A7A803E14513FDBB34FA984AB37D59563'
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.paymentChannelClaim,
// 'getTransaction'
// )
// },
// 'PaymentChannelClaim with memo': async (client, address) => {
// const hash = hashes.WITH_MEMOS_PAYMENT_CHANNEL_CLAIM_TRANSACTION_HASH
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.paymentChannelClaimWithMemo,
// 'getTransaction'
// )
// },
// 'AccountDelete': async (client, address) => {
// const hash =
// 'EC2AB14028DC84DE525470AB4DAAA46358B50A8662C63804BFF38244731C0CB9'
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.accountDelete,
// 'getTransaction'
// )
// },
// 'AccountDelete with memo': async (client, address) => {
// const hash = hashes.WITH_MEMOS_ACCOUNT_DELETE_TRANSACTION_HASH
// const response = await client.getTransaction(hash)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.accountDeleteWithMemo,
// 'getTransaction'
// )
// },
// 'no Meta': async (client, address) => {
// const hash =
// 'AFB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA1B'
// const response = await client.getTransaction(hash)
// assert.deepEqual(response, RESPONSE_FIXTURES.noMeta)
// },
// 'Unrecognized transaction type': async (client, address) => {
// const hash =
// 'AFB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA11'
// closeLedger(client.connection)
// const response = await client.getTransaction(hash)
// assert.strictEqual(
// // @ts-ignore
// response.specification.UNAVAILABLE,
// 'Unrecognized transaction type.'
// )
// },
// 'amendment': async (client, address) => {
// const hash =
// 'A971B83ABED51D83749B73F3C1AAA627CD965AFF74BE8CD98299512D6FB0658F'
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.amendment)
// },
// 'feeUpdate': async (client, address) => {
// const hash =
// 'C6A40F56127436DCD830B1B35FF939FD05B5747D30D6542572B7A835239817AF'
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.feeUpdate)
// },
// 'feeUpdate with memo': async (client, address) => {
// const hash = hashes.WITH_MEMOS_FEE_UPDATE_TRANSACTION_HASH
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.feeUpdateWithMemo)
// },
// 'order with one memo': async (client, address) => {
// const hash =
// '995570FE1E40F42DF56BFC80503BA9E3C1229619C61A1C279A76BC0805036D74'
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.withMemo)
// },
// 'order with more than one memo': async (client, address) => {
// const hash =
// '995570FE1E40F42DF56BFC80503BA9E3C1229619C61A1C279A76BC0805036D73'
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.withMemos)
// },
// 'ticketCreate with memo': async (client, address) => {
// const hash = hashes.WITH_MEMOS_TICKET_CREATE_TRANSACTION_HASH
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.ticketCreateWithMemo)
// },
// 'depositPreauth with memo': async (client, address) => {
// const hash = hashes.WITH_MEMOS_DEPOSIT_PREAUTH_TRANSACTION_HASH
// const response = await client.getTransaction(hash)
// assertResultMatch(response, RESPONSE_FIXTURES.depositPreauthWithMemo)
// }
}

View File

@@ -1,169 +0,0 @@
// import {Client} from 'xrpl-local'
// import assert from 'assert-diff'
import { TestSuite, assertRejects} from '../../utils'
// import responses from '../../fixtures/responses'
import hashes from '../../fixtures/hashes.json'
// import addresses from '../../fixtures/addresses.json'
// const utils = Client._PRIVATE.ledgerUtils
// const {getTransactions: RESPONSE_FIXTURES} = responses
/**
* Every test suite exports their tests in the default object.
* - Check out the "TestSuite" type for documentation on the interface.
* - Check out "test/client/index.ts" for more information about the test runner.
*/
export default <TestSuite>{
// 'default': async (client, address) => {
// const options = {types: ['payment', 'order'], initiated: true, limit: 2}
// const response = await client.getTransactions(address, options)
// hack(response)
// assertResultMatch(response, RESPONSE_FIXTURES.normal, 'getTransactions')
// },
// 'include raw transactions': async (client, address) => {
// const options = {
// types: ['payment', 'order'],
// initiated: true,
// limit: 2,
// includeRawTransactions: true
// }
// const response = await client.getTransactions(address, options)
// assertResultMatch(
// response,
// RESPONSE_FIXTURES.includeRawTransactions,
// 'getTransactions'
// )
// },
// 'earliest first': async (client, address) => {
// const options = {
// types: ['payment', 'order'],
// initiated: true,
// limit: 2,
// earliestFirst: true
// }
// const expected = Array.from(RESPONSE_FIXTURES.normal as any[]).sort(
// utils.compareTransactions
// )
// const response = await client.getTransactions(address, options)
// hack(response)
// assertResultMatch(response, expected, 'getTransactions')
// },
// 'earliest first with start option': async (client, address) => {
// const options = {
// types: ['payment', 'order'],
// initiated: true,
// limit: 2,
// start: hashes.VALID_TRANSACTION_HASH,
// earliestFirst: true
// }
// const response = await client.getTransactions(address, options)
// assert.strictEqual(response.length, 0)
// },
// 'gap': async (client, address) => {
// const options = {
// types: ['payment', 'order'],
// initiated: true,
// limit: 2,
// maxLedgerVersion: 348858000
// }
// return assertRejects(
// client.getTransactions(address, options),
// client.errors.MissingLedgerHistoryError
// )
// },
'tx not found': async (client, address) => {
const options = {
types: ['payment', 'order'],
initiated: true,
limit: 2,
start: hashes.NOTFOUND_TRANSACTION_HASH,
counterparty: address
}
return assertRejects(
client.getTransactions(address, options),
client.errors.NotFoundError
)
},
// 'filters': async (client, address) => {
// const options = {
// types: ['payment', 'order'],
// initiated: true,
// limit: 10,
// excludeFailures: true,
// counterparty: addresses.ISSUER
// }
// const response = await client.getTransactions(address, options)
// hack(response)
// assert.strictEqual(response.length, 10)
// response.forEach((t) => assert(t.type === 'payment' || t.type === 'order'))
// response.forEach((t) => assert(t.outcome.result === 'tesSUCCESS'))
// },
// 'filters for incoming': async (client, address) => {
// const options = {
// types: ['payment', 'order'],
// initiated: false,
// limit: 10,
// excludeFailures: true,
// counterparty: addresses.ISSUER
// }
// const response = await client.getTransactions(address, options)
// hack(response)
// assert.strictEqual(response.length, 10)
// response.forEach((t) => assert(t.type === 'payment' || t.type === 'order'))
// response.forEach((t) => assert(t.outcome.result === 'tesSUCCESS'))
// },
// this is the case where core.RippleError just falls
// through the client to the user
'error': async (client, address) => {
const options = {types: ['payment', 'order'], initiated: true, limit: 13}
return assertRejects(
client.getTransactions(address, options),
client.errors.RippleError
)
},
// TODO: this doesn't test much, just that it doesn't crash
// 'getTransactions with start option': async (client, address) => {
// const options = {
// start: hashes.VALID_TRANSACTION_HASH,
// earliestFirst: false,
// limit: 2
// }
// const response = await client.getTransactions(address, options)
// hack(response)
// assertResultMatch(response, RESPONSE_FIXTURES.normal, 'getTransactions')
// },
// 'start transaction with zero ledger version': async (client, address) => {
// const options = {
// start: '4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA13',
// limit: 1
// }
// const response = await client.getTransactions(address, options)
// hack(response)
// assertResultMatch(response, [], 'getTransactions')
// },
// 'no options': async (client, address) => {
// const response = await client.getTransactions(addresses.OTHER_ACCOUNT)
// assertResultMatch(response, RESPONSE_FIXTURES.one, 'getTransactions')
// }
}
// This test relies on the binary (hex string) format, but computed fields like `date`
// are not available in this format. To support this field, we need to 'hack' it into
// the expected response. Long term, a better approach would be to use/test the json
// format responses, instead of the binary.
// function hack(response) {
// response.forEach((element) => {
// element.outcome.timestamp = '2019-04-01T07:39:01.000Z'
// })
// }

View File

@@ -1,19 +0,0 @@
// import responses from '../../fixtures/responses'
import {TestSuite} from '../../utils'
/**
* Every test suite exports their tests in the default object.
* - Check out the "TestSuite" type for documentation on the interface.
* - Check out "test/client/index.ts" for more information about the test runner.
*/
export default <TestSuite>{
// 'submit': async (client, address) => {
// const result = await client.submit(responses.sign.normal.signedTransaction)
// assertResultMatch(result, responses.submit, 'submit')
// },
// 'submit - failure': async (client, address) => {
// await assertRejects(client.submit('BAD'), client.errors.RippledError)
// // assert.strictEqual(error.data.resultCode, 'temBAD_FEE')
// }
}

View File

@@ -182,7 +182,7 @@ describe('Connection', function () {
data: {disconnectOnServerInfo: true}
})
return this.client
.getServerInfo()
.request({command: "server_info"})
.then(() => {
assert(false, 'Should throw DisconnectedError')
})
@@ -211,7 +211,7 @@ describe('Connection', function () {
callback({message: 'not connected'})
}
return this.client
.getServerInfo()
.request({command: "server_info"})
.then(() => {
assert(false, 'Should throw DisconnectedError')
})

View File

@@ -11,46 +11,51 @@
"transactionHash": "DB83BF807416C5B3499A73130F843CF615AB8E797D79FE7D330ADF1BFA93951A",
"transactions": [
{
"type": "payment",
"address": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
"sequence": 62,
"id": "3B1A4E1C9BB6A7208EB146BCDB86ECEA6068ED01466D933528CA2B4C64F753EF",
"specification": {
"source": {
"address": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
"maxAmount": {
"currency": "XRP",
"value": "10000"
"Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
"Amount": "10000000000",
"Destination": "rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj",
"Fee": "10",
"Flags": 0,
"Sequence": 62,
"SigningPubKey": "034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E",
"TransactionType": "Payment",
"TxnSignature": "3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639",
"hash": "3B1A4E1C9BB6A7208EB146BCDB86ECEA6068ED01466D933528CA2B4C64F753EF",
"metaData": {
"AffectedNodes": [
{
"CreatedNode": {
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "4C6ACBD635B0F07101F7FA25871B0925F8836155462152172755845CE691C49E",
"NewFields": {
"Account": "rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj",
"Balance": "10000000000",
"Sequence": 1
}
}
},
{
"ModifiedNode": {
"FinalFields": {
"Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
"Balance": "981481999380",
"Flags": 0,
"OwnerCount": 0,
"Sequence": 63
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "B33FDD5CF3445E1A7F2BE9B06336BEBD73A5E3EE885D3EF93F7E3E2992E46F1A",
"PreviousFields": {
"Balance": "991481999390",
"Sequence": 62
},
"PreviousTxnID": "2485FDC606352F1B0785DA5DE96FB9DBAF43EB60ECBB01B7F6FA970F512CDA5F",
"PreviousTxnLgrSeq": 31317
}
}
},
"destination": {
"address": "rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj"
}
},
"outcome": {
"result": "tesSUCCESS",
"fee": "0.00001",
"deliveredAmount": {
"currency": "XRP",
"value": "10000"
},
"balanceChanges": {
"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj": [
{
"currency": "XRP",
"value": "10000"
}
],
"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV": [
{
"currency": "XRP",
"value": "-10000.00001"
}
]
},
"orderbookChanges": {},
"indexInLedger": 0,
"ledgerVersion": 38129
],
"TransactionIndex": 0,
"TransactionResult": "tesSUCCESS"
},
"rawTransaction": "{\"Account\":\"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV\",\"Amount\":\"10000000000\",\"Destination\":\"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj\",\"Fee\":\"10\",\"Flags\":0,\"Sequence\":62,\"SigningPubKey\":\"034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E\",\"TransactionType\":\"Payment\",\"TxnSignature\":\"3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639\",\"hash\":\"3B1A4E1C9BB6A7208EB146BCDB86ECEA6068ED01466D933528CA2B4C64F753EF\",\"meta\":{\"AffectedNodes\":[{\"CreatedNode\":{\"LedgerEntryType\":\"AccountRoot\",\"LedgerIndex\":\"4C6ACBD635B0F07101F7FA25871B0925F8836155462152172755845CE691C49E\",\"NewFields\":{\"Account\":\"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj\",\"Balance\":\"10000000000\",\"Sequence\":1}}},{\"ModifiedNode\":{\"FinalFields\":{\"Account\":\"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV\",\"Balance\":\"981481999380\",\"Flags\":0,\"OwnerCount\":0,\"Sequence\":63},\"LedgerEntryType\":\"AccountRoot\",\"LedgerIndex\":\"B33FDD5CF3445E1A7F2BE9B06336BEBD73A5E3EE885D3EF93F7E3E2992E46F1A\",\"PreviousFields\":{\"Balance\":\"991481999390\",\"Sequence\":62},\"PreviousTxnID\":\"2485FDC606352F1B0785DA5DE96FB9DBAF43EB60ECBB01B7F6FA970F512CDA5F\",\"PreviousTxnLgrSeq\":31317}}],\"TransactionIndex\":0,\"TransactionResult\":\"tesSUCCESS\"},\"ledger_index\":38129}"
}

View File

@@ -22,15 +22,19 @@ function acceptLedger(client) {
return client.connection.request({command: 'ledger_accept'})
}
function verifyTransaction(testcase, hash, type, options, txData, address) {
function verifyTransaction(testcase, hash, type, options, txData, account) {
console.log('VERIFY...')
return testcase.client
.getTransaction(hash, options)
.then((data) => {
assert(data && data.outcome)
assert.strictEqual(data.type, type)
assert.strictEqual(data.address, address)
assert.strictEqual(data.outcome.result, 'tesSUCCESS')
.request({
command: 'tx',
transaction: hash,
min_ledger: options.minLedgerVersion,
max_ledger: options.maxLedgerVersion
}).then((data) => {
assert(data && data.result)
assert.strictEqual(data.result.TransactionType, type)
assert.strictEqual(data.result.Account, account)
assert.strictEqual(data.result.meta.TransactionResult, 'tesSUCCESS')
if (testcase.transactions != null) {
testcase.transactions.push(hash)
}
@@ -48,7 +52,7 @@ function verifyTransaction(testcase, hash, type, options, txData, address) {
type,
options,
txData,
address
account
).then(resolve, reject),
INTERVAL
)
@@ -74,15 +78,15 @@ function testTransaction(
const signedData = testcase.client.sign(txJSON, secret)
console.log('PREPARED...')
return testcase.client
.submit(signedData.signedTransaction)
.then((data) =>
.request({command: 'submit', tx_blob: signedData.signedTransaction})
.then((response) =>
testcase.test.title.indexOf('multisign') !== -1
? acceptLedger(testcase.client).then(() => data)
: data
? acceptLedger(testcase.client).then(() => response)
: response
)
.then((data) => {
.then((response) => {
console.log('SUBMITTED...')
assert.strictEqual(data.resultCode, 'tesSUCCESS')
assert.strictEqual(response.result.engine_result, 'tesSUCCESS')
const options = {
minLedgerVersion: lastClosedLedgerVersion,
maxLedgerVersion: txData.LastLedgerSequence
@@ -137,7 +141,7 @@ function makeTrustLine(testcase, address, secret) {
if (address === wallet.getAddress()) {
testcase.transactions.push(signed.id)
}
return client.submit(signed.signedTransaction)
return client.request({command: 'submit', tx_blob: signed.signedTransaction})
})
.then(() => ledgerAccept(client))
return trust
@@ -147,7 +151,7 @@ function makeOrder(client, address, specification, secret) {
return client
.prepareOrder(address, specification)
.then((data) => client.sign(data.txJSON, secret))
.then((signed) => client.submit(signed.signedTransaction))
.then((signed) => client.request({command: 'submit', tx_blob: signed.signedTransaction}))
.then(() => ledgerAccept(client))
}
@@ -163,7 +167,7 @@ function setupAccounts(testcase) {
return client
.prepareSettings(masterAccount, {defaultRipple: true})
.then((data) => client.sign(data.txJSON, masterSecret))
.then((signed) => client.submit(signed.signedTransaction))
.then((signed) => client.request({command: 'submit', tx_blob: signed.signedTransaction}))
.then(() => ledgerAccept(client))
})
.then(() =>
@@ -254,16 +258,6 @@ describe('integration tests', function () {
beforeEach(_.partial(setup, serverUrl))
afterEach(teardown)
it('settings', function () {
return this.client.getLedgerVersion().then((ledgerVersion) => {
return this.client
.prepareSettings(address, requests.prepareSettings.domain, instructions)
.then((prepared) =>
testTransaction(this, 'settings', ledgerVersion, prepared)
)
})
})
it('trustline', function () {
return this.client.getLedgerVersion().then((ledgerVersion) => {
return this.client
@@ -273,7 +267,7 @@ describe('integration tests', function () {
instructions
)
.then((prepared) =>
testTransaction(this, 'trustline', ledgerVersion, prepared)
testTransaction(this, 'TrustSet', ledgerVersion, prepared)
)
})
})
@@ -294,7 +288,7 @@ describe('integration tests', function () {
return this.client
.preparePayment(address, paymentSpecification, instructions)
.then((prepared) =>
testTransaction(this, 'payment', ledgerVersion, prepared)
testTransaction(this, 'Payment', ledgerVersion, prepared)
)
})
})
@@ -312,24 +306,38 @@ describe('integration tests', function () {
value: '0.0002'
}
}
const expectedOrder = {
flags: 0,
quality: "1.185",
taker_gets: '200',
taker_pays: {
currency: 'USD',
value: '237',
issuer: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
}
}
return this.client.getLedgerVersion().then((ledgerVersion) => {
return this.client
.prepareOrder(address, orderSpecification, instructions)
.then((prepared) =>
testTransaction(this, 'order', ledgerVersion, prepared)
testTransaction(this, 'OfferCreate', ledgerVersion, prepared)
)
.then((result) => {
const txData = JSON.parse(result.txJSON)
return this.client.getOrders(address).then((orders) => {
return this.client.request({
command: 'account_offers',
account: address
}).then(response => response.result.offers)
.then((orders) => {
assert(orders && orders.length > 0)
const createdOrder = (
orders.filter((order) => {
return order.properties.sequence === txData.Sequence
return order.seq === txData.Sequence
})
)[0]
assert(createdOrder)
assert.strictEqual(createdOrder.properties.maker, address)
assert.deepEqual(createdOrder.specification, orderSpecification)
delete createdOrder.seq
assert.deepEqual(createdOrder, expectedOrder)
return txData
})
})
@@ -343,7 +351,7 @@ describe('integration tests', function () {
.then((prepared) =>
testTransaction(
this,
'orderCancellation',
'OfferCancel',
ledgerVersion,
prepared
)
@@ -356,12 +364,6 @@ describe('integration tests', function () {
assert(this.client.isConnected())
})
it('getServerInfo', function () {
return this.client.getServerInfo().then((data) => {
assert(data && data.result.info.pubkey_node)
})
})
it('getFee', function () {
return this.client.getFee().then((fee) => {
assert.strictEqual(typeof fee, 'string')
@@ -377,19 +379,6 @@ describe('integration tests', function () {
})
})
it('getTransactions', function () {
const options = {
initiated: true,
minLedgerVersion: this.startLedgerVersion
}
return this.client
.getTransactions(address, options)
.then((transactionsData) => {
assert(transactionsData)
assert.strictEqual(transactionsData.length, this.transactions.length)
})
})
it('getTrustlines', function () {
const fixture = requests.prepareTrustline.simple
const { currency, counterparty } = fixture
@@ -414,13 +403,6 @@ describe('integration tests', function () {
})
})
it('getSettings', function () {
return this.client.getSettings(address).then((data) => {
assert(data)
assert.strictEqual(data.domain, requests.prepareSettings.domain.domain)
})
})
it('getOrderbook', function () {
const orderbook = {
base: {
@@ -545,7 +527,7 @@ describe('integration tests - standalone rippled', function () {
.then((prepared) => {
return testTransaction(
this,
'settings',
'SignerListSet',
ledgerVersion,
prepared,
address,
@@ -576,15 +558,15 @@ describe('integration tests - standalone rippled', function () {
signed2.signedTransaction
])
return this.client
.submit(combined.signedTransaction)
.request({command: 'submit', tx_blob: combined.signedTransaction})
.then((response) => acceptLedger(this.client).then(() => response))
.then((response) => {
assert.strictEqual(response.resultCode, 'tesSUCCESS')
assert.strictEqual(response.result.engine_result, 'tesSUCCESS')
const options = {minLedgerVersion}
return verifyTransaction(
this,
combined.id,
'settings',
'AccountSet',
options,
{},
address

View File

@@ -36,8 +36,9 @@ function pay(client, from, to, amount, secret, currency = 'XRP', counterparty) {
.then(data => client.sign(data.txJSON, secret))
.then(signed => {
id = signed.id;
return client.submit(signed.signedTransaction);
return client.request({command: 'submit', tx_blob: signed.signedTransaction});
})
// TODO: add better error handling here
.then(() => ledgerAccept(client))
.then(() => id);
}