diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj
index bc089866b..3ca3c1267 100644
--- a/Builds/VisualStudio2013/RippleD.vcxproj
+++ b/Builds/VisualStudio2013/RippleD.vcxproj
@@ -3337,6 +3337,8 @@
+
+
@@ -3353,6 +3355,10 @@
True
True
+
+ True
+ True
+
True
True
diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters
index 4cf6a31ca..ef5c986d5 100644
--- a/Builds/VisualStudio2013/RippleD.vcxproj.filters
+++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters
@@ -4068,6 +4068,9 @@
ripple\test\jtx
+
+ ripple\test\jtx
+
ripple\test\jtx
@@ -4089,6 +4092,9 @@
ripple\test\jtx\impl
+
+ ripple\test\jtx\impl
+
ripple\test\jtx\impl
diff --git a/src/ripple/app/ledger/tests/DeferredCredits.test.cpp b/src/ripple/app/ledger/tests/DeferredCredits.test.cpp
index a7518f491..4640744f5 100644
--- a/src/ripple/app/ledger/tests/DeferredCredits.test.cpp
+++ b/src/ripple/app/ledger/tests/DeferredCredits.test.cpp
@@ -57,7 +57,7 @@ class DeferredCredits_test : public beast::unit_test::suite
auto master = createAccount ("masterpassphrase", keyType);
- Ledger::pointer LCL;
+ std::shared_ptr LCL;
Ledger::pointer ledger;
std::tie (LCL, ledger) = createGenesisLedger (100000 * xrp, master);
@@ -124,7 +124,7 @@ class DeferredCredits_test : public beast::unit_test::suite
auto master = createAccount ("masterpassphrase", keyType);
- Ledger::pointer LCL;
+ std::shared_ptr LCL;
Ledger::pointer ledger;
std::tie (LCL, ledger) = createGenesisLedger (100000 * xrp, master);
diff --git a/src/ripple/app/ledger/tests/Ledger_test.cpp b/src/ripple/app/ledger/tests/Ledger_test.cpp
index 94c0d3aed..deba77692 100644
--- a/src/ripple/app/ledger/tests/Ledger_test.cpp
+++ b/src/ripple/app/ledger/tests/Ledger_test.cpp
@@ -30,7 +30,7 @@ class Ledger_test : public beast::unit_test::suite
auto master = createAccount ("masterpassphrase", keyType);
- Ledger::pointer LCL;
+ std::shared_ptr LCL;
Ledger::pointer ledger;
std::tie(LCL, ledger) = createGenesisLedger(100000*xrp, master);
@@ -96,7 +96,7 @@ class Ledger_test : public beast::unit_test::suite
auto master = createAccount ("masterpassphrase", keyType);
- Ledger::pointer LCL;
+ std::shared_ptr LCL;
Ledger::pointer ledger;
std::tie(LCL, ledger) = createGenesisLedger (100000 * xrp, master);
diff --git a/src/ripple/app/ledger/tests/common_ledger.cpp b/src/ripple/app/ledger/tests/common_ledger.cpp
index b3d2cec4e..622ddfd80 100644
--- a/src/ripple/app/ledger/tests/common_ledger.cpp
+++ b/src/ripple/app/ledger/tests/common_ledger.cpp
@@ -137,11 +137,11 @@ applyTransaction(Ledger::pointer const& ledger, STTx const& tx, bool check)
// Create genesis ledger from a start amount in drops, and the public
// master RippleAddress
-std::pair
+std::pair, Ledger::pointer>
createGenesisLedger(std::uint64_t start_amount_drops, TestAccount const& master)
{
initializePathfinding();
- Ledger::pointer ledger = std::make_shared(master.pk,
+ auto ledger = std::make_shared(master.pk,
start_amount_drops);
ledger->getHash(); // updates the hash
ledger->setClosed();
@@ -198,7 +198,7 @@ createAndFundAccountsWithFlags(TestAccount& from,
std::vector passphrases,
KeyType keyType, std::uint64_t amountDrops,
Ledger::pointer& ledger,
- Ledger::pointer& LCL,
+ std::shared_ptr& LCL,
const std::uint32_t flags, bool sign)
{
auto accounts = createAndFundAccounts(from,
@@ -430,11 +430,14 @@ trust(TestAccount& from, TestAccount const& issuer,
}
void
-close_and_advance(Ledger::pointer& ledger, Ledger::pointer& LCL)
+close_and_advance(Ledger::pointer& ledger, std::shared_ptr& LCL)
{
std::shared_ptr set = ledger->peekTransactionMap();
CanonicalTXSet retriableTransactions(set->getHash());
- Ledger::pointer newLCL = std::make_shared(false, *LCL);
+ // Make a non-const copy of LCL. This won't be necessary once
+ // that other Ledger constructor can take a const Ledger.
+ Ledger oldLCL(*LCL, false);
+ Ledger::pointer newLCL = std::make_shared(false, oldLCL);
// Set up to write SHAMap changes to our database,
// perform updates, extract changes
applyTransactions(set, newLCL, newLCL, retriableTransactions, false);
@@ -453,8 +456,12 @@ close_and_advance(Ledger::pointer& ledger, Ledger::pointer& LCL)
bool closeTimeCorrect = true;
newLCL->setAccepted(closeTime, closeResolution, closeTimeCorrect);
+ if (!newLCL->assertSane())
+ throw std::runtime_error(
+ "!newLCL->assertSane()");
+
LCL = newLCL;
- ledger = std::make_shared(false, *LCL);
+ ledger = std::make_shared(false, *newLCL);
}
Json::Value findPath(Ledger::pointer ledger, TestAccount const& src,
diff --git a/src/ripple/app/ledger/tests/common_ledger.h b/src/ripple/app/ledger/tests/common_ledger.h
index 0fbcdf7ca..9e0f99cfc 100644
--- a/src/ripple/app/ledger/tests/common_ledger.h
+++ b/src/ripple/app/ledger/tests/common_ledger.h
@@ -125,7 +125,7 @@ applyTransaction(Ledger::pointer const& ledger, STTx const& tx, bool check = tru
// Create genesis ledger from a start amount in drops, and the public
// master RippleAddress
-std::pair
+std::pair, Ledger::pointer>
createGenesisLedger(std::uint64_t start_amount_drops, TestAccount const& master);
// Create an account represented by public RippleAddress and private
@@ -148,7 +148,7 @@ createAndFundAccountsWithFlags(TestAccount& from,
std::vector passphrases,
KeyType keyType, std::uint64_t amountDrops,
Ledger::pointer& ledger,
- Ledger::pointer& LCL,
+ std::shared_ptr& LCL,
const std::uint32_t flags, bool sign = true);
void
@@ -237,7 +237,7 @@ trust(TestAccount& from, TestAccount const& issuer,
Ledger::pointer const& ledger, bool sign = true);
void
-close_and_advance(Ledger::pointer& ledger, Ledger::pointer& LCL);
+close_and_advance(Ledger::pointer& ledger, std::shared_ptr& LCL);
Json::Value findPath(Ledger::pointer ledger, TestAccount const& src,
TestAccount const& dest, std::vector srcCurrencies,
diff --git a/src/ripple/app/paths/tests/Path_test.cpp b/src/ripple/app/paths/tests/Path_test.cpp
index ca355eebb..3c5a2dc85 100644
--- a/src/ripple/app/paths/tests/Path_test.cpp
+++ b/src/ripple/app/paths/tests/Path_test.cpp
@@ -37,7 +37,7 @@ class Path_test : public TestSuite
auto master = createAccount("masterpassphrase", KeyType::ed25519);
- Ledger::pointer LCL;
+ std::shared_ptr LCL;
Ledger::pointer ledger;
std::tie(LCL, ledger) = createGenesisLedger(100000 * xrp, master);
@@ -62,7 +62,7 @@ class Path_test : public TestSuite
auto master = createAccount("masterpassphrase", KeyType::ed25519);
- Ledger::pointer LCL;
+ std::shared_ptr LCL;
Ledger::pointer ledger;
std::tie(LCL, ledger) = createGenesisLedger(100000 * xrp, master);
@@ -100,7 +100,7 @@ class Path_test : public TestSuite
auto master = createAccount("masterpassphrase", KeyType::ed25519);
- Ledger::pointer LCL;
+ std::shared_ptr LCL;
Ledger::pointer ledger;
std::tie(LCL, ledger) = createGenesisLedger(100000 * xrp, master);
@@ -140,7 +140,7 @@ class Path_test : public TestSuite
auto master = createAccount("masterpassphrase", KeyType::ed25519);
- Ledger::pointer LCL;
+ std::shared_ptr LCL;
Ledger::pointer ledger;
std::tie(LCL, ledger) = createGenesisLedger(100000 * xrp, master);
diff --git a/src/ripple/app/tx/tests/common_transactor.cpp b/src/ripple/app/tx/tests/common_transactor.cpp
index 57bd5466e..eb73aadd1 100644
--- a/src/ripple/app/tx/tests/common_transactor.cpp
+++ b/src/ripple/app/tx/tests/common_transactor.cpp
@@ -103,7 +103,6 @@ std::pair TestLedger::applyTransaction (STTx const& tx, bool check)
// call to this method gets applied individually. So this transaction
// is guaranteed to be applied before the next one.
close_and_advance(openLedger_, lastClosedLedger_);
- suite_.expect (lastClosedLedger_->assertSane() == true);
// Check for the transaction in the closed ledger.
bool const foundTx =
diff --git a/src/ripple/app/tx/tests/common_transactor.h b/src/ripple/app/tx/tests/common_transactor.h
index 9ab15cd58..6baf109da 100644
--- a/src/ripple/app/tx/tests/common_transactor.h
+++ b/src/ripple/app/tx/tests/common_transactor.h
@@ -101,7 +101,7 @@ public:
class TestLedger
{
private:
- Ledger::pointer lastClosedLedger_;
+ std::shared_ptr lastClosedLedger_;
Ledger::pointer openLedger_;
beast::unit_test::suite& suite_;
diff --git a/src/ripple/test/jtx.h b/src/ripple/test/jtx.h
index ed8ea395e..3c48ba40e 100644
--- a/src/ripple/test/jtx.h
+++ b/src/ripple/test/jtx.h
@@ -23,6 +23,7 @@
// Convenience header that includes everything
#include
+#include
#include
#include
#include
diff --git a/src/ripple/test/jtx/advance.h b/src/ripple/test/jtx/advance.h
new file mode 100644
index 000000000..8fb3a2853
--- /dev/null
+++ b/src/ripple/test/jtx/advance.h
@@ -0,0 +1,38 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of rippled: https://github.com/ripple/rippled
+ Copyright (c) 2012, 2013 Ripple Labs Inc.
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+//==============================================================================
+
+#ifndef RIPPLE_TEST_JTX_ADVANCE_H_INCLUDED
+#define RIPPLE_TEST_JTX_ADVANCE_H_INCLUDED
+
+#include
+
+namespace ripple {
+namespace test {
+namespace jtx {
+
+// TODO EHENNIS: Return the transaction list.
+// (Coming soon.)
+void
+advance(Env& env, std::shared_ptr& last);
+
+} // jtx
+} // test
+} // ripple
+
+#endif
diff --git a/src/ripple/test/jtx/impl/Env_test.cpp b/src/ripple/test/jtx/impl/Env_test.cpp
index 98ed35ac1..7cc5a8ffa 100644
--- a/src/ripple/test/jtx/impl/Env_test.cpp
+++ b/src/ripple/test/jtx/impl/Env_test.cpp
@@ -530,6 +530,38 @@ public:
env(noop("alice"), memo("data1", "format1", "type1"), memo("data2", "format2", "type2"));
}
+ void
+ testAdvance()
+ {
+ using namespace jtx;
+ Env env(*this);
+ // Create the LCL as a copy of the Env's
+ // ledger. This will have the side effect
+ // of skipping one seq in Env.ledger the
+ // first time it is advanced. This can be
+ // worked around if desired by assigning
+ // an advanced ledger back to Env before
+ // starting, but it won't matter to most
+ // tests.
+ std::shared_ptr lastClosedLedger =
+ std::make_shared(
+ *env.ledger, false);
+
+ auto firstSeq = env.ledger->seq();
+
+ expect(lastClosedLedger->seq() == firstSeq);
+
+ advance(env, lastClosedLedger);
+
+ expect(lastClosedLedger->seq() == firstSeq + 1);
+ expect(env.ledger->seq() == firstSeq + 2);
+
+ advance(env, lastClosedLedger);
+
+ expect(lastClosedLedger->seq() == firstSeq + 2);
+ expect(env.ledger->seq() == firstSeq + 3);
+ }
+
void
run()
{
@@ -543,7 +575,6 @@ public:
testRequire();
testKeyType();
testPayments();
-
testMultiSign();
testMultiSign2();
testTicket();
@@ -552,6 +583,7 @@ public:
testJTxCopy();
testJTxMove();
testMemo();
+ testAdvance();
}
};
diff --git a/src/ripple/test/jtx/impl/advance.cpp b/src/ripple/test/jtx/impl/advance.cpp
new file mode 100644
index 000000000..655babd1c
--- /dev/null
+++ b/src/ripple/test/jtx/impl/advance.cpp
@@ -0,0 +1,38 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of rippled: https://github.com/ripple/rippled
+ Copyright (c) 2012, 2013 Ripple Labs Inc.
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+//==============================================================================
+
+#include
+#include
+#include
+#include
+
+namespace ripple {
+namespace test {
+namespace jtx {
+
+void
+advance(Env& env, std::shared_ptr& last)
+{
+ close_and_advance(env.ledger, last);
+}
+
+
+} // jtx
+} // test
+} // ripple
diff --git a/src/ripple/unity/test.cpp b/src/ripple/unity/test.cpp
index 8429b9c47..4364861c7 100644
--- a/src/ripple/unity/test.cpp
+++ b/src/ripple/unity/test.cpp
@@ -20,6 +20,7 @@
#include
#include
+#include
#include
#include
#include