mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-21 04:35:49 +00:00
cover src/api/transaction/payment.js with unit tests
This commit is contained in:
@@ -50,6 +50,18 @@ describe('RippleAPI', function() {
|
||||
_.partial(checkResult, responses.preparePayment, done));
|
||||
});
|
||||
|
||||
it('preparePayment with all options specified', function(done) {
|
||||
this.api.preparePayment(address, requests.preparePaymentAllOptions,
|
||||
instructions,
|
||||
_.partial(checkResult, responses.preparePaymentAllOptions, done));
|
||||
});
|
||||
|
||||
it('preparePayment without counterparty set', function(done) {
|
||||
this.api.preparePayment(address, requests.preparePaymentNoCounterparty,
|
||||
instructions,
|
||||
_.partial(checkResult, responses.preparePaymentNoCounterparty, done));
|
||||
});
|
||||
|
||||
it('prepareOrder', function(done) {
|
||||
this.api.prepareOrder(address, requests.prepareOrder, instructions,
|
||||
_.partial(checkResult, responses.prepareOrder, done));
|
||||
|
||||
2
test/fixtures/api/requests/index.js
vendored
2
test/fixtures/api/requests/index.js
vendored
@@ -3,6 +3,8 @@
|
||||
module.exports = {
|
||||
prepareOrder: require('./prepare-order'),
|
||||
preparePayment: require('./prepare-payment'),
|
||||
preparePaymentAllOptions: require('./prepare-payment-all-options'),
|
||||
preparePaymentNoCounterparty: require('./prepare-payment-no-counterparty'),
|
||||
prepareSettings: require('./prepare-settings'),
|
||||
prepareTrustline: require('./prepare-trustline'),
|
||||
sign: require('./sign')
|
||||
|
||||
30
test/fixtures/api/requests/prepare-payment-all-options.json
vendored
Normal file
30
test/fixtures/api/requests/prepare-payment-all-options.json
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"source": {
|
||||
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"amount": {
|
||||
"value": "0.01",
|
||||
"currency": "XRP"
|
||||
},
|
||||
"tag": 14
|
||||
},
|
||||
"destination": {
|
||||
"address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||
"amount": {
|
||||
"value": "0.01",
|
||||
"currency": "XRP"
|
||||
},
|
||||
"tag": 58
|
||||
},
|
||||
"memos": [
|
||||
{
|
||||
"type": "test",
|
||||
"format": "plain/text",
|
||||
"data": "texted data"
|
||||
}
|
||||
],
|
||||
"invoiceID": "A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A",
|
||||
"allowPartialPayment": true,
|
||||
"noDirectRipple": true,
|
||||
"limitQuality": true,
|
||||
"paths": "[[{\"account\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"currency\":\"USD\",\"issuer\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"type\":49,\"type_hex\":\"0000000000000031\"},{\"currency\":\"LTC\",\"issuer\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"type\":48,\"type_hex\":\"0000000000000030\"},{\"account\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"currency\":\"LTC\",\"issuer\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"type\":49,\"type_hex\":\"0000000000000031\"}]]"
|
||||
}
|
||||
30
test/fixtures/api/requests/prepare-payment-no-counterparty.json
vendored
Normal file
30
test/fixtures/api/requests/prepare-payment-no-counterparty.json
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"source": {
|
||||
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"amount": {
|
||||
"value": "0.01",
|
||||
"currency": "USD"
|
||||
},
|
||||
"tag": 14
|
||||
},
|
||||
"destination": {
|
||||
"address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||
"amount": {
|
||||
"value": "0.01",
|
||||
"currency": "LTC"
|
||||
},
|
||||
"tag": 58
|
||||
},
|
||||
"memos": [
|
||||
{
|
||||
"type": "test",
|
||||
"format": "plain/text",
|
||||
"data": "texted data"
|
||||
}
|
||||
],
|
||||
"invoiceID": "A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A",
|
||||
"allowPartialPayment": true,
|
||||
"noDirectRipple": true,
|
||||
"limitQuality": true,
|
||||
"paths": "[[{\"account\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"currency\":\"USD\",\"issuer\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"type\":49,\"type_hex\":\"0000000000000031\"},{\"currency\":\"LTC\",\"issuer\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"type\":48,\"type_hex\":\"0000000000000030\"},{\"account\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"currency\":\"LTC\",\"issuer\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"type\":49,\"type_hex\":\"0000000000000031\"}]]"
|
||||
}
|
||||
3
test/fixtures/api/responses/index.js
vendored
3
test/fixtures/api/responses/index.js
vendored
@@ -21,6 +21,9 @@ module.exports = {
|
||||
prepareOrderCancellation: require('./prepare-order-cancellation.json'),
|
||||
prepareOrder: require('./prepare-order.json'),
|
||||
preparePayment: require('./prepare-payment.json'),
|
||||
preparePaymentAllOptions: require('./prepare-payment-all-options.json'),
|
||||
preparePaymentNoCounterparty:
|
||||
require('./prepare-payment-no-counterparty.json'),
|
||||
prepareSettings: {
|
||||
regularKey: require('./prepare-settings-regular-key.json'),
|
||||
flags: require('./prepare-settings.json')
|
||||
|
||||
43
test/fixtures/api/responses/prepare-payment-all-options.json
vendored
Normal file
43
test/fixtures/api/responses/prepare-payment-all-options.json
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"Flags": 458752,
|
||||
"TransactionType": "Payment",
|
||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"Destination": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||
"Amount": "10000",
|
||||
"InvoiceID": "A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A",
|
||||
"SourceTag": 14,
|
||||
"DestinationTag": 58,
|
||||
"Paths": [
|
||||
[
|
||||
{
|
||||
"account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"currency": "USD",
|
||||
"type_hex": "0000000000000031"
|
||||
},
|
||||
{
|
||||
"issuer": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX",
|
||||
"currency": "LTC",
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX",
|
||||
"issuer": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX",
|
||||
"currency": "LTC",
|
||||
"type_hex": "0000000000000031"
|
||||
}
|
||||
]
|
||||
],
|
||||
"Memos": [
|
||||
{
|
||||
"Memo": {
|
||||
"MemoType": "74657374",
|
||||
"MemoFormat": "706C61696E2F74657874",
|
||||
"MemoData": "7465787465642064617461"
|
||||
}
|
||||
}
|
||||
],
|
||||
"LastLedgerSequence": 8820051,
|
||||
"Fee": "12",
|
||||
"Sequence": 23
|
||||
}
|
||||
52
test/fixtures/api/responses/prepare-payment-no-counterparty.json
vendored
Normal file
52
test/fixtures/api/responses/prepare-payment-no-counterparty.json
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"Flags": 458752,
|
||||
"TransactionType": "Payment",
|
||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"Destination": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||
"Amount": {
|
||||
"value": "0.01",
|
||||
"currency": "LTC",
|
||||
"issuer": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo"
|
||||
},
|
||||
"InvoiceID": "A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A",
|
||||
"SourceTag": 14,
|
||||
"DestinationTag": 58,
|
||||
"Paths": [
|
||||
[
|
||||
{
|
||||
"account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"currency": "USD",
|
||||
"type_hex": "0000000000000031"
|
||||
},
|
||||
{
|
||||
"issuer": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX",
|
||||
"currency": "LTC",
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX",
|
||||
"issuer": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX",
|
||||
"currency": "LTC",
|
||||
"type_hex": "0000000000000031"
|
||||
}
|
||||
]
|
||||
],
|
||||
"Memos": [
|
||||
{
|
||||
"Memo": {
|
||||
"MemoType": "74657374",
|
||||
"MemoFormat": "706C61696E2F74657874",
|
||||
"MemoData": "7465787465642064617461"
|
||||
}
|
||||
}
|
||||
],
|
||||
"SendMax": {
|
||||
"value": "0.01",
|
||||
"currency": "USD",
|
||||
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
|
||||
},
|
||||
"LastLedgerSequence": 8820051,
|
||||
"Fee": "12",
|
||||
"Sequence": 23
|
||||
}
|
||||
Reference in New Issue
Block a user