[FEATURE] Remote.prototype.requestOffer

See: https://ripple.com/build/rippled-apis/#ledger-entry

Rippled request
```js
{
  "id": 1,
  "command": "ledger_entry",
  "type": "offer",
  "offer": {"account": "rEQWVz1qN4DWw5J17s3DgXQzUuVYDSpK6M", "seq":5 },
  "ledger_index": 10850610
}
```

Response
```js
{
  "id": 7,
  "status": "success",
  "type": "response",
  "result": {
    "index": "F9DCCD26C770952D216085BF97D7E225F6A8B578ABD066AA92D7D06144B535EE",
    "ledger_index": 10850610,
    "node": {
      "Account": "rEQWVz1qN4DWw5J17s3DgXQzUuVYDSpK6M",
      "BookDirectory": "CF8D13399C6ED20BA82740CFA78E928DC8D498255249BA6351038D7EA4C68000",
      "BookNode": "0000000000000000",
      "Flags": 131072,
      "LedgerEntryType": "Offer",
      "OwnerNode": "0000000000000000",
      "PreviousTxnID": "64FAB660F9F5D9E7183E977701930AD09F372129C56E1685B68A914D8A43CA41",
      "PreviousTxnLgrSeq": 10850602,
      "Sequence": 5,
      "TakerGets": "1000000",
      "TakerPays": {
        "currency": "USD",
        "issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
        "value": "100"
      },
      "index": "F9DCCD26C770952D216085BF97D7E225F6A8B578ABD066AA92D7D06144B535EE"
    },
    "validated": false
  }
}
```
This commit is contained in:
Alan Cohen
2015-01-20 17:59:35 -08:00
parent 55cd13ed4e
commit 98f40abfc3
2 changed files with 66 additions and 0 deletions

View File

@@ -838,5 +838,33 @@ describe('Remote', function () {
assert.strictEqual(request.message.account_root, ADDRESS);
assert.strictEqual(request.message.ledger_index, 'validated');
});
it('request offer with ledger index', function() {
var request = remote.requestOffer({account: ADDRESS, ledger: LEDGER_INDEX, sequence: 5});
assert.strictEqual(request.message.command, 'ledger_entry');
assert.strictEqual(request.message.offer.account, ADDRESS);
assert.strictEqual(request.message.offer.seq, 5);
assert.strictEqual(request.message.ledger_index, LEDGER_INDEX);
});
it('request offer with ledger hash', function() {
var request = remote.requestOffer({account: ADDRESS, ledger: LEDGER_HASH, sequence: 5});
assert.strictEqual(request.message.command, 'ledger_entry');
assert.strictEqual(request.message.offer.account, ADDRESS);
assert.strictEqual(request.message.offer.seq, 5);
assert.strictEqual(request.message.ledger_hash, LEDGER_HASH);
});
it('request account balance with ledger identifier', function() {
var request = remote.requestOffer({account: ADDRESS, ledger: 'validated', sequence: 5});
assert.strictEqual(request.message.command, 'ledger_entry');
assert.strictEqual(request.message.offer.account, ADDRESS);
assert.strictEqual(request.message.offer.seq, 5);
assert.strictEqual(request.message.ledger_index, 'validated');
});
it('request account balance with offer index', function() {
var request = remote.requestOffer({ index: TRANSACTION_HASH, ledger: LEDGER_INDEX});
assert.strictEqual(request.message.command, 'ledger_entry');
assert.strictEqual(request.message.offer, TRANSACTION_HASH);
assert.strictEqual(request.message.ledger_index, LEDGER_INDEX);
});
});
});