|
588 | 588 | expect(stored[:content]).to eq("Hello from Input123") |
589 | 589 | end |
590 | 590 | end |
| 591 | + |
| 592 | + describe "Large content with SSTORE2Unlimited" do |
| 593 | + it "successfully stores and retrieves content larger than 24KB" do |
| 594 | + # Create content larger than 24KB (24576 bytes) |
| 595 | + # The old bytecode size limit was 24KB, but our SSTORE2Unlimited removes this restriction |
| 596 | + large_content_size = 30_000 # 30KB, well over the old 24KB limit |
| 597 | + large_text = "A" * large_content_size |
| 598 | + large_data_uri = "data:text/plain;charset=utf-8,#{large_text}" |
| 599 | + |
| 600 | + # Create the large ethscription |
| 601 | + expect_ethscription_success( |
| 602 | + create_input( |
| 603 | + creator: alice, |
| 604 | + to: bob, |
| 605 | + data_uri: large_data_uri |
| 606 | + ) |
| 607 | + ) do |results| |
| 608 | + # Verify the ethscription was created |
| 609 | + expect(results[:ethscription_ids].size).to eq(1) |
| 610 | + expect(results[:l2_receipts].first[:status]).to eq('0x1') |
| 611 | + |
| 612 | + # Retrieve and verify the stored content |
| 613 | + stored = get_ethscription_content(results[:ethscription_ids].first) |
| 614 | + |
| 615 | + # Verify the content size |
| 616 | + expect(stored[:content].length).to eq(large_content_size) |
| 617 | + |
| 618 | + # Verify the content matches exactly |
| 619 | + expect(stored[:content]).to eq(large_text) |
| 620 | + |
| 621 | + # Verify other metadata |
| 622 | + expect(stored[:mimetype]).to eq("text/plain") |
| 623 | + |
| 624 | + # Log success for visibility |
| 625 | + puts "✓ Successfully created and retrieved ethscription with #{large_content_size} bytes (#{large_content_size / 1024}KB) of content" |
| 626 | + end |
| 627 | + end |
| 628 | + |
| 629 | + it "handles very large content (100KB+)" do |
| 630 | + # Test with even larger content to ensure SSTORE2Unlimited works for very large data |
| 631 | + very_large_content_size = 100_000 # 100KB |
| 632 | + |
| 633 | + # Create repeating pattern to make it compressible but still large |
| 634 | + pattern = "Hello World! This is a test of very large content storage. " |
| 635 | + repeat_count = very_large_content_size / pattern.length |
| 636 | + very_large_text = pattern * repeat_count |
| 637 | + very_large_data_uri = "data:text/plain;charset=utf-8,#{very_large_text}" |
| 638 | + |
| 639 | + # Create the very large ethscription |
| 640 | + expect_ethscription_success( |
| 641 | + create_input( |
| 642 | + creator: alice, |
| 643 | + to: bob, |
| 644 | + data_uri: very_large_data_uri |
| 645 | + ) |
| 646 | + ) do |results| |
| 647 | + # Verify creation |
| 648 | + expect(results[:ethscription_ids].size).to eq(1) |
| 649 | + |
| 650 | + # Retrieve and verify |
| 651 | + stored = get_ethscription_content(results[:ethscription_ids].first) |
| 652 | + |
| 653 | + # Verify size (approximately, due to pattern repetition) |
| 654 | + expect(stored[:content].length).to be >= (very_large_content_size * 0.9) |
| 655 | + |
| 656 | + # Verify content starts correctly |
| 657 | + expect(stored[:content]).to start_with(pattern) |
| 658 | + |
| 659 | + puts "✓ Successfully handled very large ethscription with ~#{stored[:content].length} bytes (~#{stored[:content].length / 1024}KB) of content" |
| 660 | + end |
| 661 | + end |
| 662 | + |
| 663 | + it "correctly handles large Base64-encoded binary content" do |
| 664 | + # Test with large binary content (e.g., image data) encoded as Base64 |
| 665 | + # Generate pseudo-random binary data |
| 666 | + binary_size = 25_000 # 25KB of binary data |
| 667 | + binary_data = (0...binary_size).map { rand(256).chr }.join |
| 668 | + base64_content = Base64.strict_encode64(binary_data) |
| 669 | + |
| 670 | + # Create data URI with Base64-encoded content |
| 671 | + large_base64_uri = "data:application/octet-stream;base64,#{base64_content}" |
| 672 | + |
| 673 | + expect_ethscription_success( |
| 674 | + create_input( |
| 675 | + creator: alice, |
| 676 | + to: bob, |
| 677 | + data_uri: large_base64_uri |
| 678 | + ) |
| 679 | + ) do |results| |
| 680 | + # Verify creation |
| 681 | + expect(results[:ethscription_ids].size).to eq(1) |
| 682 | + |
| 683 | + # Retrieve stored content |
| 684 | + stored = get_ethscription_content(results[:ethscription_ids].first) |
| 685 | + |
| 686 | + # Content should be the decoded binary, not the base64 string |
| 687 | + expect(stored[:content].length).to eq(binary_size) |
| 688 | + expect(stored[:content].encoding).to eq(Encoding::ASCII_8BIT) |
| 689 | + |
| 690 | + # Verify mimetype |
| 691 | + expect(stored[:mimetype]).to eq("application/octet-stream") |
| 692 | + |
| 693 | + # Verify content matches original binary data |
| 694 | + expect(stored[:content]).to eq(binary_data) |
| 695 | + |
| 696 | + puts "✓ Successfully stored and retrieved #{binary_size} bytes of binary content via Base64 encoding" |
| 697 | + end |
| 698 | + end |
| 699 | + |
| 700 | + it "handles large JSON content" do |
| 701 | + # Create a large JSON structure |
| 702 | + large_json_obj = { |
| 703 | + "description" => "Large JSON test for SSTORE2Unlimited", |
| 704 | + "data" => (1..1000).map do |i| |
| 705 | + { |
| 706 | + "id" => i, |
| 707 | + "name" => "Item #{i}", |
| 708 | + "description" => "This is a description for item number #{i} in our large JSON test", |
| 709 | + "attributes" => { |
| 710 | + "color" => ["red", "blue", "green", "yellow"].sample, |
| 711 | + "size" => rand(1..100), |
| 712 | + "weight" => rand(1.0..100.0).round(2), |
| 713 | + "tags" => ["tag1", "tag2", "tag3", "tag4", "tag5"] |
| 714 | + } |
| 715 | + } |
| 716 | + end |
| 717 | + } |
| 718 | + |
| 719 | + large_json_string = JSON.generate(large_json_obj) |
| 720 | + json_data_uri = "data:application/json,#{large_json_string}" |
| 721 | + |
| 722 | + puts "JSON content size: #{large_json_string.length} bytes (#{large_json_string.length / 1024}KB)" |
| 723 | + |
| 724 | + expect_ethscription_success( |
| 725 | + create_input( |
| 726 | + creator: alice, |
| 727 | + to: bob, |
| 728 | + data_uri: json_data_uri |
| 729 | + ) |
| 730 | + ) do |results| |
| 731 | + # Verify creation |
| 732 | + expect(results[:ethscription_ids].size).to eq(1) |
| 733 | + |
| 734 | + # Retrieve and parse stored JSON |
| 735 | + stored = get_ethscription_content(results[:ethscription_ids].first) |
| 736 | + parsed_json = JSON.parse(stored[:content]) |
| 737 | + |
| 738 | + # Verify JSON structure |
| 739 | + expect(parsed_json["data"].length).to eq(1000) |
| 740 | + expect(parsed_json["description"]).to eq("Large JSON test for SSTORE2Unlimited") |
| 741 | + |
| 742 | + # Verify mimetype |
| 743 | + expect(stored[:mimetype]).to eq("application/json") |
| 744 | + |
| 745 | + puts "✓ Successfully stored and retrieved large JSON with #{stored[:content].length} bytes" |
| 746 | + end |
| 747 | + end |
| 748 | + end |
591 | 749 | end |
592 | 750 | end |
0 commit comments