Integration tests
Basic usage.
Documentation for installation of dependencies and running these tests can be found with the Rippled build instructions. (Also for Windows, OS X, or Ubuntu.)
Advanced usage.
These instructions assume familiarity with the instructions linked above.
Debugging rippled
By default, each test will start and stop an independent instance of rippled.
This ensures that each test is run against the known
genesis ledger.
To use a running rippled, particularly one running in a debugger, follow
these steps:
Setup
Using configuration files
-
Make a copy of the example configuration file:
cp -i test/config-example.js test/config.js -
Edit
test/config.jsto select the "debug" server configuration.
- Change the existing default server to:
exports.server_default = "debug";(near the top of the file).
- Create a
rippled.cfgfile for the tests. - Run
npm test. The tests will fail. This failure is expected. - Copy and/or rename the
tmp/server/debug/rippled.cfgfile to somewhere convenient.
Using the command line
- Create a
rippled.cfgfile for the tests. - Run
npm test --noserver. The tests will fail. This failure is expected. - Copy and/or rename the
tmp/server/alpha/rippled.cfgfile to somewhere convenient.
Running the tests.
-
Start
rippled(in a debugger) with command line options-av --conf <rippled-created-above.cfg>. -
Set any desired breakpoints in the
rippledsource. -
Running one test per genesis ledger is highly recommended. If the relevant
.jsfile contains more than one test, changetest(totest.only(for the single desired test.
- To run multiple tests, change
test(totest.skip(for any undesired tests in the .js file.
-
Start test(s) in the node-inspector debugger. (The tests can be run without the debugger, but there will probably be problems with timeouts or reused ledgers).
-
node_modules/node-inspector/bin/inspector.js & -
node node_modules/.bin/mocha --debug --debug-brk test/<testfile.js> -
Browse to http://127.0.0.1:8080/debug?port=5858 in a browser supported by node-inspector (i.e. Chrome or Safari).
-
To run multiple tests (not recommended), put a breakpoint in the following function:
- File
testutils.js-> functionbuild_teardown()-> nested functionteardown()-> nested series functionstop_server().- When this breakpoint is hit, stop and restart
rippled.
- When this breakpoint is hit, stop and restart
- Use the node-inspector UI to step through and run
the test(s) until control is handed off to
rippled. When the request is finished control will be handed back to node-inspector, which may or may not stop depending on which breakpoints are set.
After debugging using configuration files.
With the command line --noserver flag, this step is unnecessary.
- To return to the default behavior, edit
test/config.jsand change the default server back to its original value:exports.server_default = "alpha";.
- Alternately, delete
test/config.js.