Skip to content

Commit

Permalink
add batch hash unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo committed Oct 16, 2024
1 parent aa46689 commit 22c3772
Show file tree
Hide file tree
Showing 5 changed files with 340 additions and 0 deletions.
68 changes: 68 additions & 0 deletions encoding/codecv0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/hex"
"testing"

"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -261,3 +262,70 @@ func TestCodecV0BatchEncode(t *testing.T) {
encoded = hex.EncodeToString(daBatch.Encode())
assert.Equal(t, "000000000000000000000000000000002a000000000000002a1f9b3d942a6ee14e7afc52225c91fa44faa0a7ec511df9a2d9348d33bcd142fc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffbff", encoded)
}

func TestCodecV0BatchHash(t *testing.T) {
codecv0, err := CodecFromVersion(CodecV0)
assert.NoError(t, err)

// empty batch
batch := &daBatchV1{
daBatchV0: daBatchV0{
version: uint8(CodecV0),
},
}
assert.Equal(t, common.HexToHash("0x7f74e58579672e582998264e7e8191c51b6b8981afd0f9bf1a2ffc3abb39e678"), batch.Hash())

block2 := readBlockFromJSON(t, "testdata/blockTrace_02.json")
chunk2 := &Chunk{Blocks: []*Block{block2}}
originalBatch := &Batch{Chunks: []*Chunk{chunk2}}
daBatch, err := codecv0.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x4605465b7470c8565b123330d7186805caf9a7f2656d8e9e744b62e14ca22c3d"), daBatch.Hash())

block3 := readBlockFromJSON(t, "testdata/blockTrace_03.json")
chunk3 := &Chunk{Blocks: []*Block{block3}}
originalBatch = &Batch{Chunks: []*Chunk{chunk3}}
daBatch, err = codecv0.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x922e004553d563bde6560a827c6449200bfd84f92917dfa14d740f26e52c59bc"), daBatch.Hash())

block4 := readBlockFromJSON(t, "testdata/blockTrace_04.json")
chunk4 := &Chunk{Blocks: []*Block{block4}}
originalBatch = &Batch{Chunks: []*Chunk{chunk4}}
daBatch, err = codecv0.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xfbb081f25d6d06aefd76f062eee50885faf5bb050c8f31d533fc8560e655b690"), daBatch.Hash())

block5 := readBlockFromJSON(t, "testdata/blockTrace_05.json")
chunk5 := &Chunk{Blocks: []*Block{block5}}
originalBatch = &Batch{Chunks: []*Chunk{chunk5}}
daBatch, err = codecv0.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x99f9648e4d090f1222280bec95a3f1e39c6cbcd4bff21eb2ae94b1536bb23acc"), daBatch.Hash())

block6 := readBlockFromJSON(t, "testdata/blockTrace_06.json")
chunk6 := &Chunk{Blocks: []*Block{block6}}
originalBatch = &Batch{Chunks: []*Chunk{chunk6}}
daBatch, err = codecv0.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xe0950d500d47df4e9c443978682bcccfc8d50983f99ec9232067333a7d32a9d2"), daBatch.Hash())

block7 := readBlockFromJSON(t, "testdata/blockTrace_07.json")
chunk7 := &Chunk{Blocks: []*Block{block7}}
originalBatch = &Batch{Chunks: []*Chunk{chunk7}}
daBatch, err = codecv0.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x745a74773cdc7cd0b86b50305f6373c7efeaf051b38a71ea561333708e8a90d9"), daBatch.Hash())

originalBatch = &Batch{Chunks: []*Chunk{chunk2, chunk3, chunk4, chunk5}}
daBatch, err = codecv0.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x85b5c152c5c0b25731bfab6f4d309e94a42ddf0f4c9235189e5cd19c5c008522"), daBatch.Hash())

chunk8 := &Chunk{Blocks: []*Block{block2, block3, block4}}
chunk9 := &Chunk{Blocks: []*Block{block5}}
originalBatch = &Batch{Chunks: []*Chunk{chunk8, chunk9}}
daBatch, err = codecv0.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xc5e787fa6a83374135c3b95bd8325bcc0440cd5eb2d71bb31ddca67dd2d44f64"), daBatch.Hash())
}
68 changes: 68 additions & 0 deletions encoding/codecv1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/hex"
"testing"

