Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic SSZ tests #1212

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
446 changes: 446 additions & 0 deletions SSZTests/bitlist/bitlist.json

Large diffs are not rendered by default.

402 changes: 402 additions & 0 deletions SSZTests/bitvector/bitvector.json

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions SSZTests/bool/bool_deserialization_invalid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"bool_byte80": {
"inType" : "Bool",
"in" : "error",
"out" : "0x80"
},
"bool_byte02": {
"inType" : "Bool",
"in" : "error",
"out" : "0x02"
},
"bool_byteff": {
"inType" : "Bool",
"in" : "error",
"out" : "0xff"
},
"bool_byte10": {
"inType" : "Bool",
"in" : "error",
"out" : "0x10"
}
}
17 changes: 17 additions & 0 deletions SSZTests/bool/bool_valid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"null": {
"inType" : "Null",
"in": null,
"out": "0x"
},
"bool_false": {
"inType" : "Bool",
"in" : false,
"out" : "0x00"
},
"bool_true": {
"inType" : "Bool",
"in" : true,
"out" : "0x01"
}
}
51 changes: 51 additions & 0 deletions SSZTests/exampleStructureEncoding.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
EXAMPLE ENCODING
aggregation_bits: '0xd203'
data:
slot: 16190417324762968195
index: 11925472494053767852
beacon_block_root: '0x6fdd48270188c7abda9c27cca8e670b7fbf2b2bbd3ad44c6ae07243d64b01bae'
source: {epoch: 11830679453202619032, root: '0x314da949cc563740f2316a5ab49867d4f8766cee4608ea29e3a4ab99ff0d9250'}
target: {epoch: 8155824741468644389, root: '0xecf4804a437264413f838299b81b2d9dc7b92e71e7743eda04389641224f8c98'}
signature: '0x63f34097da24274a0afeeab5415d301abfe395d9a38aab73e0e1a57510bdfa694a7205c6b181079b3a45618b1cd78622e4ff059b3c3b4793e2dec50f52c0099d02c71d0c58b29173c9eff94fd558edc2bceafa48b395abaacaca18663c7d3308'



SSZ:
e4000000 (must be ssz header 228 dec in uint32)

data:
slot: 83b0d3bfc6eaafe0 (little endian reverse)
index: ac3ac4aa0cca7fa5 (little endian reverse)
beacon root: 6fdd48270188c7abda9c27cca8e670b7fbf2b2bbd3ad44c6ae07243d64b01bae
source:
epoch: 989aa7f347042fa4 (little endian reverse)
root: 314da949cc563740f2316a5ab49867d4f8766cee4608ea29e3a4ab99ff0d9250
target:
epoch: 25a49415644f2f71 (little endian reverse)
root: ecf4804a437264413f838299b81b2d9dc7b92e71e7743eda04389641224f8c98

signature: 63f34097da24274a0afeeab5415d301abfe395d9a38aab73e0e1a57510bdfa694a7205c6b181079b3a45618b1cd78622e4ff059b3c3b4793e2dec50f52c0099d02c71d0c58b29173c9eff94fd558edc2bceafa48b395abaacaca18663c7d3308
aggregation_bits: d203 (why not reversed?)


SIZE:
e4000000 (must be ssz header 228 dec in uint32) the bytes length below size is 226

8 slot: 83b0d3bfc6eaafe0 (little endian reverse)
8 index: ac3ac4aa0cca7fa5 (little endian reverse)
32 beacon root: 6fdd48270188c7abda9c27cca8e670b7fbf2b2bbd3ad44c6ae07243d64b01bae
source:
8 epoch: 989aa7f347042fa4 (little endian reverse)
32 root: 314da949cc563740f2316a5ab49867d4f8766cee4608ea29e3a4ab99ff0d9250
target:
8 epoch: 25a49415644f2f71 (little endian reverse)
32 root: ecf4804a437264413f838299b81b2d9dc7b92e71e7743eda04389641224f8c98
96 112233445566778899101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
signature: 63f34097da24274a0afeeab5415d301abfe395d9a38aab73e0e1a57510bdfa694a7205c6b181079b3a45618b1cd78622e4ff059b3c3b4793e2dec50f52c0099d02c71d0c58b29173c9eff94fd558edc2bceafa48b395abaacaca18663c7d3308
2 aggregation_bits: d203 (why not reversed?)

314da949cc563740f2316a5ab49867d4f8766cee4608ea29e3a4ab99ff0d9250




