mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
Fix parsing of settings transactions
This commit is contained in:
@@ -32,6 +32,7 @@ const getOrdersResponse = require('./fixtures/get-orders-response');
|
||||
const getOrderbookResponse = require('./fixtures/get-orderbook-response');
|
||||
const getServerInfoResponse = require('./fixtures/get-server-info-response');
|
||||
const getPathsResponse = require('./fixtures/get-paths-response');
|
||||
const settingsTransactionResponse = require('./fixtures/settings-tx-response');
|
||||
const address = addresses.ACCOUNT;
|
||||
|
||||
const orderbook = {
|
||||
@@ -121,6 +122,13 @@ describe('RippleAPI', function() {
|
||||
_.partial(checkResult, transactionResponse, done));
|
||||
});
|
||||
|
||||
it('getTransaction - settings', function(done) {
|
||||
const hash =
|
||||
'4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA1B';
|
||||
this.api.getTransaction(hash, {},
|
||||
_.partial(checkResult, settingsTransactionResponse, done));
|
||||
});
|
||||
|
||||
it('getTransactions', function(done) {
|
||||
const options = {types: ['payment', 'order'], outgoing: true, limit: 2};
|
||||
this.api.getTransactions(address, options,
|
||||
|
||||
41
test/fixtures/account-set-tx.json
vendored
Normal file
41
test/fixtures/account-set-tx.json
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
10
test/fixtures/mock.js
vendored
10
test/fixtures/mock.js
vendored
@@ -3,7 +3,6 @@
|
||||
const _ = require('lodash');
|
||||
const addresses = require('./addresses');
|
||||
const accountTransactionsResponse = require('./acct-tx-response');
|
||||
const SerializedObject = require('ripple-lib').SerializedObject;
|
||||
const BASE_LEDGER_INDEX = 8819951;
|
||||
|
||||
module.exports.accountTransactionsResponse = accountTransactionsResponse;
|
||||
@@ -645,15 +644,14 @@ const BINARY_TRANSACTION_SYNTH = module.exports.BINARY_TRANSACTION_SYNTH = {
|
||||
validated: true
|
||||
};
|
||||
|
||||
module.exports.transactionResponse = function(request) {
|
||||
const EXAMPLE_TX = _.merge(BINARY_TRANSACTION_SYNTH, BINARY_TRANSACTION, {meta: METADATA});
|
||||
|
||||
module.exports.transactionResponse = function(request, transaction) {
|
||||
return JSON.stringify({
|
||||
id: request.id,
|
||||
status: 'success',
|
||||
type: 'response',
|
||||
result: _.extend({
|
||||
meta: SerializedObject.from_json(METADATA).to_hex(),
|
||||
tx: SerializedObject.from_json(BINARY_TRANSACTION).to_hex()
|
||||
}, BINARY_TRANSACTION_SYNTH)
|
||||
result: transaction || EXAMPLE_TX
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
28
test/fixtures/settings-tx-response.json
vendored
Normal file
28
test/fixtures/settings-tx-response.json
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"type": "settings",
|
||||
"address": "rLVKsA4F9iJBbA6rX2x4wCmkj6drgtqpQe",
|
||||
"id": "4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA1B",
|
||||
"specification": {
|
||||
"requireAuthorization": true,
|
||||
"disallowIncomingXRP": true,
|
||||
"globalFreeze": false,
|
||||
"sequence": 1
|
||||
},
|
||||
"outcome": {
|
||||
"result": "tesSUCCESS",
|
||||
"timestamp": "2014-08-08T16:57:50.000Z",
|
||||
"fee": "0.00001",
|
||||
"balanceChanges": {
|
||||
"rLVKsA4F9iJBbA6rX2x4wCmkj6drgtqpQe": [
|
||||
{
|
||||
"currency": "XRP",
|
||||
"value": "-0.00001"
|
||||
}
|
||||
]
|
||||
},
|
||||
"orderbookChanges": {},
|
||||
"ledgerVersion": 8206418,
|
||||
"indexInLedger": 5,
|
||||
"sequence": 1
|
||||
}
|
||||
}
|
||||
2
test/fixtures/trustline-response.json
vendored
2
test/fixtures/trustline-response.json
vendored
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"Flags": 131072,
|
||||
"Flags": 2228224,
|
||||
"TransactionType": "TrustSet",
|
||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"LimitAmount": {
|
||||
|
||||
@@ -8,6 +8,7 @@ const addresses = require('./fixtures/addresses');
|
||||
const hashes = require('./fixtures/hashes');
|
||||
const accountOffersResponse = require('./fixtures/acct-offers-response');
|
||||
const bookOffers = require('./fixtures/book-offers-response');
|
||||
const accountSetTransactionResponse = require('./fixtures/account-set-tx.json');
|
||||
const paths = require('./fixtures/paths');
|
||||
|
||||
function isUSD(json) {
|
||||
@@ -101,6 +102,10 @@ module.exports = function(port) {
|
||||
assert.strictEqual(request.command, 'tx');
|
||||
if (request.transaction === hashes.VALID_TRANSACTION_HASH) {
|
||||
conn.send(fixtures.transactionResponse(request));
|
||||
} else if (request.transaction ===
|
||||
'4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA1B') {
|
||||
const transaction = accountSetTransactionResponse;
|
||||
conn.send(fixtures.transactionResponse(request, transaction));
|
||||
} else if (request.transaction === hashes.NOTFOUND_TRANSACTION_HASH) {
|
||||
conn.send(fixtures.transactionNotFoundResponse(request));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user