Latest RLP standard. Lists specify length rather than itemCount.

This commit is contained in:
Gav Wood 2014-02-05 01:16:11 +00:00
parent 8e90047882
commit 4e2e3149b6
2 changed files with 8 additions and 8 deletions

View File

@ -35,19 +35,19 @@ using namespace eth;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
RLPStream s; /* RLPStream s;
BlockInfo::genesis().fillStream(s, false); BlockInfo::genesis().fillStream(s, false);
std::cout << RLP(s.out()) << std::endl; std::cout << RLP(s.out()) << std::endl;
std::cout << asHex(s.out()) << std::endl; std::cout << asHex(s.out()) << std::endl;
std::cout << sha3(s.out()) << std::endl; std::cout << sha3(s.out()) << std::endl;*/
// hexPrefixTest(); hexPrefixTest();
// rlpTest(); rlpTest();
trieTest(); trieTest();
// daggerTest(); // daggerTest();
// cryptoTest(); // cryptoTest();
// stateTest(); // stateTest();
peerTest(argc, argv); // peerTest(argc, argv);
return 0; return 0;
} }

View File

@ -35,12 +35,12 @@ int rlpTest()
assert(asString(rlp("dog")) == "\x83""dog"); assert(asString(rlp("dog")) == "\x83""dog");
// 2-item list // 2-item list
string twoItemListString = "\xc2\x0f\x83""dog"; string twoItemListString = "\xc5\x0f\x83""dog";
RLP twoItemList(twoItemListString); RLP twoItemList(twoItemListString);
assert(twoItemList.itemCount() == 2); assert(twoItemList.itemCount() == 2);
assert(twoItemList[0] == 15); assert(twoItemList[0] == 15);
assert(twoItemList[1] == "dog"); assert(twoItemList[1] == "dog");
assert(asString(rlpList(15, "dog")) == "\xc2\x0f\x83""dog"); assert(asString(rlpList(15, "dog")) == "\xc5\x0f\x83""dog");
// null // null
assert(RLP("\x80") == ""); assert(RLP("\x80") == "");
@ -56,7 +56,7 @@ int rlpTest()
// 32-byte (256-bit) int // 32-byte (256-bit) int
assert(RLP("\xa0\x10\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f") == bigint("0x100102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")); assert(RLP("\xa0\x10\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f") == bigint("0x100102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"));
assert(asString(rlp(bigint("0x100102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"))) == "\x37\x10\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"); assert(asString(rlp(bigint("0x100102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"))) == "\xa0\x10\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f");
// 56-character string. // 56-character string.
assert(RLP("\xb8\x38""Lorem ipsum dolor sit amet, consectetur adipisicing elit") == "Lorem ipsum dolor sit amet, consectetur adipisicing elit"); assert(RLP("\xb8\x38""Lorem ipsum dolor sit amet, consectetur adipisicing elit") == "Lorem ipsum dolor sit amet, consectetur adipisicing elit");