122 changes: 122 additions & 0 deletions SSZTests/uint/integralTypes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"uint8": {
"inType" : "Uint8",
"in": 1,
"out": "0x01"
},
"uint8_zero": {
"inType" : "Uint8",
"in": 0,
"out": "0x00"
},
"uint8_max": {
"inType" : "Uint8",
"in": 255,
"out": "0xff"
},
"uint8_overflow": {
"inType" : "Uint8",
"in": 256,
"out": "error"
},
"uint16": {
"inType" : "Uint16",
"in": 1,
"out": "0x0100"
},
"uint16_zero": {
"inType" : "Uint16",
"in": 0,
"out": "0x0000"
},
"uint16_max": {
"inType" : "Uint16",
"in": 65535,
"out": "0xffff"
},
"uint16_overflow": {
"inType" : "Uint16",
"in": 65536,
"out": "error"
},
"uint32": {
"inType" : "Uint32",
"in": "1",
"out": "0x01000000"
},
"uint32_zero": {
"inType" : "Uint32",
"in": "0",
"out": "0x00000000"
},
"uint32_max": {
"inType" : "Uint32",
"in": "4294967295",
"out": "0xffffffff"
},
"uint32_overflow": {
"inType" : "Uint32",
"in": "4294967296",
"out": "error"
},
"uint64": {
"inType" : "Uint64",
"in": "1",
"out": "0x0100000000000000"
},
"uint64_zero": {
"inType" : "Uint64",
"in": "0",
"out": "0x0000000000000000"
},
"uint64_max": {
"inType" : "Uint64",
"in": "18446744073709551615",
"out": "0xffffffffffffffff"
},
"uint64_overflow": {
"inType" : "Uint64",
"in": "18446744073709551616",
"out": "error"
},
"uint128": {
"inType" : "Uint128",
"in": "1",
"out": "0x01000000000000000000000000000000"
},
"uint128_zero": {
"inType" : "Uint128",
"in": "0",
"out": "0x00000000000000000000000000000000"
},
"uint128_max": {
"inType" : "Uint128",
"in": "340282366920938463463374607431768211455",
"out": "0xffffffffffffffffffffffffffffffff"
},
"uint128_overflow": {
"inType" : "Uint128",
"in": "340282366920938463463374607431768211456",
"out": "error"
},
"uint256": {
"inType" : "Uint256",
"in": "1",
"out": "0x0100000000000000000000000000000000000000000000000000000000000000"
},
"uint256_zero": {
"inType" : "Uint256",
"in": "0",
"out": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
"uint256_max": {
"inType" : "Uint256",
"in": "115792089237316195423570985008687907853269984665640564039457584007913129639935",
"out": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
"uint256_overflow": {
"inType" : "Uint256",
"in": "115792089237316195423570985008687907853269984665640564039457584007913129639936",
"out": "error"
}
}
92 changes: 92 additions & 0 deletions SSZTests/uint/uint_deserialization_invalid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"uint_128_one_byte_shorter": {
"inType" : "Uint128",
"in" : "error",
"out" : "0xffffffffffffffffffffffffffffff"
},
"uint_64_one_byte_shorter": {
"inType" : "Uint64",
"in" : "error",
"out" : "0xffffffffffffff"
},
"uint_32_one_byte_shorter": {
"inType" : "Uint32",
"in" : "error",
"out" : "0xffffff"
},
"uint_32_one_too_high": {
"inType" : "Uint32",
"in" : "error",
"out" : "0x0000000001"
},
"uint_128_one_too_high": {
"inType" : "Uint128",
"in" : "error",
"out" : "0x0000000000000000000000000000000001"
},
"uint_16_one_byte_shorter": {
"inType" : "Uint16",
"in" : "error",
"out" : "0xff"
},
"uint_8_one_too_high": {
"inType" : "Uint8",
"in" : "error",
"out" : "0x0001"
},
"uint_32_one_byte_longer": {
"inType" : "Uint32",
"in" : "error",
"out" : "0xffffffff00"
},
"uint_8_one_byte_shorter": {
"inType" : "Uint8",
"in" : "error",
"out" : "0x"
},
"uint_256_one_too_high": {
"inType" : "Uint256",
"in" : "error",
"out" : "0x000000000000000000000000000000000000000000000000000000000000000001"
},
"uint_8_one_byte_longer": {
"inType" : "Uint8",
"in" : "error",
"out" : "0xff00"
},
"uint_128_one_byte_longer": {
"inType" : "Uint128",
"in" : "error",
"out" : "0xffffffffffffffffffffffffffffffff00"
},
"uint_256_one_byte_longer": {
"inType" : "Uint256",
"in" : "error",
"out" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00"
},
"uint_64_one_too_high": {
"inType" : "Uint64",
"in" : "error",
"out" : "0x000000000000000001"
},
"uint_256_one_byte_shorter": {
"inType" : "Uint256",
"in" : "error",
"out" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
"uint_16_one_byte_longer": {
"inType" : "Uint16",
"in" : "error",
"out" : "0xffff00"
},
"uint_16_one_too_high": {
"inType" : "Uint16",
"in" : "error",
"out" : "0x000001"
},
"uint_64_one_byte_longer": {
"inType" : "Uint64",
"in" : "error",
"out" : "0xffffffffffffffff00"
}
}
Loading