"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -305,3 +306,70 @@ func TestCodecV1BatchEncode(t *testing.T) {
encoded = hex.EncodeToString(daBatch.Encode())
assert.Equal(t, "010000000000000000000000000000002a000000000000002a9b0f37c563d27d9717ab16d47075df996c54fe110130df6b11bfd7230e13476701b63f87bdd2caa8d43500d47ee59204f61af95339483c62ff436c6beabf47bf00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffbff", encoded)
}

func TestCodecV1BatchHash(t *testing.T) {
codecv1, err := CodecFromVersion(CodecV1)
assert.NoError(t, err)

// empty batch
batch := &daBatchV1{
daBatchV0: daBatchV0{
version: uint8(CodecV1),
},
}
assert.Equal(t, common.HexToHash("0x4b6fe410f63051f6e93532087b42ece79fb7b966e2ba5845e6cd1c091f27e564"), batch.Hash())

block2 := readBlockFromJSON(t, "testdata/blockTrace_02.json")
chunk2 := &Chunk{Blocks: []*Block{block2}}
originalBatch := &Batch{Chunks: []*Chunk{chunk2}}
daBatch, err := codecv1.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xd557b02638c0385d5124f7fc188a025b33f8819b7f78c000751404997148ab8b"), daBatch.Hash())

block3 := readBlockFromJSON(t, "testdata/blockTrace_03.json")
chunk3 := &Chunk{Blocks: []*Block{block3}}
originalBatch = &Batch{Chunks: []*Chunk{chunk3}}
daBatch, err = codecv1.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xf13c7e249d00941c59fe4cd970241bbd6753eede8e043c438165674031792b3b"), daBatch.Hash())

block4 := readBlockFromJSON(t, "testdata/blockTrace_04.json")
chunk4 := &Chunk{Blocks: []*Block{block4}}
originalBatch = &Batch{Chunks: []*Chunk{chunk4}}
daBatch, err = codecv1.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xb64208f07fab641f7ebf831686d05ad667da0c7bfabcbd9c878cc22cbc8032fd"), daBatch.Hash())

block5 := readBlockFromJSON(t, "testdata/blockTrace_05.json")
chunk5 := &Chunk{Blocks: []*Block{block5}}
originalBatch = &Batch{Chunks: []*Chunk{chunk5}}
daBatch, err = codecv1.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x4f7426d164e885574a661838406083f5292b0a1bc6dc20c51129eed0723b8a27"), daBatch.Hash())

block6 := readBlockFromJSON(t, "testdata/blockTrace_06.json")
chunk6 := &Chunk{Blocks: []*Block{block6}}
originalBatch = &Batch{Chunks: []*Chunk{chunk6}}
daBatch, err = codecv1.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xfce89ec2aed85cebeb20eea722e3ae4ec622bff49218dbe249a2d358e2e85451"), daBatch.Hash())

block7 := readBlockFromJSON(t, "testdata/blockTrace_07.json")
chunk7 := &Chunk{Blocks: []*Block{block7}}
originalBatch = &Batch{Chunks: []*Chunk{chunk7}}
daBatch, err = codecv1.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x8fc063179b709bab338674278bb7b70dce2879a4e11ea857b3a202fb3313559f"), daBatch.Hash())

originalBatch = &Batch{Chunks: []*Chunk{chunk2, chunk3, chunk4, chunk5}}
daBatch, err = codecv1.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xf1c94cdf45967bc60bfccd599edd8cb07fd0201f41ab068637834f86140f62bf"), daBatch.Hash())

chunk8 := &Chunk{Blocks: []*Block{block2, block3, block4}}
chunk9 := &Chunk{Blocks: []*Block{block5}}
originalBatch = &Batch{Chunks: []*Chunk{chunk8, chunk9}}
daBatch, err = codecv1.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xfef0b56bd889529e3a1d884c88dd1c867e084fdc1369496907be8f865f43f0e0"), daBatch.Hash())
}
68 changes: 68 additions & 0 deletions encoding/codecv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/hex"
"testing"

