mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
JS: Stubs for monitoring accounts.
This commit is contained in:
25
src/js/account.js
Normal file
25
src/js/account.js
Normal file
@@ -0,0 +1,25 @@
|
||||
// Routines for working with an account.
|
||||
//
|
||||
// Events:
|
||||
// wallet_clean : True, iff the wallet has been updated.
|
||||
// wallet_dirty : True, iff the wallet needs to be updated.
|
||||
// balance : The current stamp balance.
|
||||
// balance_proposed
|
||||
//
|
||||
|
||||
// var network = require("./network.js");
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var Amount = require('./amount.js').Amount;
|
||||
var UInt160 = require('./amount.js').UInt160;
|
||||
|
||||
var Account = function (network, account) {
|
||||
this._network = network;
|
||||
this._account = UInt160.json_rewrite(account);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
exports.Account = Account;
|
||||
|
||||
// vim:sw=2:sts=2:ts=8
|
||||
58
src/js/network.js
Normal file
58
src/js/network.js
Normal file
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// Access to the Ripple network via multiple untrusted servers or a single trusted server.
|
||||
//
|
||||
// Overview:
|
||||
// Network configuration.
|
||||
// Can leverage local storage to remember network configuration
|
||||
// Aquires the network
|
||||
// events:
|
||||
// online
|
||||
// offline
|
||||
//
|
||||
|
||||
var remote = require("./remote.js");
|
||||
|
||||
var opts_default = {
|
||||
DEFAULT_VALIDATORS_SITE : "redstem.com",
|
||||
|
||||
ips = {
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// opts : {
|
||||
// cache : undefined || {
|
||||
// get : function () { return cached_value; },
|
||||
// set : function (value) { cached_value = value; },
|
||||
// },
|
||||
//
|
||||
// // Where to get validators.txt if needed.
|
||||
// DEFAULT_VALIDATORS_SITE : _domain_,
|
||||
//
|
||||
// // Validator.txt to use.
|
||||
// validators : _txt_,
|
||||
// }
|
||||
//
|
||||
|
||||
var Network = function (opts) {
|
||||
|
||||
};
|
||||
|
||||
// Set the network configuration.
|
||||
Network.protocol.configure = function () {
|
||||
|
||||
};
|
||||
|
||||
// Target state: connectted
|
||||
Network.protocol.start = function () {
|
||||
|
||||
};
|
||||
|
||||
// Target state: disconnectted
|
||||
Network.protocol.stop = function () {
|
||||
|
||||
};
|
||||
|
||||
exports.Network = Network;
|
||||
|
||||
// vim:sw=2:sts=2:ts=8
|
||||
54
test/monitor-test.js
Normal file
54
test/monitor-test.js
Normal file
@@ -0,0 +1,54 @@
|
||||
var async = require("async");
|
||||
var buster = require("buster");
|
||||
|
||||
var Amount = require("../src/js/amount.js").Amount;
|
||||
var Remote = require("../src/js/remote.js").Remote;
|
||||
var Server = require("./server.js").Server;
|
||||
|
||||
var testutils = require("./testutils.js");
|
||||
|
||||
require("../src/js/amount.js").config = require("./config.js");
|
||||
require("../src/js/remote.js").config = require("./config.js");
|
||||
|
||||
buster.testRunner.timeout = 5000;
|
||||
|
||||
buster.testCase("Monitor account", {
|
||||
'setUp' : testutils.build_setup({ verbose: true }),
|
||||
'tearDown' : testutils.build_teardown(),
|
||||
|
||||
"monitor root" :
|
||||
function (done) {
|
||||
var self = this;
|
||||
|
||||
async.waterfall([
|
||||
function (callback) {
|
||||
self.what = "Create accounts.";
|
||||
|
||||
testutils.create_accounts(self.remote, "root", "10000", ["alice"], callback);
|
||||
},
|
||||
function (callback) {
|
||||
self.what = "Close ledger.";
|
||||
|
||||
self.remote.once('ledger_closed', function (ledger_closed, ledger_index) {
|
||||
callback();
|
||||
});
|
||||
|
||||
self.remote.ledger_accept();
|
||||
},
|
||||
function (callback) {
|
||||
self.what = "Dumping root.";
|
||||
|
||||
testutils.account_dump(self.remote, "root", function (error) {
|
||||
buster.refute(error);
|
||||
|
||||
callback();
|
||||
});
|
||||
},
|
||||
], function (error) {
|
||||
buster.refute(error, self.what);
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
// vim:sw=2:sts=2:ts=8
|
||||
Reference in New Issue
Block a user