From 12d5dd8aabeddc2511a62917b7b28293208f1c6e Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Tue, 15 May 2012 16:16:58 -0700 Subject: [PATCH 1/6] Fix --test. --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 249751576..ba23ff80d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -119,9 +119,9 @@ int main(int argc, char* argv[]) pvCmd.resize(iCmd); for (int i=0; i != iCmd; ++i) - pvCmd[i] = (char*) (vCmd[0].c_str()); + pvCmd[i] = (char*) (vCmd[i].c_str()); - iResult = unit_test_main(init_unit_test, iCmd, &pvCmd.front()); + iResult = unit_test_main(init_unit_test, iCmd, &pvCmd[0]); } else if (!vm.count("parameters")) { From 7ca88ebb140076e188e68f74208d157305d49d3e Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Tue, 15 May 2012 16:17:41 -0700 Subject: [PATCH 2/6] Fix Ledger formats. --- src/LedgerFormats.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LedgerFormats.cpp b/src/LedgerFormats.cpp index 9dad266a6..57eea8e2f 100644 --- a/src/LedgerFormats.cpp +++ b/src/LedgerFormats.cpp @@ -12,7 +12,7 @@ LedgerEntryFormat LedgerFormats[]= { S_FIELD(Balance), STI_UINT64, SOE_REQUIRED, 0 }, { S_FIELD(LastReceive), STI_UINT32, SOE_REQUIRED, 0 }, { S_FIELD(LastTxn), STI_UINT32, SOE_REQUIRED, 0 }, - { S_FIELD(AuthorizedKey),STI_VL, SOE_IFFLAG, 1 }, + { S_FIELD(AuthorizedKey),STI_HASH160, SOE_IFFLAG, 1 }, { S_FIELD(EmailHash), STI_HASH128, SOE_IFFLAG, 2 }, { S_FIELD(WalletLocator),STI_HASH256, SOE_IFFLAG, 4 }, { S_FIELD(MessageKey), STI_VL, SOE_IFFLAG, 8 }, @@ -21,7 +21,7 @@ LedgerEntryFormat LedgerFormats[]= }, { "GeneratorMap", ltGENERATOR_MAP, { { S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 }, - { S_FIELD(GeneratorID), STI_ACCOUNT, SOE_REQUIRED, 0 }, + { S_FIELD(GeneratorID), STI_HASH160, SOE_REQUIRED, 0 }, { S_FIELD(Generator), STI_VL, SOE_REQUIRED, 0 }, { S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x01000000 }, { sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } } From 0b5a5e710ee6b2a9354289caf7fa0684ff977337 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Tue, 15 May 2012 16:18:23 -0700 Subject: [PATCH 3/6] Fix tag check in SHAMap. --- src/LedgerNode.cpp | 2 +- src/SHAMap.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/LedgerNode.cpp b/src/LedgerNode.cpp index 29b659649..67216fc1d 100644 --- a/src/LedgerNode.cpp +++ b/src/LedgerNode.cpp @@ -33,7 +33,7 @@ LedgerStateParms Ledger::writeBack(LedgerStateParms parms, SerializedLedgerEntry return lepCREATED; } - if(!mAccountStateMap->updateGiveItem(item, false)) + if (!mAccountStateMap->updateGiveItem(item, false)) { assert(false); return lepERROR; diff --git a/src/SHAMap.cpp b/src/SHAMap.cpp index 1779d5f32..ad7f42be4 100644 --- a/src/SHAMap.cpp +++ b/src/SHAMap.cpp @@ -520,12 +520,12 @@ bool SHAMap::updateGiveItem(SHAMapItem::pointer item, bool isTransaction) boost::recursive_mutex::scoped_lock sl(mLock); std::stack stack = getStack(tag, true); - if(stack.empty()) throw SHAMapException(MissingNode); + if (stack.empty()) throw SHAMapException(MissingNode); SHAMapTreeNode::pointer node=stack.top(); stack.pop(); - if (!node->isLeaf() || (node->peekItem()->getTag() == tag) ) + if (!node->isLeaf() || (node->peekItem()->getTag() != tag) ) { assert(false); return false; From 3a88ea66df9edf0744aae36e2f2ab362f224812e Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Tue, 15 May 2012 16:18:56 -0700 Subject: [PATCH 4/6] Cosmetic changes. --- src/TransactionEngine.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/TransactionEngine.cpp b/src/TransactionEngine.cpp index 0900987df..aba6aa276 100644 --- a/src/TransactionEngine.cpp +++ b/src/TransactionEngine.cpp @@ -189,7 +189,7 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran if (result == terSUCCESS) { // Write back the account states and add the transaction to the ledger // WRITEME: Special case code for changing transaction key - for(std::vector::iterator it=accounts.begin(), end=accounts.end(); + for (std::vector::iterator it=accounts.begin(), end=accounts.end(); it != end; ++it) { if (it->first == taaCREATE) { @@ -198,12 +198,12 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran } else if (it->first==taaMODIFY) { - if(mLedger->writeBack(lepNONE, it->second) & lepERROR) + if (mLedger->writeBack(lepNONE, it->second) & lepERROR) assert(false); } else if (it->first == taaDELETE) { - if(!mLedger->peekAccountStateMap()->delItem(it->second->getIndex())) + if (!mLedger->peekAccountStateMap()->delItem(it->second->getIndex())) assert(false); } } From 0936bd9ec7c2f6199da5f85cadcbf52521d5b506 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Tue, 15 May 2012 16:21:21 -0700 Subject: [PATCH 5/6] Cosmetic changes. --- src/LedgerFormats.cpp | 8 ++++---- src/TransactionFormats.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/LedgerFormats.cpp b/src/LedgerFormats.cpp index 9dad266a6..dc9c75943 100644 --- a/src/LedgerFormats.cpp +++ b/src/LedgerFormats.cpp @@ -55,11 +55,11 @@ LedgerEntryFormat LedgerFormats[]= LedgerEntryFormat* getLgrFormat(LedgerEntryType t) { - LedgerEntryFormat* f=LedgerFormats; - while(f->t_name!=NULL) + LedgerEntryFormat* f = LedgerFormats; + while(f->t_name != NULL) { - if(f->t_type==t) return f; - f++; + if(f->t_type == t) return f; + ++f; } return NULL; } diff --git a/src/TransactionFormats.cpp b/src/TransactionFormats.cpp index 568d076eb..7f0aa1518 100644 --- a/src/TransactionFormats.cpp +++ b/src/TransactionFormats.cpp @@ -55,11 +55,11 @@ TransactionFormat InnerTxnFormats[]= TransactionFormat* getTxnFormat(TransactionType t) { - TransactionFormat* f=InnerTxnFormats; - while(f->t_name!=NULL) + TransactionFormat* f = InnerTxnFormats; + while(f->t_name != NULL) { - if(f->t_type==t) return f; - f++; + if(f->t_type == t) return f; + ++f; } return NULL; } From f208c570bf69e620b10046a354460d38df752cc8 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Tue, 15 May 2012 16:33:06 -0700 Subject: [PATCH 6/6] Fix unit test calling code. --- src/main.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ba23ff80d..153f539a3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,6 +6,7 @@ #include +#include #include #include @@ -108,18 +109,20 @@ int main(int argc, char* argv[]) } else if (vm.count("test")) { - std::vector vCmd; - int iCmd = vm.count("parameters"); + int iCmd = vm.count("parameters"); + std::vector pvCmd; + + pvCmd.push_back(argv[0]); if (iCmd) + { + std::vector vCmd; + vCmd = vm["parameters"].as >(); - std::vector pvCmd; - - pvCmd.resize(iCmd); - - for (int i=0; i != iCmd; ++i) - pvCmd[i] = (char*) (vCmd[i].c_str()); + BOOST_FOREACH(std::string& param, vCmd) + pvCmd.push_back(const_cast(param.c_str())); + } iResult = unit_test_main(init_unit_test, iCmd, &pvCmd[0]); }