"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -305,3 +306,70 @@ func TestCodecV2BatchEncode(t *testing.T) {
encoded = hex.EncodeToString(daBatch.Encode())
assert.Equal(t, "020000000000000000000000000000002a000000000000002a9b0f37c563d27d9717ab16d47075df996c54fe110130df6b11bfd7230e1347670128f90d5edbcb10d13521824ccc7f47f85aff6e2da01004f9a402854eb3363200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffbff", encoded)
}

func TestCodecV2BatchHash(t *testing.T) {
codecv2, err := CodecFromVersion(CodecV2)
assert.NoError(t, err)

// empty batch
batch := &daBatchV1{
daBatchV0: daBatchV0{
version: uint8(CodecV2),
},
}
assert.Equal(t, common.HexToHash("0x8839b8a7b8dfebdc8e829f6fe543578ccdc8da1307e1e1581541a1e2a8fa5592"), batch.Hash())

block2 := readBlockFromJSON(t, "testdata/blockTrace_02.json")
chunk2 := &Chunk{Blocks: []*Block{block2}}
originalBatch := &Batch{Chunks: []*Chunk{chunk2}}
daBatch, err := codecv2.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x57553c35f981626b4d1a73c816aa8d8fad83c460fc049c5792581763f7e21b13"), daBatch.Hash())

block3 := readBlockFromJSON(t, "testdata/blockTrace_03.json")
chunk3 := &Chunk{Blocks: []*Block{block3}}
originalBatch = &Batch{Chunks: []*Chunk{chunk3}}
daBatch, err = codecv2.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x0f8e5b5205c5d809bf09047f37b558f4eb388c9c4eb23291cd97810d06654409"), daBatch.Hash())

block4 := readBlockFromJSON(t, "testdata/blockTrace_04.json")
chunk4 := &Chunk{Blocks: []*Block{block4}}
originalBatch = &Batch{Chunks: []*Chunk{chunk4}}
daBatch, err = codecv2.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xc59155dc0ae7d7d3fc29f0a9c6042f14dc58e3a1f9c0417f52bac2c4a8b33014"), daBatch.Hash())

block5 := readBlockFromJSON(t, "testdata/blockTrace_05.json")
chunk5 := &Chunk{Blocks: []*Block{block5}}
originalBatch = &Batch{Chunks: []*Chunk{chunk5}}
daBatch, err = codecv2.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x417509641fb0c0d1c07d80e64aab13934f828cb4f09608722bf8126a68c04617"), daBatch.Hash())

block6 := readBlockFromJSON(t, "testdata/blockTrace_06.json")
chunk6 := &Chunk{Blocks: []*Block{block6}}
originalBatch = &Batch{Chunks: []*Chunk{chunk6}}
daBatch, err = codecv2.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xe9c82b48e2a54c9206f57897cb870536bd22066d2af3d03aafe8a6a39add7635"), daBatch.Hash())

block7 := readBlockFromJSON(t, "testdata/blockTrace_07.json")
chunk7 := &Chunk{Blocks: []*Block{block7}}
originalBatch = &Batch{Chunks: []*Chunk{chunk7}}
daBatch, err = codecv2.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x5e3d20c5b3f56cc5a28e7431241b3ce3d484b12cfb0b3228f378b196beeb3a53"), daBatch.Hash())

originalBatch = &Batch{Chunks: []*Chunk{chunk2, chunk3, chunk4, chunk5}}
daBatch, err = codecv2.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x19b99491401625d92e16f7df6705219cc55e48e4b08db7bc4020e6934076f5f7"), daBatch.Hash())

chunk8 := &Chunk{Blocks: []*Block{block2, block3, block4}}
chunk9 := &Chunk{Blocks: []*Block{block5}}
originalBatch = &Batch{Chunks: []*Chunk{chunk8, chunk9}}
daBatch, err = codecv2.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xc5daf2ea5a3107c13b2994fb547336a7dca25cd352c051b6d9b9759d77e95fd2"), daBatch.Hash())
}
68 changes: 68 additions & 0 deletions encoding/codecv3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/hex"
"testing"

