Skip to content

Commit

Permalink
cover src/api/transaction/payment.js with unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdarkdragon committed Jul 22, 2015
1 parent e997c44 commit 040298d
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/api-test.js
Expand Up @@ -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));
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/api/requests/index.js
Expand Up @@ -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')
Expand Down
30 changes: 30 additions & 0 deletions 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\"}]]"
}
30 changes: 30 additions & 0 deletions 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\"}]]"
}
3 changes: 3 additions & 0 deletions test/fixtures/api/responses/index.js
Expand Up @@ -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')
Expand Down
43 changes: 43 additions & 0 deletions 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
}
52 changes: 52 additions & 0 deletions 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
}

0 comments on commit 040298d

Please sign in to comment.