mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
Update tests to support latest ripple-lib:
* Update ripple-lib api usage * Use latest npm ripple-lib * Tested with bignumber.js branch and tip of develop * Use new version of coffee-script * Better source maps * Update mocha * Add assert-diff for better error reporting * Add rconsole, enabled via USE_RCONSOLE env var * For use with manual installation only
This commit is contained in:
committed by
Nik Bougalis
parent
44450bf644
commit
4dc2cf8a6b
17
package.json
17
package.json
@@ -2,33 +2,28 @@
|
||||
"name": "rippled",
|
||||
"version": "0.0.1",
|
||||
"description": "Rippled Server",
|
||||
|
||||
"private": true,
|
||||
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"ripple-lib": "0.8.2",
|
||||
"assert-diff": "0.0.4",
|
||||
"async": "~0.2.9",
|
||||
"deep-equal": "0.0.0",
|
||||
"extend": "~1.2.0",
|
||||
"simple-jsonrpc": "~0.0.2",
|
||||
"deep-equal": "0.0.0"
|
||||
"ripple-lib": "0.10.0",
|
||||
"simple-jsonrpc": "~0.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"coffee-script": "~1.6.3",
|
||||
"mocha": "~1.13.0"
|
||||
"coffee-script": "^1.8.0",
|
||||
"mocha": "^2.1.0"
|
||||
},
|
||||
|
||||
"scripts": {
|
||||
"test": "mocha test/websocket-test.js test/server-test.js test/*-test.{js,coffee}"
|
||||
},
|
||||
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/ripple/rippled.git"
|
||||
},
|
||||
|
||||
"readmeFilename": "README.md"
|
||||
}
|
||||
|
||||
@@ -101,6 +101,9 @@ exports.submit_for_final = (tx, done) ->
|
||||
accept so the transaction will finalize.
|
||||
|
||||
'''
|
||||
tx.on 'proposed', -> tx.remote.ledger_accept()
|
||||
tx.on 'submitted', (m) ->
|
||||
ter = (m.engine_result ? '').slice(0, 3)
|
||||
if ter in ['tes', 'tec']
|
||||
tx.remote.ledger_accept()
|
||||
tx.on 'final', (m) -> done(m)
|
||||
tx.submit()
|
||||
@@ -188,7 +188,8 @@ config = testutils.init_config()
|
||||
#################################### HELPERS ###################################
|
||||
|
||||
get_lines = (remote, acc, done) ->
|
||||
remote.request_account_lines acc, null, 'validated', (err, lines) ->
|
||||
args = {account: acc, ledger: 'validated'}
|
||||
remote.request_account_lines args, (err, lines) ->
|
||||
done(lines)
|
||||
|
||||
account_set_factory = (remote, ledger, alias_for) ->
|
||||
|
||||
@@ -357,12 +357,12 @@ exports.LedgerState = class LedgerState
|
||||
incr_reserve_amt = @incr_reserve()
|
||||
|
||||
base_reserve = @parse_amount base_reserve_amt
|
||||
inc_reserve = @parse_amount incr_reserve_amt
|
||||
incr_reserve = @parse_amount incr_reserve_amt
|
||||
|
||||
@assert base_reserve != null,
|
||||
"Base reserve amount #{base_reserve_amt} is invalid"
|
||||
|
||||
@assert base_reserve != null,
|
||||
@assert incr_reserve != null,
|
||||
"incremental amount #{incr_reserve_amt} is invalid"
|
||||
|
||||
for account_id, account of @declaration.accounts
|
||||
@@ -380,10 +380,10 @@ exports.LedgerState = class LedgerState
|
||||
owner_count += Object.keys(@trusts_by_ci[account_id]).length
|
||||
|
||||
owner_count_amount = Amount.from_json(String(owner_count))
|
||||
inc_reserve_n = owner_count_amount.multiply(inc_reserve)
|
||||
inc_reserve_n = owner_count_amount.multiply(incr_reserve)
|
||||
total_needed = total_needed.add(inc_reserve_n)
|
||||
|
||||
@assert @accounts[account_id].compareTo total_needed != - 1,
|
||||
@assert @accounts[account_id].compareTo(total_needed) != - 1,
|
||||
"Account #{account_id} needs more XRP for reserve"
|
||||
|
||||
@reserves[account_id] = total_needed
|
||||
@@ -481,12 +481,6 @@ exports.LedgerState = class LedgerState
|
||||
tx.offer_create(src, pays, gets)
|
||||
tx.set_flags(flags)
|
||||
|
||||
# console.log tx.tx_json
|
||||
# process.exit()
|
||||
|
||||
# tx_json = make_tx_json(src, 'OfferCreate')
|
||||
# tx_json.TakerPays = pays.to_json()
|
||||
# tx_json.TakerGets = gets.to_json()
|
||||
lines.push submit_line(src, tx.tx_json)
|
||||
|
||||
ledger_accept()
|
||||
|
||||
@@ -2,6 +2,11 @@ mocha = require("mocha")
|
||||
// Stash a reference away to this
|
||||
old_loader = mocha.prototype.loadFiles
|
||||
|
||||
// Optionally use a more useful (but noisy) logger
|
||||
if (process.env.USE_RCONSOLE) {
|
||||
require('rconsole');
|
||||
};
|
||||
|
||||
if (!old_loader.monkey_patched) {
|
||||
// Gee thanks Mocha ...
|
||||
mocha.prototype.loadFiles = function() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--require ./test/mocha-loader-patch.js
|
||||
--reporter spec
|
||||
--compilers coffee:coffee-script
|
||||
--compilers coffee:coffee-script/register
|
||||
--ui tdd
|
||||
--timeout 10000
|
||||
--slow 600
|
||||
@@ -1,5 +1,5 @@
|
||||
var async = require('async');
|
||||
var assert = require('assert');
|
||||
var assert = require('assert-diff')({strict:true});
|
||||
var Account = require('ripple-lib').UInt160;
|
||||
var Remote = require('ripple-lib').Remote;
|
||||
var Transaction = require('ripple-lib').Transaction;
|
||||
@@ -123,7 +123,7 @@ suite('Order Book', function() {
|
||||
|
||||
ob.getOffers(function(err, offers) {
|
||||
assert.ifError(err);
|
||||
//console.log('OFFERS', offers);
|
||||
// console.log('OFFERS', offers);
|
||||
|
||||
var expected = [
|
||||
{ Account: 'rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn',
|
||||
@@ -132,8 +132,6 @@ suite('Order Book', function() {
|
||||
Flags: 0,
|
||||
LedgerEntryType: 'Offer',
|
||||
OwnerNode: '0000000000000000',
|
||||
PreviousTxnID: offers[0].PreviousTxnID,
|
||||
PreviousTxnLgrSeq: offers[0].PreviousTxnLgrSeq,
|
||||
Sequence: 2,
|
||||
TakerGets: { currency: 'USD',
|
||||
issuer: 'rGihwhaqU8g7ahwAvTq6iX5rvsfcbgZw6v',
|
||||
@@ -142,11 +140,11 @@ suite('Order Book', function() {
|
||||
TakerPays: '4000',
|
||||
index: 'CD6AE78EE0A5438978501A0404D9093597F57B705D566B5070D58BD48F98468C',
|
||||
owner_funds: '100',
|
||||
quality: '400',
|
||||
is_fully_funded: true,
|
||||
taker_gets_funded: '10',
|
||||
taker_pays_funded: '4000' }
|
||||
]
|
||||
|
||||
assert.deepEqual(offers, expected);
|
||||
|
||||
callback(null, ob);
|
||||
@@ -186,8 +184,6 @@ suite('Order Book', function() {
|
||||
Flags: 0,
|
||||
LedgerEntryType: 'Offer',
|
||||
OwnerNode: '0000000000000000',
|
||||
PreviousTxnID: offers[0].PreviousTxnID,
|
||||
PreviousTxnLgrSeq: offers[0].PreviousTxnLgrSeq,
|
||||
Sequence: 2,
|
||||
TakerGets:
|
||||
{ currency: 'USD',
|
||||
@@ -196,7 +192,6 @@ suite('Order Book', function() {
|
||||
TakerPays: '2000',
|
||||
index: 'CD6AE78EE0A5438978501A0404D9093597F57B705D566B5070D58BD48F98468C',
|
||||
owner_funds: '94.5',
|
||||
quality: '400',
|
||||
is_fully_funded: true,
|
||||
taker_gets_funded: '5',
|
||||
taker_pays_funded: '2000' }
|
||||
|
||||
@@ -59,7 +59,7 @@ make_suite('Robust transaction submission', function() {
|
||||
var tx = $.remote.transaction().payment({
|
||||
from: 'root',
|
||||
to: 'alice',
|
||||
amount: Amount.from_human('1XRP')
|
||||
amount: Amount.from_human('1 XRP')
|
||||
});
|
||||
|
||||
tx.once('submitted', function(m) {
|
||||
@@ -72,16 +72,16 @@ make_suite('Robust transaction submission', function() {
|
||||
tx.submit();
|
||||
|
||||
//Invoke callback immediately
|
||||
callback();
|
||||
callback(null, tx);
|
||||
},
|
||||
|
||||
function sendValidTransaction(callback) {
|
||||
function sendValidTransaction(previousTx, callback) {
|
||||
self.what = 'Send normal transaction which should succeed';
|
||||
|
||||
var tx = $.remote.transaction().payment({
|
||||
from: 'root',
|
||||
to: 'bob',
|
||||
amount: Amount.from_human('1XRP')
|
||||
amount: Amount.from_human('1 XRP')
|
||||
});
|
||||
|
||||
tx.on('submitted', function(m) {
|
||||
@@ -99,7 +99,8 @@ make_suite('Robust transaction submission', function() {
|
||||
});
|
||||
|
||||
tx.once('final', function() {
|
||||
callback();
|
||||
previousTx.once('final', function(){ callback(); });
|
||||
testutils.ledger_wait($.remote, previousTx);
|
||||
});
|
||||
|
||||
tx.submit();
|
||||
@@ -121,7 +122,7 @@ make_suite('Robust transaction submission', function() {
|
||||
|
||||
]
|
||||
|
||||
async.series(steps, function(err) {
|
||||
async.waterfall(steps, function(err) {
|
||||
assert(!err, self.what + ': ' + err);
|
||||
assert(self.resubmitted, 'Transaction failed to resubmit');
|
||||
done();
|
||||
@@ -161,7 +162,7 @@ make_suite('Robust transaction submission', function() {
|
||||
var tx = $.remote.transaction().payment({
|
||||
from: 'root',
|
||||
to: 'alice',
|
||||
amount: Amount.from_human('1XRP')
|
||||
amount: Amount.from_human('1 XRP')
|
||||
});
|
||||
|
||||
tx.submit();
|
||||
@@ -241,7 +242,7 @@ make_suite('Robust transaction submission', function() {
|
||||
var tx = $.remote.transaction().payment({
|
||||
from: 'root',
|
||||
to: 'alice',
|
||||
amount: Amount.from_human('1XRP')
|
||||
amount: Amount.from_human('1 XRP')
|
||||
});
|
||||
|
||||
tx.once('submitted', function(m) {
|
||||
@@ -334,7 +335,7 @@ make_suite('Robust transaction submission', function() {
|
||||
var tx = $.remote.transaction().payment({
|
||||
from: 'root',
|
||||
to: 'alice',
|
||||
amount: Amount.from_human('1XRP')
|
||||
amount: Amount.from_human('1 XRP')
|
||||
});
|
||||
|
||||
var timed_out = false;
|
||||
|
||||
@@ -245,7 +245,7 @@ function(remote, src, account, amount, callback) {
|
||||
// Before creating the account, check if it exists in the ledger.
|
||||
// If it does, regardless of the balance, fail the test, because
|
||||
// the ledger is not in the expected state.
|
||||
var info = remote.requestAccountInfo(account);
|
||||
var info = remote.requestAccountInfo({account: account});
|
||||
|
||||
info.once('success', function(result) {
|
||||
// The account exists. Fail by returning an error to callback.
|
||||
|
||||
Reference in New Issue
Block a user