"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -304,3 +305,70 @@ func TestCodecV3BatchEncode(t *testing.T) {
encoded = hex.EncodeToString(daBatch.Encode())
assert.Equal(t, "030000000000000000000000000000002a000000000000002a9b0f37c563d27d9717ab16d47075df996c54fe110130df6b11bfd7230e1347670128f90d5edbcb10d13521824ccc7f47f85aff6e2da01004f9a402854eb33632000000000000000000000000000000000000000000000000000000000000000000000000646b6ed01bea70cbdd3d088c0db7d3dd5a11a2934ec4e7db761195d1e62f9f38a2fd5b325910eea5d881106c394f8d9a80bac8ecc43a86e0b920c5dc93f89caa43b205c2", encoded)
}

func TestCodecV3BatchHash(t *testing.T) {
codecv3, err := CodecFromVersion(CodecV3)
assert.NoError(t, err)

// empty batch
batch := &daBatchV3{
daBatchV0: daBatchV0{
version: uint8(CodecV3),
},
}
assert.Equal(t, common.HexToHash("0x9f059299e02cd1ccaed5bbcc821843000ae6b992b68b55ff59a51252478681b0"), batch.Hash())

block2 := readBlockFromJSON(t, "testdata/blockTrace_02.json")
chunk2 := &Chunk{Blocks: []*Block{block2}}
originalBatch := &Batch{Chunks: []*Chunk{chunk2}}
daBatch, err := codecv3.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xc5065afb8f29f620ae1edb4c6ebaf7380faf4226fb83ee920d70d489fe51c5c2"), daBatch.Hash())

block3 := readBlockFromJSON(t, "testdata/blockTrace_03.json")
chunk3 := &Chunk{Blocks: []*Block{block3}}
originalBatch = &Batch{Chunks: []*Chunk{chunk3}}
daBatch, err = codecv3.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x9ec8eabaa13229ec9c9d0687133afd7435afcfe260fc4c73fea052c0911522ac"), daBatch.Hash())

block4 := readBlockFromJSON(t, "testdata/blockTrace_04.json")
chunk4 := &Chunk{Blocks: []*Block{block4}}
originalBatch = &Batch{Chunks: []*Chunk{chunk4}}
daBatch, err = codecv3.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xda944b66dcaa6dc1442be2230233e97286ee1ed3c51cde155a36643b293b07c4"), daBatch.Hash())

block5 := readBlockFromJSON(t, "testdata/blockTrace_05.json")
chunk5 := &Chunk{Blocks: []*Block{block5}}
originalBatch = &Batch{Chunks: []*Chunk{chunk5}}
daBatch, err = codecv3.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x20e2324fac82e484c569eb286a221c61151c2b3c38a63b289f6ef6c30fb31e49"), daBatch.Hash())

block6 := readBlockFromJSON(t, "testdata/blockTrace_06.json")
chunk6 := &Chunk{Blocks: []*Block{block6}}
originalBatch = &Batch{Chunks: []*Chunk{chunk6}}
daBatch, err = codecv3.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xc962bce28a34a4eb9ec81393edcf2e6367e84aad9c4fc5641da6f18f54053ed5"), daBatch.Hash())

block7 := readBlockFromJSON(t, "testdata/blockTrace_07.json")
chunk7 := &Chunk{Blocks: []*Block{block7}}
originalBatch = &Batch{Chunks: []*Chunk{chunk7}}
daBatch, err = codecv3.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x405e0fc4b7efbe5b6d1dcc63c1f3253bbb6fbefedd1afe6b2067629f9da1f1cc"), daBatch.Hash())

originalBatch = &Batch{Chunks: []*Chunk{chunk2, chunk3, chunk4, chunk5}}
daBatch, err = codecv3.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x3d5d24c951cb55e56f3b4e2defcd8f32d6d048565e6723ac7cdff7ed5e580e3a"), daBatch.Hash())

chunk8 := &Chunk{Blocks: []*Block{block2, block3, block4}}
chunk9 := &Chunk{Blocks: []*Block{block5}}
originalBatch = &Batch{Chunks: []*Chunk{chunk8, chunk9}}
daBatch, err = codecv3.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xb25d9bd7d8442a56efd8e5ee814a99da7efdf3672bb85c48b975a9e248711bfb"), daBatch.Hash())
}
68 changes: 68 additions & 0 deletions encoding/codecv4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/hex"
"testing"

