run integration tests using standalone server

This commit is contained in:
Ivan Tivonenko
2015-12-12 02:53:37 +02:00
parent ed79a04018
commit 3dd21a7e11
15 changed files with 1248 additions and 214 deletions

View File

@@ -1,74 +0,0 @@
{
"jsonrpc": "2.0",
"id": "2",
"result": {
"type": "order",
"address": "rK5j9n8baXfL4gzUoZsfxBvvsv97P5swaV",
"sequence": 7973823,
"id": "4EB6B76237DEEE99F1EA16FAACED2D1E69C5F9CB54F727A4ECA51A08AD3AF466",
"specification": {
"direction": "buy",
"quantity": {
"currency": "USD",
"value": "0.000709756467",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
},
"totalPrice": {
"currency": "JPY",
"value": "0.086630181788",
"counterparty": "r94s8px6kSw1uZ1MV98dhSRTvc6VMPoPcN"
}
},
"outcome": {
"result": "tesSUCCESS",
"timestamp": "2015-12-03T00:53:21.000Z",
"fee": "0.010001",
"balanceChanges": {
"rK5j9n8baXfL4gzUoZsfxBvvsv97P5swaV": [
{
"currency": "XRP",
"value": "-0.010001"
}
]
},
"orderbookChanges": {
"rK5j9n8baXfL4gzUoZsfxBvvsv97P5swaV": [
{
"direction": "buy",
"quantity": {
"currency": "USD",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.000709260645"
},
"totalPrice": {
"currency": "JPY",
"counterparty": "r94s8px6kSw1uZ1MV98dhSRTvc6VMPoPcN",
"value": "0.086665436143"
},
"sequence": 7973725,
"status": "cancelled",
"makerExchangeRate": "0.008183892870852266"
},
{
"direction": "buy",
"quantity": {
"currency": "USD",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.000709756467"
},
"totalPrice": {
"currency": "JPY",
"counterparty": "r94s8px6kSw1uZ1MV98dhSRTvc6VMPoPcN",
"value": "0.086630181788"
},
"sequence": 7973823,
"status": "created",
"makerExchangeRate": "0.008192946757712049"
}
]
},
"ledgerVersion": 17445469,
"indexInLedger": 2
}
}
}

View File

@@ -1,72 +0,0 @@
{
"jsonrpc": "2.0",
"id": "3",
"result": [
{
"type": "order",
"address": "rpP2JgiMyTF5jR5hLG3xHCPi1knBb1v9cM",
"sequence": 3372206,
"id": "848397FA686BD4A59F91EC1F4DE717360470EE8BD67CAA01D5FD333EDA8D97B3",
"specification": {
"direction": "buy",
"quantity": {
"currency": "JPY",
"value": "27865.90216965619",
"counterparty": "rJRi8WW24gt9X85PHAxfWNPCizMMhqUQwg"
},
"totalPrice": {
"currency": "XRP",
"value": "40000"
}
},
"outcome": {
"result": "tesSUCCESS",
"fee": "0.011",
"balanceChanges": {
"rpP2JgiMyTF5jR5hLG3xHCPi1knBb1v9cM": [
{
"currency": "XRP",
"value": "-0.011"
}
]
},
"orderbookChanges": {
"rpP2JgiMyTF5jR5hLG3xHCPi1knBb1v9cM": [
{
"direction": "buy",
"quantity": {
"currency": "JPY",
"counterparty": "rJRi8WW24gt9X85PHAxfWNPCizMMhqUQwg",
"value": "27880.6855384734"
},
"totalPrice": {
"currency": "XRP",
"value": "40000"
},
"sequence": 3372204,
"status": "cancelled",
"makerExchangeRate": "0.697017138461835"
},
{
"direction": "buy",
"quantity": {
"currency": "JPY",
"counterparty": "rJRi8WW24gt9X85PHAxfWNPCizMMhqUQwg",
"value": "27865.90216965619"
},
"totalPrice": {
"currency": "XRP",
"value": "40000"
},
"sequence": 3372206,
"status": "created",
"makerExchangeRate": "0.6966475542414048"
}
]
},
"ledgerVersion": 17533547,
"indexInLedger": 12
}
}
]
}

View File

@@ -1,6 +0,0 @@
'use strict';
module.exports = {
getTransaction: require('./get-transaction'),
getTransactions: require('./get-transactions')
};

View File

