|
1 | | -""" |
2 | | -abstract: Tests [EIP-7594: PeerDAS - Peer Data Availability Sampling](https://eips.ethereum.org/EIPS/eip-7594) |
3 | | - Tests [EIP-7594: PeerDAS - Peer Data Availability Sampling](https://eips.ethereum.org/EIPS/eip-7594). |
4 | | -""" # noqa: E501 |
| 1 | +"""Blob class and functionality.""" |
5 | 2 |
|
6 | 3 | import random |
7 | 4 | from enum import Enum |
@@ -403,72 +400,72 @@ def corrupt_byte(b: bytes) -> Bytes: |
403 | 400 | # static_blob.write_to_file() |
404 | 401 | # -------------------------------------------- |
405 | 402 |
|
406 | | -# myosaka: Fork = Osaka |
407 | | -# myprague: Fork = Prague |
408 | | -# mycancun: Fork = Cancun |
409 | | -# myseed: int = 1337 # fork+seed is the unique ID of a blob |
410 | | -# mytimestamp: int = 168123123 |
411 | | -# b: Blob = Blob.NewBlob(myosaka, myseed, mytimestamp) |
412 | | -# json_str: str = b.model_dump_json() |
413 | | -# restored: Blob = Blob.model_validate_json(json_str) |
414 | | -# assert b.data == restored.data |
415 | | -# assert b.commitment == restored.commitment |
416 | | -# assert b.proof == restored.proof |
417 | | -# assert b.cells == restored.cells |
418 | | -# assert b.versioned_hash == restored.versioned_hash |
419 | | -# assert b.name == restored.name |
420 | | -# assert b.fork == restored.fork |
421 | | -# assert b.timestamp == restored.timestamp |
422 | | -# print(type(b.proof), len(b.proof)) |
423 | | -# print(BYTES_PER_FIELD_ELEMENT) |
424 | | -# print(len(b.data)) |
425 | | -# b.write_to_file() |
426 | | -# c: Blob = Blob.LoadBlobFromFile("blob_" + "osaka" + "_" + str(myseed) + "_" + str(mytimestamp)) |
427 | | -# assert b.data == c.data |
428 | | -# assert b.commitment == c.commitment |
429 | | -# assert b.proof == c.proof |
430 | | -# assert b.cells == c.cells |
431 | | -# assert b.versioned_hash == c.versioned_hash |
432 | | -# assert b.name == c.name |
433 | | -# assert b.fork == c.fork |
434 | | -# assert b.timestamp == c.timestamp |
435 | | -# d: Blob = Blob.NewBlob(myprague, myseed, 123) |
436 | | -# d.write_to_file() |
437 | | -# e: Blob = Blob.NewBlob(myprague, myseed, 123) |
438 | | -# print("Line above should say blob already existed and was loaded from file") |
439 | | -# ee: Blob = Blob.NewBlob(myprague, myseed, 1234) |
440 | | -# newtimestamp = 999999 |
441 | | -# f: Blob = Blob.NewBlob(mycancun, 1337, newtimestamp) |
442 | | -# f.write_to_file() |
443 | | -# h: Blob = Blob.NewBlob(myosaka, myseed) |
444 | | -# h.write_to_file() |
445 | | -# zz: Blob = Blob.NewBlob(myosaka, myseed) |
446 | | -# print("Line above should say blob already existed and was loaded from file") |
447 | | -# # you can load a blob either via just filename or via absolute path or via relative path (cwd is ./src/ethereum_test_types) # noqa: E501 |
448 | | -# yyy: Blob = Blob.LoadBlobFromFile("blob_cancun_1337_999999.json") |
449 | | -# # yyyy: Blob = Blob.LoadBlobFromFile( |
450 | | -# # "/home/user/Documents/execution-spec-tests/tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337.json" # noqa: E501 |
451 | | -# # ) # you must replace user with ur actual username as $USER not supported here |
452 | | -# yyyyy: Blob = Blob.LoadBlobFromFile( |
453 | | -# "tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337_999999.json" |
454 | | -# ) |
455 | | -# zzzzzzz: Blob = Blob.LoadBlobFromFile( |
456 | | -# "./tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337_999999.json" |
457 | | -# ) |
458 | | - |
459 | | - |
460 | | -# # test proof corruption |
461 | | -# # osaka |
462 | | -# testseed = 55 |
463 | | -# ddd: Blob = Blob.NewBlob(Osaka, testseed + 10) |
464 | | -# oldValue = ddd.proof[0][5] |
465 | | -# for m in Blob.ProofCorruptionMode: |
466 | | -# ddd.corrupt_proof(m) |
467 | | -# print("proof corruption works (osaka):", oldValue != ddd.proof[0][5]) |
468 | | -# # prague |
469 | | -# eeeeeeeeee: Blob = Blob.NewBlob(Prague, testseed + 11) |
470 | | -# oldValue = eeeeeeeeee.proof[5] |
471 | | -# for m in Blob.ProofCorruptionMode: |
472 | | -# eeeeeeeeee.corrupt_proof(m) |
473 | | -# print("proof corruption works (prague):", oldValue != eeeeeeeeee.proof[5]) |
474 | | -# print("pydantic model works") |
| 403 | +myosaka: Fork = Osaka |
| 404 | +myprague: Fork = Prague |
| 405 | +mycancun: Fork = Cancun |
| 406 | +myseed: int = 1337 # fork+seed is the unique ID of a blob |
| 407 | +mytimestamp: int = 168123123 |
| 408 | +b: Blob = Blob.NewBlob(myosaka, myseed, mytimestamp) |
| 409 | +json_str: str = b.model_dump_json() |
| 410 | +restored: Blob = Blob.model_validate_json(json_str) |
| 411 | +assert b.data == restored.data |
| 412 | +assert b.commitment == restored.commitment |
| 413 | +assert b.proof == restored.proof |
| 414 | +assert b.cells == restored.cells |
| 415 | +assert b.versioned_hash == restored.versioned_hash |
| 416 | +assert b.name == restored.name |
| 417 | +assert b.fork == restored.fork |
| 418 | +assert b.timestamp == restored.timestamp |
| 419 | +print(type(b.proof), len(b.proof)) |
| 420 | +print(BYTES_PER_FIELD_ELEMENT) |
| 421 | +print(len(b.data)) |
| 422 | +b.write_to_file() |
| 423 | +c: Blob = Blob.LoadBlobFromFile("blob_" + "osaka" + "_" + str(myseed) + "_" + str(mytimestamp)) |
| 424 | +assert b.data == c.data |
| 425 | +assert b.commitment == c.commitment |
| 426 | +assert b.proof == c.proof |
| 427 | +assert b.cells == c.cells |
| 428 | +assert b.versioned_hash == c.versioned_hash |
| 429 | +assert b.name == c.name |
| 430 | +assert b.fork == c.fork |
| 431 | +assert b.timestamp == c.timestamp |
| 432 | +d: Blob = Blob.NewBlob(myprague, myseed, 123) |
| 433 | +d.write_to_file() |
| 434 | +e: Blob = Blob.NewBlob(myprague, myseed, 123) |
| 435 | +print("Line above should say blob already existed and was loaded from file") |
| 436 | +ee: Blob = Blob.NewBlob(myprague, myseed, 1234) |
| 437 | +newtimestamp = 999999 |
| 438 | +f: Blob = Blob.NewBlob(mycancun, 1337, newtimestamp) |
| 439 | +f.write_to_file() |
| 440 | +h: Blob = Blob.NewBlob(myosaka, myseed) |
| 441 | +h.write_to_file() |
| 442 | +zz: Blob = Blob.NewBlob(myosaka, myseed) |
| 443 | +print("Line above should say blob already existed and was loaded from file") |
| 444 | +# you can load a blob either via just filename or via absolute path or via relative path (cwd is ./src/ethereum_test_types) # noqa: E501 |
| 445 | +yyy: Blob = Blob.LoadBlobFromFile("blob_cancun_1337_999999.json") |
| 446 | +# yyyy: Blob = Blob.LoadBlobFromFile( |
| 447 | +# "/home/user/Documents/execution-spec-tests/tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337.json" # noqa: E501 |
| 448 | +# ) # you must replace user with ur actual username as $USER not supported here |
| 449 | +yyyyy: Blob = Blob.LoadBlobFromFile( |
| 450 | + "tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337_999999.json" |
| 451 | +) |
| 452 | +zzzzzzz: Blob = Blob.LoadBlobFromFile( |
| 453 | + "./tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337_999999.json" |
| 454 | +) |
| 455 | + |
| 456 | + |
| 457 | +# test proof corruption |
| 458 | +# osaka |
| 459 | +testseed = 55 |
| 460 | +ddd: Blob = Blob.NewBlob(Osaka, testseed + 10) |
| 461 | +oldValue = ddd.proof[0][5] |
| 462 | +for m in Blob.ProofCorruptionMode: |
| 463 | + ddd.corrupt_proof(m) |
| 464 | +print("proof corruption works (osaka):", oldValue != ddd.proof[0][5]) |
| 465 | +# prague |
| 466 | +eeeeeeeeee: Blob = Blob.NewBlob(Prague, testseed + 11) |
| 467 | +oldValue = eeeeeeeeee.proof[5] |
| 468 | +for m in Blob.ProofCorruptionMode: |
| 469 | + eeeeeeeeee.corrupt_proof(m) |
| 470 | +print("proof corruption works (prague):", oldValue != eeeeeeeeee.proof[5]) |
| 471 | +print("pydantic model works") |
0 commit comments