Skip to content

Commit

Permalink
fix handling memos in prepareSettings
Browse files Browse the repository at this point in the history
boost coverage back to 99.88%
move connection tests to separate file
group test fixtures into namespaces
  • Loading branch information
darkdarkdragon committed Nov 25, 2015
1 parent 27ed1aa commit c970413
Show file tree
Hide file tree
Showing 21 changed files with 649 additions and 469 deletions.
47 changes: 41 additions & 6 deletions docs/index.md
Expand Up @@ -348,7 +348,14 @@ ripplingDisabled | boolean | *Optional* If true, payments cannot ripple through
"qualityIn": 0.91,
"qualityOut": 0.87,
"ripplingDisabled": true,
"frozen": false
"frozen": false,
"memos": [
{
"type": "test",
"format": "plain/text",
"data": "texted data"
}
]
}
```

Expand Down Expand Up @@ -435,7 +442,14 @@ transferRate | number,null | *Optional* The fee to charge when users transfer t

```json
{
"domain": "ripple.com"
"domain": "ripple.com",
"memos": [
{
"type": "test",
"format": "plain/text",
"data": "texted data"
}
]
}
```

Expand Down Expand Up @@ -2826,7 +2840,14 @@ const trustline = {
"qualityIn": 0.91,
"qualityOut": 0.87,
"ripplingDisabled": true,
"frozen": false
"frozen": false,
"memos": [
{
"type": "test",
"format": "plain/text",
"data": "texted data"
}
]
};
return api.preparePayment(address, trustline).then(prepared =>
{/* ... */});
Expand All @@ -2835,7 +2856,7 @@ return api.preparePayment(address, trustline).then(prepared =>

```json
{
"txJSON": "{\"Flags\":2149711872,\"TransactionType\":\"TrustSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"LimitAmount\":{\"value\":\"10000\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"QualityIn\":910000000,\"QualityOut\":870000000,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"txJSON": "{\"TransactionType\":\"TrustSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"LimitAmount\":{\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\",\"value\":\"10000\"},\"Flags\":2149711872,\"QualityIn\":910000000,\"QualityOut\":870000000,\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\"}}],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "0.000012",
"sequence": 23,
Expand Down Expand Up @@ -2997,7 +3018,14 @@ instructions | object | The instructions for how to execute the transaction afte
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
const settings = {
"domain": "ripple.com"
"domain": "ripple.com",
"memos": [
{
"type": "test",
"format": "plain/text",
"data": "texted data"
}
]
};
return api.prepareSettings(address, settings)
.then(prepared => {/* ... */});
Expand All @@ -3006,7 +3034,14 @@ return api.prepareSettings(address, settings)

```json
{
"domain": "ripple.com"
"domain": "ripple.com",
"memos": [
{
"type": "test",
"format": "plain/text",
"data": "texted data"
}
]
}
```

Expand Down
8 changes: 6 additions & 2 deletions src/common/connection.js
Expand Up @@ -17,6 +17,10 @@ class Connection extends EventEmitter {
super();
this._url = url;
this._trace = options.trace;
if (this._trace) {
// for easier unit testing
this._console = console;
}
this._proxyURL = options.proxy;
this._proxyAuthorization = options.proxyAuthorization;
this._authorization = options.authorization;
Expand Down Expand Up @@ -54,7 +58,7 @@ class Connection extends EventEmitter {
_onMessage(message) {
let parameters;
if (this._trace) {
console.log(message);
this._console.log(message);
}
try {
parameters = this._parseMessage(message);
Expand Down Expand Up @@ -198,7 +202,7 @@ class Connection extends EventEmitter {

_send(message) {
if (this._trace) {
console.log(message);
this._console.log(message);
}
return new Promise((resolve, reject) => {
this._ws.send(message, undefined, (error, result) => {
Expand Down
10 changes: 6 additions & 4 deletions src/transaction/settings.js
Expand Up @@ -87,15 +87,17 @@ function createSettingsTransaction(account: string, settings: Settings
TransactionType: 'AccountSet',
Account: account
};
setTransactionFlags(txJSON, settings);

if (settings.memos !== undefined) {
txJSON.Memos = _.map(settings.memos, utils.convertMemo);
}

setTransactionFlags(txJSON, _.omit(settings, 'memos'));
setTransactionFields(txJSON, settings);

if (txJSON.TransferRate !== undefined) {
txJSON.TransferRate = convertTransferRate(txJSON.TransferRate);
}
if (settings.memos !== undefined) {
txJSON.Memos = _.map(settings.memos, utils.convertMemo);
}
return txJSON;
}

Expand Down

0 comments on commit c970413

Please sign in to comment.