TestAddPeerDuringSyncing test sync process with local node support a shard and sync data from first remote peer which has excluded list. After first peer sync finish (blob indexes in excluded list included in heal task), the second peer connect and sync the rest of the blobs. The local node should s
(t *testing.T)
| 996 | // which has excluded list. After first peer sync finish (blob indexes in excluded list included in heal task), |
| 997 | // the second peer connect and sync the rest of the blobs. The local node should sync done. |
| 998 | func TestAddPeerDuringSyncing(t *testing.T) { |
| 999 | var ( |
| 1000 | kvSize = defaultChunkSize |
| 1001 | kvEntries = uint64(16) |
| 1002 | lastKvIndex = uint64(16) |
| 1003 | encodeType = uint64(defaultEncodeType) |
| 1004 | db = rawdb.NewMemoryDatabase() |
| 1005 | ctx, cancel = context.WithCancel(context.Background()) |
| 1006 | mux = new(event.Feed) |
| 1007 | shards = []uint64{0} |
| 1008 | shardMap = make(map[common.Address][]uint64) |
| 1009 | excludedList = getRandomU64InRange(make(map[uint64]struct{}), 0, 15, 3) |
| 1010 | m = metrics.NewMetrics("sync_test") |
| 1011 | chainID = new(big.Int).SetUint64(3333) |
| 1012 | ) |
| 1013 | |
| 1014 | metafile, err := CreateMetaFile(metafileName, int64(kvEntries)) |
| 1015 | if err != nil { |
| 1016 | t.Error("Create metafileName fail", err.Error()) |
| 1017 | } |
| 1018 | defer metafile.Close() |
| 1019 | |
| 1020 | shardMap[contract] = shards |
| 1021 | shardManager, files := createEthStorage(contract, shards, defaultChunkSize, kvSize, kvEntries, common.Address{}, defaultEncodeType) |
| 1022 | if shardManager == nil { |
| 1023 | t.Fatalf("createEthStorage failed") |
| 1024 | } |
| 1025 | |
| 1026 | defer func(files []string) { |
| 1027 | for _, file := range files { |
| 1028 | os.Remove(file) |
| 1029 | } |
| 1030 | }(files) |
| 1031 | |
| 1032 | l1 := NewMockL1Source(lastKvIndex, metafileName) |
| 1033 | data := makeKVStorage(contract, shards, defaultChunkSize, kvSize, kvEntries, lastKvIndex, common.Address{}, encodeType, metafile) |
| 1034 | sm := ethstorage.NewStorageManager(shardManager, l1, lg) |
| 1035 | sm.Reset(0) |
| 1036 | // fill empty to excludedList for verify KVs |
| 1037 | fillEmpty(shardManager, excludedList) |
| 1038 | |
| 1039 | localHost, syncCl := createLocalHostAndSyncClient(t, chainID, db, sm, m, mux) |
| 1040 | syncCl.Start() |
| 1041 | |
| 1042 | pData := copyShardData(data[contract], shards, kvEntries, excludedList) |
| 1043 | smr0 := &mockStorageManagerReader{ |
| 1044 | kvEntries: kvEntries, |
| 1045 | maxKvSize: kvSize, |
| 1046 | encodeType: encodeType, |
| 1047 | shards: shards, |
| 1048 | contractAddress: contract, |
| 1049 | shardMiner: common.Address{}, |
| 1050 | blobPayloads: pData, |
| 1051 | } |
| 1052 | remoteHost0 := createRemoteHost(t, ctx, chainID, smr0, db, m) |
| 1053 | connect(t, localHost, remoteHost0, shardMap, shardMap) |
| 1054 | time.Sleep(3 * time.Second) |
| 1055 |
nothing calls this directly
no test coverage detected