Bugfixes and new code. Ledger unit test now successfully creates a local

account, creates an initial ledger, closes the initial ledger and opens a
new ledger, creates a second account, and adds a transaction to transfer
funds to the open ledger.
This commit is contained in:
JoelKatz
2011-11-30 12:19:48 -08:00
parent b301fe2846
commit f243286bc9
7 changed files with 135 additions and 72 deletions

View File

@@ -5,9 +5,13 @@ AccountState::AccountState(const std::vector<unsigned char>& v)
{
Serializer s(v);
mValid=false;
if(!s.get160(mAccountID, 0)) return;
if(!s.get64(mBalance, 20)) return;
if(!s.get32(mAccountSeq, 28)) return;
if(!s.get160(mAccountID, 0)) { assert(false); return; }
if(!s.get64(mBalance, 20)) { assert(false); return; }
if(!s.get32(mAccountSeq, 28)) { assert(false); return; }
#ifdef DEBUG
std::cerr << "SerializeAccount >> " << mAccountID.GetHex() << ", " << mBalance << ", " << mAccountSeq <<
std::endl;
#endif
mValid=true;
}
@@ -20,5 +24,12 @@ std::vector<unsigned char> AccountState::getRaw() const
s.add160(mAccountID);
s.add64(mBalance);
s.add32(mAccountSeq);
#ifdef DEBUG
std::cerr << "SerializeAccount << " << mAccountID.GetHex() << ", " << mBalance << ", " << mAccountSeq <<
std::endl;
uint64 test;
assert(s.get64(test, 20));
assert(test==mBalance);
#endif
return s.getData();
}