(data map[common.Address]map[uint64]*BlobPayloadWithRowData,
excludedList map[uint64]struct{}, t *testing.T)
| 259 | } |
| 260 | |
| 261 | func verifyKVs(data map[common.Address]map[uint64]*BlobPayloadWithRowData, |
| 262 | excludedList map[uint64]struct{}, t *testing.T) { |
| 263 | emptyCommit := common.Hash{} |
| 264 | emptyCommit[ethstorage.HashSizeInContract] = emptyCommit[ethstorage.HashSizeInContract] | blobEmptyFillingMask |
| 265 | for contract, shardData := range data { |
| 266 | shardManager := ethstorage.ContractToShardManager[contract] |
| 267 | if shardManager == nil { |
| 268 | t.Fatalf("sstorage manager for contract %s do not exist.", contract.Hex()) |
| 269 | } |
| 270 | for idx, blobPayload := range shardData { |
| 271 | rowData := blobPayload.RowData |
| 272 | encodedBlob := blobPayload.EncodedBlob |
| 273 | commit := blobPayload.BlobCommit |
| 274 | // for data in the excluded list, that mean it should not sync to the local node, but written by empty blob, |
| 275 | // so the expected data is make([]byte, kvSize) |
| 276 | if _, ok := excludedList[idx]; ok { |
| 277 | rowData = make([]byte, len(blobPayload.RowData)) |
| 278 | commit = emptyCommit |
| 279 | encodedBlob, _, _ = shardManager.EncodeKV(idx, rowData, commit, blobPayload.MinerAddress, blobPayload.EncodeType) |
| 280 | } |
| 281 | decodedData, ok, err := shardManager.TryRead(idx, len(blobPayload.RowData), commit) |
| 282 | if err != nil { |
| 283 | t.Fatalf("TryRead sstorage Data fail. err: %s", err.Error()) |
| 284 | } |
| 285 | if !ok { |
| 286 | t.Fatalf("TryRead sstroage Data fail. err: %s, index %d", "shard Idx not support", idx) |
| 287 | } |
| 288 | |
| 289 | encodedData, _, err := shardManager.TryReadEncoded(idx, len(blobPayload.EncodedBlob)) |
| 290 | if err != nil { |
| 291 | t.Fatalf("TryRead encoded Data fail. err: %s", err.Error()) |
| 292 | } |
| 293 | |
| 294 | if !bytes.Equal(rowData, decodedData) { |
| 295 | t.Fatalf("verify KV failed; index: %d; rowData: %s; decodedData: %s", idx, |
| 296 | common.Bytes2Hex(rowData), common.Bytes2Hex(decodedData)) |
| 297 | } |
| 298 | if !bytes.Equal(encodedBlob, encodedData) { |
| 299 | t.Fatalf("verify KV failed; index: %d; blobPayload: %s; encodedData: %s", idx, |
| 300 | common.Bytes2Hex(rowData), common.Bytes2Hex(encodedData)) |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | func generateMetadata(hash common.Hash) common.Hash { |
| 307 | meta := make([]byte, 32) |
no test coverage detected