@@ -4,18 +4,19 @@ const assert = require('assert-diff');
const _ = require('lodash');
const jayson = require('jayson');
const RippleAPI = require('../../src').RippleAPI;
const createHTTPServer = require('../../src/index').createHTTPServer;
const {payTo, ledgerAccept} = require('./utils');
const apiFixtures = require('../fixtures');
const apiRequests = apiFixtures.requests;
const apiResponses = apiFixtures.responses;
const fixtures = require('./fixtures');
const TIMEOUT = 20000; // how long before each test case times out
const serverUri = 'ws://127.0.0.1:6006';
const apiOptions = {
server: 'wss://s1.ripple.com'
server: serverUri
};
const httpPort = 3000;
@@ -38,11 +39,14 @@ function random() {
return _.fill(Array(16), 0);
}
describe('http server integration tests', function() {
this.timeout(TIMEOUT);
let server = null;
let client = null;
let paymentId = null;
let newWallet = null;
function createTestInternal(testName, methodName, params, testFunc, id) {
it(testName, function() {
@@ -60,6 +64,21 @@ describe('http server integration tests', function() {
makeNamedParams(params), testFunc, id);
}
before(() => {
this.api = new RippleAPI({server: serverUri});
console.log('CONNECTING...');
return this.api.connect().then(() => {
console.log('CONNECTED...');
})
.then(() => ledgerAccept(this.api))
.then(() => newWallet = this.api.generateAddress())
.then(() => ledgerAccept(this.api))
.then(() => payTo(this.api, newWallet.address))
.then(paymentId_ => {
paymentId = paymentId_;
});
});
beforeEach(function() {
server = createHTTPServer(apiOptions, httpPort);
return server.start().then(() => {
@@ -85,26 +104,43 @@ describe('http server integration tests', function() {
result => assert(_.isNumber(result.result.validatedLedger.ledgerVersion))
);
createTest(
'getTransaction',
[{id: '4EB6B76237DEEE99F1EA16FAACED2D1E69C5F9CB54F727A4ECA51A08AD3AF466'}],
result => assert.deepEqual(result, fixtures.getTransaction),
'2'
);
it('getTransaction', function() {
const params = [{id: paymentId}];
return new Promise((resolve, reject) => {
client.request('getTransaction', makePositionalParams(params),
(err, result) => {
if (err) {
reject(err);
}
assert.strictEqual(result.result.id, paymentId);
const outcome = result.result.outcome;
assert.strictEqual(outcome.result, 'tesSUCCESS');
assert.strictEqual(outcome.balanceChanges
.rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh[0].value, '-4003218.000012');
resolve(result);
});
});
});
createTest(
'getTransactions',
[{address: 'rpP2JgiMyTF5jR5hLG3xHCPi1knBb1v9cM'}, {
it('getTransactions', function() {
const params = [{address: newWallet.address}, {
options: {
binary: true,
limit: 1,
start:
'FBAAC31D6BAEEFA9E501266FD62DA7A7982662BC19BC42F49BB41405C2F820DB'
limit: 1
}
}],
result => assert.deepEqual(result, fixtures.getTransactions),
'3'
);
}];
return new Promise((resolve, reject) => {
client.request('getTransactions', makeNamedParams(params),
(err, result) => {
if (err) {
reject(err);
}
assert.strictEqual(result.result.length, 1);
assert.strictEqual(result.result[0].id, paymentId);
resolve(result);
});
});
});
createTest(
'prepareSettings',

View File

@@ -9,11 +9,14 @@ const requests = require('../fixtures/requests');
const RippleAPI = require('../../src').RippleAPI;
const {isValidAddress} = require('ripple-address-codec');
const {isValidSecret} = require('../../src/common');
const {payTo, ledgerAccept} = require('./utils');
const TIMEOUT = 30000; // how long before each test case times out
const TIMEOUT = 10000; // how long before each test case times out
const INTERVAL = 1000; // how long to wait between checks for validated ledger
const serverUrl = 'ws://127.0.0.1:6006';
function acceptLedger(api) {
return api.connection.request({command: 'ledger_accept'});
}
@@ -59,6 +62,7 @@ function testTransaction(testcase, type, lastClosedLedgerVersion, prepared,
minLedgerVersion: lastClosedLedgerVersion,
maxLedgerVersion: txData.LastLedgerSequence
};
ledgerAccept(testcase.api);
return new Promise((resolve, reject) => {
setTimeout(() => verifyTransaction(testcase, signedData.id, type,
options, txData, address).then(resolve, reject), INTERVAL);
@@ -74,17 +78,110 @@ function setup(server = 'wss://s1.ripple.com') {
});
}
const masterAccount = 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh';
const masterSecret = 'snoPBrXtMeMyMHUVTgbuqAfg1SUTb';
function makeTrustLine(testcase, address, secret) {
const api = testcase.api;
const specification = {
currency: 'USD',
counterparty: masterAccount,
limit: '1341.1',
ripplingDisabled: true
};
const trust = api.prepareTrustline(address, specification, {})
.then(data => {
const signed = api.sign(data.txJSON, secret);
if (address === wallet.getAddress()) {
testcase.transactions.push(signed.id);
}
return api.submit(signed.signedTransaction);
})
.then(() => ledgerAccept(api));
return trust;
}
function makeOrder(api, address, specification, secret) {
return api.prepareOrder(address, specification)
.then(data => api.sign(data.txJSON, secret))
.then(signed => api.submit(signed.signedTransaction))
.then(() => ledgerAccept(api));
}
function setupAccounts(testcase) {
const api = testcase.api;
const promise = payTo(api, 'rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM')
.then(() => payTo(api, wallet.getAddress()))
.then(() => payTo(api, testcase.newWallet.address))
.then(() => payTo(api, 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc'))
.then(() => payTo(api, 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'))
.then(() => {
return api.prepareSettings(masterAccount, {defaultRipple: true})
.then(data => api.sign(data.txJSON, masterSecret))
.then(signed => api.submit(signed.signedTransaction))
.then(() => ledgerAccept(api));
})
.then(() => makeTrustLine(testcase, wallet.getAddress(),
wallet.getSecret()))
.then(() => makeTrustLine(testcase, testcase.newWallet.address,
testcase.newWallet.secret))
.then(() => payTo(api, wallet.getAddress(), '123', 'USD', masterAccount))
.then(() => payTo(api, 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'))
.then(() => {
const orderSpecification = {
direction: 'buy',
quantity: {
currency: 'USD',
value: '432',
counterparty: masterAccount
},
totalPrice: {
currency: 'XRP',
value: '432'
}
};
return makeOrder(testcase.api, testcase.newWallet.address,
orderSpecification, testcase.newWallet.secret);
})
.then(() => {
const orderSpecification = {
direction: 'buy',
quantity: {
currency: 'XRP',
value: '1741'
},
totalPrice: {
currency: 'USD',
value: '171',
counterparty: masterAccount
}
};
return makeOrder(testcase.api, masterAccount, orderSpecification,
masterSecret);
});
return promise;
}
function teardown() {
return this.api.disconnect();
}
function suiteSetup() {
this.transactions = [];
return setup.bind(this)().then(() => {
return this.api.getLedgerVersion().then(ledgerVersion => {
return setup.bind(this)(serverUrl)
.then(() => ledgerAccept(this.api))
.then(() => this.newWallet = this.api.generateAddress())
// two times to give time to server to send `ledgerClosed` event
// so getLedgerVersion will return right value
.then(() => ledgerAccept(this.api))
.then(() => this.api.getLedgerVersion())
.then(ledgerVersion => {
this.startLedgerVersion = ledgerVersion;
});
}).then(teardown.bind(this));
})
.then(() => setupAccounts(this))
.then(() => teardown.bind(this)());
}
describe('integration tests', function() {
@@ -93,7 +190,7 @@ describe('integration tests', function() {
this.timeout(TIMEOUT);
before(suiteSetup);
beforeEach(setup);
beforeEach(_.partial(setup, serverUrl));
afterEach(teardown);
@@ -149,10 +246,10 @@ describe('integration tests', function() {
}
};
return this.api.getLedgerVersion().then(ledgerVersion => {
return this.api.prepareOrder(address,
orderSpecification, instructions).then(prepared =>
testTransaction(this, 'order', ledgerVersion, prepared)
).then(result => {
return this.api.prepareOrder(address, orderSpecification, instructions)
.then(prepared =>
testTransaction(this, 'order', ledgerVersion, prepared))
.then(result => {
const txData = JSON.parse(result.txJSON);
return this.api.getOrders(address).then(orders => {
assert(orders && orders.length > 0);
@@ -164,8 +261,9 @@ describe('integration tests', function() {
assert.deepEqual(createdOrder.specification, orderSpecification);
return txData;
});
}).then(txData => this.api.prepareOrderCancellation(
address, {orderSequence: txData.Sequence}, instructions)
})
.then(txData => this.api.prepareOrderCancellation(
address, {orderSequence: txData.Sequence}, instructions)
.then(prepared => testTransaction(this, 'orderCancellation',
ledgerVersion, prepared))
);
@@ -253,7 +351,7 @@ describe('integration tests', function() {
},
counter: {
currency: 'USD',
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
counterparty: masterAccount
}
};
return this.api.getOrderbook(address, orderbook).then(book => {
@@ -281,11 +379,11 @@ describe('integration tests', function() {
address: address
},
destination: {
address: 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc',
address: this.newWallet.address,
amount: {
value: '0.000001',
value: '1',
currency: 'USD',
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
counterparty: masterAccount
}
}
};
@@ -298,8 +396,24 @@ describe('integration tests', function() {
});
});
it('getPaths - send all', function() {
const pathfind = requests.getPaths.sendAll;
const pathfind = {
source: {
address: address,
amount: {
currency: 'USD',
value: '0.005'
}
},
destination: {
address: this.newWallet.address,
amount: {
currency: 'USD'
}
}
};
return this.api.getPaths(pathfind).then(data => {
assert(data && data.length > 0);
assert(_.every(data, path => {
@@ -323,30 +437,11 @@ describe('integration tests', function() {
});
function createAccount(api, address) {
const root = 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh';
const secret = 'snoPBrXtMeMyMHUVTgbuqAfg1SUTb';
const amount = {
currency: 'XRP',
value: '10000'
};
return api.preparePayment(root, {
source: {address: root, maxAmount: amount},
destination: {address, amount}
}).then(prepared => {
return api.submit(api.sign(prepared.txJSON, secret).signedTransaction);
}).then(() => {
return acceptLedger(api);
});
}
describe.skip('integration tests - standalone rippled', function() {
const instructions = {maxLedgerVersionOffset: 10, fee: '1'};
describe('integration tests - standalone rippled', function() {
const instructions = {maxLedgerVersionOffset: 10};
this.timeout(TIMEOUT);
const url = 'ws://127.0.0.1:6006';
// const url = 'wss://s.altnet.rippletest.net:51233';
beforeEach(_.partial(setup, url));
beforeEach(_.partial(setup, serverUrl));
afterEach(teardown);
const address = 'r5nx8ZkwEbFztnc8Qyi22DE9JYjRzNmvs';
const secret = 'ss6F8381Br6wwpy9p582H8sBt19J3';
@@ -364,7 +459,7 @@ describe.skip('integration tests - standalone rippled', function() {
]
};
let minLedgerVersion = null;
return createAccount(this.api, address).then(() => {
return payTo(this.api, address).then(() => {
return this.api.getLedgerVersion().then(ledgerVersion => {
minLedgerVersion = ledgerVersion;
return this.api.prepareSettings(address, {signers}, instructions)
@@ -374,8 +469,10 @@ describe.skip('integration tests - standalone rippled', function() {
});
});
}).then(() => {
const multisignInstructions =
_.assign({}, instructions, {signersCount: 2});
return this.api.prepareSettings(
address, {domain: 'example.com'}, instructions)
address, {domain: 'example.com'}, multisignInstructions)
.then(prepared => {
const signed1 = this.api.sign(
prepared.txJSON, signer1secret, {signAs: signer1address});

View File

@@ -0,0 +1,961 @@
#-------------------------------------------------------------------------------
#
# Rippled Server Instance Configuration Example
#
#-------------------------------------------------------------------------------
#
# Contents
#
# 1. Server
#
# 2. Peer Protocol
#
# 3. Ripple Protocol
#
# 4. HTTPS Client
#
# 5. Database
#
# 6. Diagnostics
#
# 7. Voting
#
# 8. Example Settings
#
#-------------------------------------------------------------------------------
#
# Purpose
#
# This file documents and provides examples of all rippled server process
# configuration options. When the rippled server instance is launched, it
# looks for a file with the following name:
#
# rippled.cfg
#
# For more information on where the rippled server instance searches for
# the file please visit the Ripple wiki. Specifically, the section explaining
# the --conf command line option:
#
# https://ripple.com/wiki/Rippled#--conf.3Dpath
#
# This file should be named rippled.cfg. This file is UTF-8 with Dos, UNIX,
# or Mac style end of lines. Blank lines and lines beginning with '#' are
# ignored. Undefined sections are reserved. No escapes are currently defined.
#
# Notation
#
# In this document a simple BNF notation is used. Angle brackets denote
# required elements, square brackets denote optional elements, and single
# quotes indicate string literals. A vertical bar separating 1 or more
# elements is a logical "or"; Any one of the elements may be chosen.
# Parenthesis are notational only, and used to group elements, they are not
# part of the syntax unless they appear in quotes. White space may always
# appear between elements, it has no effect on values.
#
# <key> A required identifier
# '=' The equals sign character
# | Logical "or"
# ( ) Used for grouping
#
#
# An identifier is a string of upper or lower case letters, digits, or
# underscores subject to the requirement that the first character of an
# identifier must be a letter. Identifiers are not case sensitive (but
# values may be).
#
# Some configuration sections contain key/value pairs. A line containing
# a key/value pair has this syntax:
#
# <identifier> '=' <value>
#
# Depending on the section and key, different value types are possible:
#
# <integer> A signed integer
# <unsigned> An unsigned integer
# <flag> A boolean. 1 = true/yes/on, 0 = false/no/off.
#
# Consult the documentation on the key in question to determine the possible
# value types.
#
#
#
#-------------------------------------------------------------------------------
#
# 1. Server
#
#----------
#
#
#
# rippled offers various server protocols to clients making inbound
# connections. The listening ports rippled uses are "universal" ports
# which may be configured to handshake in one or more of the available
# supported protocols. These universal ports simplify administration:
# A single open port can be used for multiple protocols.
#
# NOTE At least one server port must be defined in order
# to accept incoming network connections.
#
#
# [server]
#
# A list of port names and key/value pairs. A port name must start with a
# letter and contain only letters and numbers. The name is not case-sensitive.
# For each name in this list, rippled will look for a configuration file
# section with the same name and use it to create a listening port. The
# name is informational only; the choice of name does not affect the function
# of the listening port.
#
# Key/value pairs specified in this section are optional, and apply to all
# listening ports unless the port overrides the value in its section. They
# may be considered default values.
#
# Suggestion:
#
# To avoid a conflict with port names and future configuration sections,
# we recommend prepending "port_" to the port name. This prefix is not
# required, but suggested.
#
# This example defines two ports with different port numbers and settings:
#
# [server]
# port_public
# port_private
# port = 80
#
# [port_public]
# ip=0.0.0.0
# port = 443
# protocol=peer,https
#
# [port_private]
# ip=127.0.0.1
# protocol=http
#
# When rippled is used as a command line client (for example, issuing a
# server stop command), the first port advertising the http or https
# protocol will be used to make the connection.
#
#
#
# [<name>]
#
# A series of key/value pairs that define the settings for the port with
# the corresponding name. These keys are possible:
#
# ip = <IP-address>
#
# Required. Determines the IP address of the network interface to bind
# to. To bind to all available interfaces, uses 0.0.0.0
#
# port = <number>
#
# Required. Sets the port number to use for this port.
#
# protocol = [ http, https, peer ]
#
# Required. A comma-separated list of protocols to support:
#
# http JSON-RPC over HTTP
# https JSON-RPC over HTTPS
# ws Websockets
# wss Secure Websockets
# peer Peer Protocol
#
# Restrictions:
#
# Only one port may be configured to support the peer protocol.
# A port cannot have websocket and non websocket protocols at the
# same time. It is possible have both Websockets and Secure Websockets
# together in one port.
#
# NOTE If no ports support the peer protocol, rippled cannot
# receive incoming peer connections or become a superpeer.
#
# user = <text>
# password = <text>
#
# When set, these credentials will be required on HTTP/S requests.
# The credentials must be provided using HTTP's Basic Authentication
# headers. If either or both fields are empty, then no credentials are
# required. IP address restrictions, if any, will be checked in addition
# to the credentials specified here.
#
# When acting in the client role, rippled will supply these credentials
# using HTTP's Basic Authentication headers when making outbound HTTP/S
# requests.
#
# admin = [ IP, IP, IP, ... ]
#
# A comma-separated list of IP addresses.
#
# When set, grants administrative command access to the specified IP
# addresses. These commands may be issued over http, https, ws, or wss
# if configured on the port. If unspecified, the default is to not allow
# administrative commands.
#
# *SECURITY WARNING*
# 0.0.0.0 may be specified to allow access from any IP address. It must
# be the only address specified and cannot be combined with other IPs.
# Use of this address can compromise server security, please consider its
# use carefully.
#
# admin_user = <text>
# admin_password = <text>
#
# When set, clients must provide these credentials in the submitted
# JSON for any administrative command requests submitted to the HTTP/S,
# WS, or WSS protocol interfaces. If administrative commands are
# disabled for a port, these credentials have no effect.
#
# When acting in the client role, rippled will supply these credentials
# in the submitted JSON for any administrative command requests when
# invoking JSON-RPC commands on remote servers.
#
# ssl_key = <filename>
# ssl_cert = <filename>
# ssl_chain = <filename>
#
# Use the specified files when configuring SSL on the port.
#
# NOTE If no files are specified and secure protocols are selected,
# rippled will generate an internal self-signed certificate.
#
# The files have these meanings:
#
# ssl_key
#
# Specifies the filename holding the SSL key in PEM format.
#
# ssl_cert
#
# Specifies the path to the SSL certificate file in PEM format.
# This is not needed if the chain includes it.
#
# ssl_chain
#
# If you need a certificate chain, specify the path to the
# certificate chain here. The chain may include the end certificate.
#
#
#
# [rpc_startup]
#
# Specify a list of RPC commands to run at startup.
#
# Examples:
# { "command" : "server_info" }
# { "command" : "log_level", "partition" : "ripplecalc", "severity" : "trace" }
#
#
#
# [websocket_ping_frequency]
#
# <number>
#
# The amount of time to wait in seconds, before sending a websocket 'ping'
# message. Ping messages are used to determine if the remote end of the
# connection is no longer available.
#
#
#
#-------------------------------------------------------------------------------
#
# 2. Peer Protocol
#
#-----------------
#
# These settings control security and access attributes of the Peer to Peer
# server section of the rippled process. Peer Protocol implements the
# Ripple Payment protocol. It is over peer connections that transactions
# and validations are passed from to machine to machine, to determine the
# contents of validated ledgers.
#
#
#
# [ips]
#
# List of hostnames or ips where the Ripple protocol is served. For a starter
# list, you can either copy entries from: https://ripple.com/ripple.txt or if
# you prefer you can specify r.ripple.com 51235
#
# One IPv4 address or domain names per line is allowed. A port may must be
# specified after adding a space to the address. By convention, if known,
# IPs are listed in from most to least trusted.
#
# Examples:
# 192.168.0.1
# 192.168.0.1 3939
# r.ripple.com 51235
#
# This will give you a good, up-to-date list of addresses:
#
# [ips]
# r.ripple.com 51235
#
# The default is: [ips_fixed] addresses (if present) or r.ripple.com 51235
#
#
# [ips_fixed]
#
# List of IP addresses or hostnames to which rippled should always attempt to
# maintain peer connections with. This is useful for manually forming private
# networks, for example to configure a validation server that connects to the
# Ripple network through a public-facing server, or for building a set
# of cluster peers.
#
# One IPv4 address or domain names per line is allowed. A port must be
# specified after adding a space to the address.
#
#
#
# [peer_private]
#
# 0 or 1.
#
# 0: Request peers to broadcast your address. Normal outbound peer connections [default]
# 1: Request peers not broadcast your address. Only connect to configured peers.
#
#
#
# [peers_max]
#
# The largest number of desired peer connections (incoming or outgoing).
# Cluster and fixed peers do not count towards this total. There are
# implementation-defined lower limits imposed on this value for security
# purposes.
#
#
#
# [node_seed]
#
# This is used for clustering. To force a particular node seed or key, the
# key can be set here. The format is the same as the validation_seed field.
# To obtain a validation seed, use the validation_create command.
#
# Examples: RASH BUSH MILK LOOK BAD BRIM AVID GAFF BAIT ROT POD LOVE
# shfArahZT9Q9ckTf3s1psJ7C7qzVN
#
#
#
# [cluster_nodes]
#
# To extend full trust to other nodes, place their node public keys here.
# Generally, you should only do this for nodes under common administration.
# Node public keys start with an 'n'. To give a node a name for identification
# place a space after the public key and then the name.
#
#
#
# [sntp_servers]
#
# IP address or domain of NTP servers to use for time synchronization.
#
# These NTP servers are suitable for rippled servers located in the United
# States:
# time.windows.com
# time.apple.com
# time.nist.gov
# pool.ntp.org
#
#
#
# [overlay]
#
# Controls settings related to the peer to peer overlay.
#
# A set of key/value pair parameters to configure the overlay.
#
# public_ip = <IP-address>
#
# If the server has a known, fixed public IPv4 address,
# specify that IP address here in dotted decimal notation.
# Peers will use this information to reject attempt to proxy
# connections to or from this server.
#
# ip_limit = <number>
#
# The maximum number of incoming peer connections allowed by a single
# IP that isn't classified as "private" in RFC1918. The implementation
# imposes some hard and soft upper limits on this value to prevent a
# single host from consuming all inbound slots. If the value is not
# present the server will autoconfigure an appropriate limit.
#
#
#
# [transaction_queue] EXPERIMENTAL
#
# This section is EXPERIMENTAL, and should not be
# present for production configuration settings.
#
# A set of key/value pair parameters to tune the performance of the
# transaction queue.
#
# ledgers_in_queue = <number>
#
# The queue will be limited to this <number> of average ledgers'
# worth of transactions. If the queue fills up, the transactions
# with the lowest fees will be dropped from the queue any time a
# transaction with a higher fee level is added. Default: 20.
#
# retry_sequence_percent = <number>
#
# If a client resubmits a transaction, the new transaction's fee
# must be more than <number> percent higher than the original
# transaction's fee, or meet the current open ledger fee to be
# considered. Default: 125.
#
#
#
#-------------------------------------------------------------------------------
#
# 3. Ripple Protocol
#
#-------------------
#
# These settings affect the behavior of the server instance with respect
# to Ripple payment protocol level activities such as validating and
# closing ledgers, establishing a quorum, or adjusting fees in response
# to server overloads.
#
#
#
# [node_size]
#
# Tunes the servers based on the expected load and available memory. Legal
# sizes are "tiny", "small", "medium", "large", and "huge". We recommend
# you start at the default and raise the setting if you have extra memory.
# The default is "tiny".
#
#
#
# [validation_quorum]
#
# Sets the minimum number of trusted validations a ledger must have before
# the server considers it fully validated. Note that if you are validating,
# your validation counts.
#
#
#
# [ledger_history]
#
# The number of past ledgers to acquire on server startup and the minimum to
# maintain while running.
#
# To serve clients, servers need historical ledger data. Servers that don't
# need to serve clients can set this to "none". Servers that want complete
# history can set this to "full".
#
# This must be less than or equal to online_delete (if online_delete is used)
#
# The default is: 256
#
#
#
# [fetch_depth]
#
# The number of past ledgers to serve to other peers that request historical
# ledger data (or "full" for no limit).
#
# Servers that require low latency and high local performance may wish to
# restrict the historical ledgers they are willing to serve. Setting this
# below 32 can harm network stability as servers require easy access to
# recent history to stay in sync. Values below 128 are not recommended.
#
# The default is: full
#
#
#
# [validation_seed]
#
# To perform validation, this section should contain either a validation seed
# or key. The validation seed is used to generate the validation
# public/private key pair. To obtain a validation seed, use the
# validation_create command.
#
# Examples: RASH BUSH MILK LOOK BAD BRIM AVID GAFF BAIT ROT POD LOVE
# shfArahZT9Q9ckTf3s1psJ7C7qzVN
#
#
#
# [validators]
#
# List of nodes to always accept as validators. Nodes are specified by domain
# or public key.
#
# For domains, rippled will probe for https web servers at the specified
# domain in the following order: ripple.DOMAIN, www.DOMAIN, DOMAIN
#
# For public key entries, a comment may optionally be specified after adding
# a space to the public key.
#
# Examples:
# ripple.com
# n9KorY8QtTdRx7TVDpwnG9NvyxsDwHUKUEeDLY3AkiGncVaSXZi5
# n9MqiExBcoG19UXwoLjBJnhsxEhAZMuWwJDRdkyDz1EkEkwzQTNt John Doe
#
#
#
# [validators_file]
#
# Path to file contain a list of nodes to always accept as validators. Use
# this to specify a file other than this file to manage your validators list.
#
# If this entry is not present or empty and no nodes from previous runs were
# found in the database, rippled will look for a validators.txt in the config
# directory. If not found there, it will attempt to retrieve the file from
# the [validators_site] web site.
#
# After specifying a different [validators_file] or changing the contents of
# the validators file, issue a RPC unl_load command to have rippled load the
# file.
#
# Specify the file by specifying its full path.
#
# Examples:
# C:/home/johndoe/ripple/validators.txt
# /home/johndoe/ripple/validators.txt
#
#
#
# [validators_site]
#
# Specifies where to find validators.txt for UNL boostrapping and RPC
# unl_network command.
#
# Example: ripple.com
#
#
#
# [path_search]
# When searching for paths, the default search aggressiveness. This can take
# exponentially more resources as the size is increased.
#
# The default is: 7
#
# [path_search_fast]
# [path_search_max]
# When searching for paths, the minimum and maximum search aggressiveness.
#
# If you do not need pathfinding, you can set path_search_max to zero to
# disable it and avoid some expensive bookkeeping.
#
# The default for 'path_search_fast' is 2. The default for 'path_search_max' is 10.
#
# [path_search_old]
#
# For clients that use the legacy path finding interfaces, the search
# aggressiveness to use. The default is 7.
#
#
#
# [fee_default]
#
# Sets the base cost of a transaction in drops. Used when the server has
# no other source of fee information, such as signing transactions offline.
#
#
#
#-------------------------------------------------------------------------------
#
# 4. HTTPS Client
#
#----------------
#
# The rippled server instance uses HTTPS GET requests in a variety of
# circumstances, including but not limited to contacting trusted domains to
# fetch information such as mapping an email address to a Ripple Payment
# Network address.
#
# [ssl_verify]
#
# 0 or 1.
#
# 0. HTTPS client connections will not verify certificates.
# 1. Certificates will be checked for HTTPS client connections.
#
# If not specified, this parameter defaults to 1.
#
#
#
# [ssl_verify_file]
#
# <pathname>
#
# A file system path leading to the certificate verification file for
# HTTPS client requests.
#
#
#
# [ssl_verify_dir]
#
# <pathname>
#
#
# A file system path leading to a file or directory containing the root
# certificates that the server will accept for verifying HTTP servers.
# Used only for outbound HTTPS client connections.
#
#
#
#-------------------------------------------------------------------------------
#
# 5. Database
#
#------------
#
# rippled creates 4 SQLite database to hold bookkeeping information
# about transactions, local credentials, and various other things.
# It also creates the NodeDB, which holds all the objects that
# make up the current and historical ledgers.
#
# The size of the NodeDB grows in proportion to the amount of new data and the
# amount of historical data (a configurable setting) so the performance of the
# underlying storage media where the NodeDB is placed can significantly affect
# the performance of the server.
#
# Partial pathnames will be considered relative to the location of
# the rippled.cfg file.
#
# [node_db] Settings for the Node Database (required)
#
# Format (without spaces):
# One or more lines of case-insensitive key / value pairs:
# <key> '=' <value>
# ...
#
# Example:
# type=nudb
# path=db/nudb
#
# The "type" field must be present and controls the choice of backend:
#
# type = NuDB
#
# NuDB is a high-performance database written by Ripple Labs and optimized
# for rippled and solid-state drives.
#
# NuDB maintains its high speed regardless of the amount of history
# stored. Online delete may be selected, but is not required. NuDB is
# available on all platforms that rippled runs on.
#
# type = RocksDB
#
# RocksDB is an open-source, general-purpose key/value store - see
# http://rocksdb.org/ for more details.
#
# RocksDB is an alternative backend for systems that don't use solid-state
# drives. Because RocksDB's performance degrades as it stores more data,
# keeping full history is not advised, and using online delete is
# recommended. RocksDB is not available on Windows.
#
# The RocksDB backend also provides these optional parameters:
#
# compression 0 for none, 1 for Snappy compression
#
#
#
# Required keys:
# path Location to store the database (all types)
#
# Optional keys:
#
# These keys are possible for any type of backend:
#
# online_delete Minimum value of 256. Enable automatic purging
# of older ledger information. Maintain at least this
# number of ledger records online. Must be greater
# than or equal to ledger_history.
#
# advisory_delete 0 for disabled, 1 for enabled. If set, then
# require administrative RPC call "can_delete"
# to enable online deletion of ledger records.
#
# Notes:
# The 'node_db' entry configures the primary, persistent storage.
#
# The 'import_db' is used with the '--import' command line option to
# migrate the specified database into the current database given
# in the [node_db] section.
#
# [import_db] Settings for performing a one-time import (optional)
# [database_path] Path to the book-keeping databases.
#
# There are 4 bookkeeping SQLite database that the server creates and
# maintains. If you omit this configuration setting, it will default to
# creating a directory called "db" located in the same place as your
# rippled.cfg file. Partial pathnames will be considered relative to
# the location of the rippled executable.
#
#
#
#
#-------------------------------------------------------------------------------
#
# 6. Diagnostics
#
#---------------
#
# These settings are designed to help server administrators diagnose
# problems, and obtain detailed information about the activities being
# performed by the rippled process.
#
#
#
# [debug_logfile]
#
# Specifies where a debug logfile is kept. By default, no debug log is kept.
# Unless absolute, the path is relative the directory containing this file.
#
# Example: debug.log
#
#
#
# [insight]
#
# Configuration parameters for the Beast. Insight stats collection module.
#
# Insight is a module that collects information from the areas of rippled
# that have instrumentation. The configuration parameters control where the
# collection metrics are sent. The parameters are expressed as key = value
# pairs with no white space. The main parameter is the choice of server:
#
# "server"
#
# Choice of server to send metrics to. Currently the only choice is
# "statsd" which sends UDP packets to a StatsD daemon, which must be
# running while rippled is running. More information on StatsD is
# available here:
# https://github.com/b/statsd_spec
#
# When server=statsd, these additional keys are used:
#
# "address" The UDP address and port of the listening StatsD server,
# in the format, n.n.n.n:port.
#
# "prefix" A string prepended to each collected metric. This is used
# to distinguish between different running instances of rippled.
#
# If this section is missing, or the server type is unspecified or unknown,
# statistics are not collected or reported.
#
# Example:
#
# [insight]
# server=statsd
# address=192.168.0.95:4201
# prefix=my_validator
#
#-------------------------------------------------------------------------------
#
# 7. Voting
#
#----------
#
# The vote settings configure settings for the entire Ripple network.
# While a single instance of rippled cannot unilaterally enforce network-wide
# settings, these choices become part of the instance's vote during the
# consensus process for each voting ledger.
#
# [voting]
#
# A set of key/value pair parameters used during voting ledgers.
#
# reference_fee = <drops>
#
# The cost of the reference transaction fee, specified in drops.
# The reference transaction is the simplest form of transaction.
# It represents an XRP payment between two parties.
#
# If this parameter is unspecified, rippled will use an internal
# default. Don't change this without understanding the consequences.
#
# Example:
# reference_fee = 10 # 10 drops
#
# account_reserve = <drops>
#
# The account reserve requirement is specified in drops. The portion of an
# account's XRP balance that is at or below the reserve may only be
# spent on transaction fees, and not transferred out of the account.
#
# If this parameter is unspecified, rippled will use an internal
# default. Don't change this without understanding the consequences.
#
# Example:
# account_reserve = 20000000 # 20 XRP
#
# owner_reserve = <drops>
#
# The owner reserve is the amount of XRP reserved in the account for
# each ledger item owned by the account. Ledger items an account may
# own include trust lines, open orders, and tickets.
#
# If this parameter is unspecified, rippled will use an internal
# default. Don't change this without understanding the consequences.
#
# Example:
# owner_reserve = 5000000 # 5 XRP
#
#-------------------------------------------------------------------------------
#
# 8. Example Settings
#
#--------------------
#
# Administrators can use these values as a starting point for configuring
# their instance of rippled, but each value should be checked to make sure
# it meets the business requirements for the organization.
#
# Server
#
# These example configuration settings create these ports:
#
# "peer"
#
# Peer protocol open to everyone. This is required to accept
# incoming rippled connections. This does not affect automatic
# or manual outgoing Peer protocol connections.
#
# "rpc"
#
# Administrative RPC commands over HTTPS, when originating from
# the same machine (via the loopback adapter at 127.0.0.1).
#
# "wss_admin"
#
# Admin level API commands over Secure Websockets, when originating
# from the same machine (via the loopback adapter at 127.0.0.1).
#
# This port is commented out but can be enabled by removing
# the '#' from each corresponding line including the entry under [server]
#
# "wss_public"
#
# Guest level API commands over Secure Websockets, open to everyone.
#
# For HTTPS and Secure Websockets ports, if no certificate and key file
# are specified then a self-signed certificate will be generated on startup.
# If you have a certificate and key file, uncomment the corresponding lines
# and ensure the paths to the files are correct.
#
# NOTE
#
# To accept connections on well known ports such as 80 (HTTP) or
# 443 (HTTPS), most operating systems will require rippled to
# run with administrator privileges, or else rippled will not start.
[server]
port_rpc_admin_local
#port_peer
port_ws_admin_local
#port_ws_public
#port_ws_admin_public
#ssl_key = /etc/ssl/private/server.key
#ssl_cert = /etc/ssl/certs/server.crt
[port_rpc_admin_local]
port = 5005
ip = 127.0.0.1
admin = 127.0.0.1
protocol = http
[port_peer]
port = 51235
ip = 0.0.0.0
protocol = peer
[port_ws_admin_local]
port = 6006
ip = 127.0.0.1
admin = 127.0.0.1
protocol = ws
[port_ws_admin_public]
port = 5007
ip = 0.0.0.0
admin = 192.168.50.1
protocol = ws
[port_ws_public]
port = 5006
ip = 0.0.0.0
protocol = ws
#[port_ws_public]
#port = 5005
#ip = 127.0.0.1
#protocol = wss
#-------------------------------------------------------------------------------
[node_size]
medium
# This is primary persistent datastore for rippled. This includes transaction
# metadata, account states, and ledger headers. Helpful information can be
# found here: https://ripple.com/wiki/NodeBackEnd
# delete old ledgers while maintaining at least 2000. Do not require an
# external administrative command to initiate deletion.
[node_db]
type=RocksDB
path=/var/lib/rippled/db/rocksdb
open_files=2000
filter_bits=12
cache_mb=256
file_size_mb=8
file_size_mult=2
online_delete=2000
advisory_delete=0
[database_path]
/var/lib/rippled/db
# This needs to be an absolute directory reference, not a relative one.
# Modify this value as required.
[debug_logfile]
/var/log/rippled.debug.log
[sntp_servers]
time.windows.com
time.apple.com
time.nist.gov
pool.ntp.org
# Where to find some other servers speaking the Ripple protocol.
#
#[ips]
#r.ripple.com 51235
# Public keys of the validators that this rippled instance trusts. The latest
# list of validators can be obtained from https://ripple.com/ripple.txt
#
# See also https://wiki.ripple.com/Ripple.txt
#
[validators]
n949f75evCHwgyP4fPVgaHqNHxUVN15PsJEZ3B3HnXPcPjcZAoy7 RL1
n9MD5h24qrQqiyBC8aeqqCWvpiBiYQ3jxSr91uiDvmrkyHRdYLUj RL2
n9L81uNCaPgtUJfaHh89gmdvXKAmSt5Gdsw2g1iPWaPkAHW5Nm4C RL3
n9KiYM9CgngLvtRCQHZwgC2gjpdaZcCcbt3VboxiNFcKuwFVujzS RL4
n9LdgEtkmGB9E2h3K4Vp7iGUaKuq23Zr32ehxiU8FWY7xoxbWTSA RL5
# The number of validators rippled needs to accept a consensus.
# Don't change this unless you know what you're doing.
[validation_quorum]
3
# Turn down default logging to save disk space in the long run.
# Valid values here are trace, debug, info, warning, error, and fatal
[rpc_startup]
{ "command": "log_level", "severity": "trace" }
#{ "command": "log_level", "severity": "warning" }
# If ssl_verify is 1, certificates will be validated.
# To allow the use of self-signed certificates for development or internal use,
# set to ssl_verify to 0.
[ssl_verify]
1
[features]
SusPay
MultiSign

56
test/integration/utils.js Normal file
View File

@@ -0,0 +1,56 @@
'use strict';
const masterAccount = 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh';
const masterSecret = 'snoPBrXtMeMyMHUVTgbuqAfg1SUTb';
function ledgerAccept(api) {
const request = {command: 'ledger_accept'};
return api.connection.request(request);
}
function pay(api, from, to, amount, secret, currency = 'XRP', counterparty) {
const paymentSpecification = {
source: {
address: from,
maxAmount: {
value: amount,
currency: currency
}
},
destination: {
address: to,
amount: {
value: amount,
currency: currency
}
}
};
if (counterparty !== undefined) {
paymentSpecification.source.maxAmount.counterparty = counterparty;
paymentSpecification.destination.amount.counterparty = counterparty;
}
let id = null;
return api.preparePayment(from, paymentSpecification, {})
.then(data => api.sign(data.txJSON, secret))
.then(signed => {
id = signed.id;
return api.submit(signed.signedTransaction);
})
.then(() => ledgerAccept(api))
.then(() => id);
}
function payTo(api, to, amount = '4003218', currency = 'XRP', counterparty) {
return pay(api, masterAccount, to, amount, masterSecret, currency,
counterparty);
}
module.exports = {
pay,
payTo,
ledgerAccept
};