mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
Fixes miscommunication with ripplingDisabled in trustlines (#1481)
This commit is contained in:
@@ -14,16 +14,16 @@ function parseAccountTrustline(trustline: Trustline): FormattedTrustline {
|
|||||||
counterparty: trustline.account,
|
counterparty: trustline.account,
|
||||||
qualityIn: parseQuality(trustline.quality_in) || undefined,
|
qualityIn: parseQuality(trustline.quality_in) || undefined,
|
||||||
qualityOut: parseQuality(trustline.quality_out) || undefined,
|
qualityOut: parseQuality(trustline.quality_out) || undefined,
|
||||||
ripplingDisabled: trustline.no_ripple || undefined,
|
ripplingDisabled: trustline.no_ripple,
|
||||||
frozen: trustline.freeze || undefined,
|
frozen: trustline.freeze,
|
||||||
authorized: trustline.authorized || undefined
|
authorized: trustline.authorized
|
||||||
})
|
})
|
||||||
// rippled doesn't provide the counterparty's qualities
|
// rippled doesn't provide the counterparty's qualities
|
||||||
const counterparty = removeUndefined({
|
const counterparty = removeUndefined({
|
||||||
limit: trustline.limit_peer,
|
limit: trustline.limit_peer,
|
||||||
ripplingDisabled: trustline.no_ripple_peer || undefined,
|
ripplingDisabled: trustline.no_ripple_peer,
|
||||||
frozen: trustline.freeze_peer || undefined,
|
frozen: trustline.freeze_peer,
|
||||||
authorized: trustline.peer_authorized || undefined
|
authorized: trustline.peer_authorized
|
||||||
})
|
})
|
||||||
const state = {
|
const state = {
|
||||||
balance: trustline.balance
|
balance: trustline.balance
|
||||||
|
|||||||
@@ -27,5 +27,14 @@ export default <TestSuite>{
|
|||||||
|
|
||||||
'getTrustlines - no options': async (api, address) => {
|
'getTrustlines - no options': async (api, address) => {
|
||||||
await api.getTrustlines(address)
|
await api.getTrustlines(address)
|
||||||
}
|
},
|
||||||
|
|
||||||
|
'getTrustlines - ripplingDisabled works properly': async (api, address) => {
|
||||||
|
const result = await api.getTrustlines(addresses.FOURTH_ACCOUNT)
|
||||||
|
assertResultMatch(
|
||||||
|
result,
|
||||||
|
RESPONSE_FIXTURES.ripplingDisabled,
|
||||||
|
'getTrustlines'
|
||||||
|
)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
22
test/fixtures/responses/get-trustlines-rippling-disabled.json
vendored
Normal file
22
test/fixtures/responses/get-trustlines-rippling-disabled.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "10000000000",
|
||||||
|
"currency": "ETH",
|
||||||
|
"counterparty": "rEyiXgWXCKsh9wXYRrXCYSgCbR1gj3Xd8b",
|
||||||
|
"ripplingDisabled": true
|
||||||
|
},
|
||||||
|
"counterparty": { "limit": "0", "ripplingDisabled": true },
|
||||||
|
"state": { "balance": "0" }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "10000000000",
|
||||||
|
"currency": "BTC",
|
||||||
|
"counterparty": "rEyiXgWXCKsh9wXYRrXCYSgCbR1gj3Xd8b",
|
||||||
|
"ripplingDisabled": false
|
||||||
|
},
|
||||||
|
"counterparty": { "limit": "0", "ripplingDisabled": true },
|
||||||
|
"state": { "balance": "0" }
|
||||||
|
}
|
||||||
|
]
|
||||||
3
test/fixtures/responses/index.js
vendored
3
test/fixtures/responses/index.js
vendored
@@ -102,7 +102,8 @@ module.exports = {
|
|||||||
item: require('./trustline-item.json'),
|
item: require('./trustline-item.json'),
|
||||||
count: 401
|
count: 401
|
||||||
}),
|
}),
|
||||||
all: require('./get-trustlines-all.json')
|
all: require('./get-trustlines-all.json'),
|
||||||
|
ripplingDisabled: require('./get-trustlines-rippling-disabled.json')
|
||||||
},
|
},
|
||||||
getLedger: {
|
getLedger: {
|
||||||
header: require('./get-ledger'),
|
header: require('./get-ledger'),
|
||||||
|
|||||||
37
test/fixtures/rippled/account-lines.js
vendored
37
test/fixtures/rippled/account-lines.js
vendored
@@ -370,3 +370,40 @@ module.exports.manyItems = function(request, options = {}) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.ripplingDisabled = function(request, options = {}) {
|
||||||
|
_.defaults(options, {
|
||||||
|
ledger: BASE_LEDGER_INDEX
|
||||||
|
});
|
||||||
|
|
||||||
|
return JSON.stringify({
|
||||||
|
id: request.id,
|
||||||
|
status: 'success',
|
||||||
|
type: 'response',
|
||||||
|
result: {
|
||||||
|
account: request.account,
|
||||||
|
marker: options.marker,
|
||||||
|
limit: request.limit,
|
||||||
|
ledger_index: options.ledger,
|
||||||
|
lines: [{'account': 'rEyiXgWXCKsh9wXYRrXCYSgCbR1gj3Xd8b',
|
||||||
|
'balance': '0',
|
||||||
|
'currency': 'ETH',
|
||||||
|
'limit': '10000000000',
|
||||||
|
'limit_peer': '0',
|
||||||
|
'no_ripple': true,
|
||||||
|
'no_ripple_peer': true,
|
||||||
|
'quality_in': 0,
|
||||||
|
'quality_out': 0},
|
||||||
|
{'account': 'rEyiXgWXCKsh9wXYRrXCYSgCbR1gj3Xd8b',
|
||||||
|
'balance': '0',
|
||||||
|
'currency': 'BTC',
|
||||||
|
'limit': '10000000000',
|
||||||
|
'limit_peer': '0',
|
||||||
|
'no_ripple': false,
|
||||||
|
'no_ripple_peer': true,
|
||||||
|
'quality_in': 0,
|
||||||
|
'quality_out': 0}]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -668,6 +668,8 @@ export function createMockRippled(port) {
|
|||||||
conn.send(accountLinesResponse.counterparty(request))
|
conn.send(accountLinesResponse.counterparty(request))
|
||||||
} else if (request.account === addresses.THIRD_ACCOUNT) {
|
} else if (request.account === addresses.THIRD_ACCOUNT) {
|
||||||
conn.send(accountLinesResponse.manyItems(request))
|
conn.send(accountLinesResponse.manyItems(request))
|
||||||
|
} else if (request.account === addresses.FOURTH_ACCOUNT) {
|
||||||
|
conn.send(accountLinesResponse.ripplingDisabled(request))
|
||||||
} else if (request.account === addresses.NOTFOUND) {
|
} else if (request.account === addresses.NOTFOUND) {
|
||||||
conn.send(createResponse(request, fixtures.account_info.notfound))
|
conn.send(createResponse(request, fixtures.account_info.notfound))
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user