|
6 | 6 |
|
7 | 7 | "github.com/scroll-tech/go-ethereum/common" |
8 | 8 | "github.com/scroll-tech/go-ethereum/core/types" |
| 9 | + "github.com/scroll-tech/go-ethereum/crypto/kzg4844" |
9 | 10 | "github.com/stretchr/testify/assert" |
10 | 11 | "github.com/stretchr/testify/require" |
11 | 12 | ) |
@@ -618,3 +619,57 @@ func TestCodecV0DecodeDAChunksRawTx(t *testing.T) { |
618 | 619 | assert.Equal(t, 1, len(daChunksRawTx[1].Transactions[0])) |
619 | 620 | assert.Equal(t, 0, len(daChunksRawTx[1].Transactions[1])) |
620 | 621 | } |
| 622 | + |
| 623 | +func TestDACodecV0SimpleMethods(t *testing.T) { |
| 624 | + codecv0, err := CodecFromVersion(CodecV0) |
| 625 | + require.NoError(t, err) |
| 626 | + |
| 627 | + t.Run("Version", func(t *testing.T) { |
| 628 | + version := codecv0.Version() |
| 629 | + assert.Equal(t, CodecV0, version) |
| 630 | + }) |
| 631 | + |
| 632 | + t.Run("CheckChunkCompressedDataCompatibility", func(t *testing.T) { |
| 633 | + chunk := &Chunk{} |
| 634 | + compatible, err := codecv0.CheckChunkCompressedDataCompatibility(chunk) |
| 635 | + assert.NoError(t, err) |
| 636 | + assert.True(t, compatible) |
| 637 | + }) |
| 638 | + |
| 639 | + t.Run("CheckBatchCompressedDataCompatibility", func(t *testing.T) { |
| 640 | + batch := &Batch{} |
| 641 | + compatible, err := codecv0.CheckBatchCompressedDataCompatibility(batch) |
| 642 | + assert.NoError(t, err) |
| 643 | + assert.True(t, compatible) |
| 644 | + }) |
| 645 | + |
| 646 | + t.Run("EstimateChunkL1CommitBatchSizeAndBlobSize", func(t *testing.T) { |
| 647 | + chunk := &Chunk{} |
| 648 | + batchSize, blobSize, err := codecv0.EstimateChunkL1CommitBatchSizeAndBlobSize(chunk) |
| 649 | + assert.NoError(t, err) |
| 650 | + assert.Equal(t, uint64(0), batchSize) |
| 651 | + assert.Equal(t, uint64(0), blobSize) |
| 652 | + }) |
| 653 | + |
| 654 | + t.Run("EstimateBatchL1CommitBatchSizeAndBlobSize", func(t *testing.T) { |
| 655 | + batch := &Batch{} |
| 656 | + batchSize, blobSize, err := codecv0.EstimateBatchL1CommitBatchSizeAndBlobSize(batch) |
| 657 | + assert.NoError(t, err) |
| 658 | + assert.Equal(t, uint64(0), batchSize) |
| 659 | + assert.Equal(t, uint64(0), blobSize) |
| 660 | + }) |
| 661 | + |
| 662 | + t.Run("JSONFromBytes", func(t *testing.T) { |
| 663 | + data := []byte("test data") |
| 664 | + json, err := codecv0.JSONFromBytes(data) |
| 665 | + assert.NoError(t, err) |
| 666 | + assert.Nil(t, json) |
| 667 | + }) |
| 668 | + |
| 669 | + t.Run("DecodeTxsFromBlob", func(t *testing.T) { |
| 670 | + blob := &kzg4844.Blob{} |
| 671 | + chunks := []*DAChunkRawTx{} |
| 672 | + err := codecv0.DecodeTxsFromBlob(blob, chunks) |
| 673 | + assert.NoError(t, err) |
| 674 | + }) |
| 675 | +} |
0 commit comments