"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -305,3 +306,70 @@ func TestCodecV4BatchEncode(t *testing.T) {
encoded = hex.EncodeToString(daBatch.Encode())
assert.Equal(t, "040000000000000000000000000000002a000000000000002a9b0f37c563d27d9717ab16d47075df996c54fe110130df6b11bfd7230e1347670128f90d5edbcb10d13521824ccc7f47f85aff6e2da01004f9a402854eb33632000000000000000000000000000000000000000000000000000000000000000000000000646b6ed01bea70cbdd3d088c0db7d3dd5a11a2934ec4e7db761195d1e62f9f38a2fd5b325910eea5d881106c394f8d9a80bac8ecc43a86e0b920c5dc93f89caa43b205c2", encoded)
}

func TestCodecV4BatchHash(t *testing.T) {
codecv4, err := CodecFromVersion(CodecV4)
assert.NoError(t, err)

// empty batch
batch := &daBatchV3{
daBatchV0: daBatchV0{
version: uint8(CodecV4),
},
}
assert.Equal(t, common.HexToHash("0xdaf0827d02b32d41458aea0d5796dd0072d0a016f9834a2cb1a964d2c6ee135c"), batch.Hash())

block2 := readBlockFromJSON(t, "testdata/blockTrace_02.json")
chunk2 := &Chunk{Blocks: []*Block{block2}}
originalBatch := &Batch{Chunks: []*Chunk{chunk2}}
daBatch, err := codecv4.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x0684ec7f79e1950823f3aff20c6a3cde03357eb72027ee663347ac77d46f7565"), daBatch.Hash())

block3 := readBlockFromJSON(t, "testdata/blockTrace_03.json")
chunk3 := &Chunk{Blocks: []*Block{block3}}
originalBatch = &Batch{Chunks: []*Chunk{chunk3}}
daBatch, err = codecv4.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x094d6fb43f3bc4af387c8494f5b4d7ba82c9895a0122fbbe34f6a02cb512c564"), daBatch.Hash())

block4 := readBlockFromJSON(t, "testdata/blockTrace_04.json")
chunk4 := &Chunk{Blocks: []*Block{block4}}
originalBatch = &Batch{Chunks: []*Chunk{chunk4}}
daBatch, err = codecv4.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xda211c0402d1546fe4964c0e3d61621f6f020c851fd255a2c55419a4e091eae9"), daBatch.Hash())

block5 := readBlockFromJSON(t, "testdata/blockTrace_05.json")
chunk5 := &Chunk{Blocks: []*Block{block5}}
originalBatch = &Batch{Chunks: []*Chunk{chunk5}}
daBatch, err = codecv4.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x6bc8b8a6125c4f82afcbf8f190cefd002a61606fb751aca04b99f34a7459f678"), daBatch.Hash())

block6 := readBlockFromJSON(t, "testdata/blockTrace_06.json")
chunk6 := &Chunk{Blocks: []*Block{block6}}
originalBatch = &Batch{Chunks: []*Chunk{chunk6}}
daBatch, err = codecv4.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x985335548d6816cf955f39baa9e62ffec7068ac8591f7c7ea5a39d5b4929c29f"), daBatch.Hash())

block7 := readBlockFromJSON(t, "testdata/blockTrace_07.json")
chunk7 := &Chunk{Blocks: []*Block{block7}}
originalBatch = &Batch{Chunks: []*Chunk{chunk7}}
daBatch, err = codecv4.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0x4ae2e62edaf78d4c9278c170b3ea2b0fb81c95c8875f523dbe889fe5035791ab"), daBatch.Hash())

originalBatch = &Batch{Chunks: []*Chunk{chunk2, chunk3, chunk4, chunk5}}
daBatch, err = codecv4.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xc4120eefe42981b827f5c9a67b8f9b14007bf624694e5702f0f8a665b68832ad"), daBatch.Hash())

chunk8 := &Chunk{Blocks: []*Block{block2, block3, block4}}
chunk9 := &Chunk{Blocks: []*Block{block5}}
originalBatch = &Batch{Chunks: []*Chunk{chunk8, chunk9}}
daBatch, err = codecv4.NewDABatch(originalBatch)
assert.NoError(t, err)
assert.Equal(t, common.HexToHash("0xa152b2e1594032ce70be219cfa9781f0840120ac2bf3fcad24893d77c4b74077"), daBatch.Hash())
}

0 comments on commit 22c3772

Please sign in to comment.