diff --git a/test/api-test.js b/test/api-test.js index 3e7919bc..caf5ea12 100644 --- a/test/api-test.js +++ b/test/api-test.js @@ -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)); diff --git a/test/fixtures/api/requests/index.js b/test/fixtures/api/requests/index.js index 2fe2aef6..d6d0092f 100644 --- a/test/fixtures/api/requests/index.js +++ b/test/fixtures/api/requests/index.js @@ -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') diff --git a/test/fixtures/api/requests/prepare-payment-all-options.json b/test/fixtures/api/requests/prepare-payment-all-options.json new file mode 100644 index 00000000..10f3e809 --- /dev/null +++ b/test/fixtures/api/requests/prepare-payment-all-options.json @@ -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\"}]]" +} diff --git a/test/fixtures/api/requests/prepare-payment-no-counterparty.json b/test/fixtures/api/requests/prepare-payment-no-counterparty.json new file mode 100644 index 00000000..6f8009fc --- /dev/null +++ b/test/fixtures/api/requests/prepare-payment-no-counterparty.json @@ -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\"}]]" +} diff --git a/test/fixtures/api/responses/index.js b/test/fixtures/api/responses/index.js index 8e8ccb1e..f42b9c25 100644 --- a/test/fixtures/api/responses/index.js +++ b/test/fixtures/api/responses/index.js @@ -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') diff --git a/test/fixtures/api/responses/prepare-payment-all-options.json b/test/fixtures/api/responses/prepare-payment-all-options.json new file mode 100644 index 00000000..644bd081 --- /dev/null +++ b/test/fixtures/api/responses/prepare-payment-all-options.json @@ -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 +} \ No newline at end of file diff --git a/test/fixtures/api/responses/prepare-payment-no-counterparty.json b/test/fixtures/api/responses/prepare-payment-no-counterparty.json new file mode 100644 index 00000000..4f43f731 --- /dev/null +++ b/test/fixtures/api/responses/prepare-payment-no-counterparty.json @@ -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 +} \ No newline at end of file