|
@@ -135,6 +135,12 @@ func setSequence(seq int64, files fileList) int64 {
|
|
|
return seq
|
|
return seq
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func setBlocksHash(files fileList) {
|
|
|
|
|
+ for i, f := range files {
|
|
|
|
|
+ files[i].BlocksHash = protocol.BlocksHash(f.Blocks)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func TestGlobalSet(t *testing.T) {
|
|
func TestGlobalSet(t *testing.T) {
|
|
|
ldb := db.NewLowlevel(backend.OpenMemory())
|
|
ldb := db.NewLowlevel(backend.OpenMemory())
|
|
|
defer ldb.Close()
|
|
defer ldb.Close()
|
|
@@ -149,6 +155,7 @@ func TestGlobalSet(t *testing.T) {
|
|
|
protocol.FileInfo{Name: "z", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}, Blocks: genBlocks(8)},
|
|
protocol.FileInfo{Name: "z", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}, Blocks: genBlocks(8)},
|
|
|
}
|
|
}
|
|
|
localSeq := setSequence(0, local0)
|
|
localSeq := setSequence(0, local0)
|
|
|
|
|
+ setBlocksHash(local0)
|
|
|
local1 := fileList{
|
|
local1 := fileList{
|
|
|
protocol.FileInfo{Name: "a", Sequence: 6, Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}, Blocks: genBlocks(1)},
|
|
protocol.FileInfo{Name: "a", Sequence: 6, Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}, Blocks: genBlocks(1)},
|
|
|
protocol.FileInfo{Name: "b", Sequence: 7, Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}, Blocks: genBlocks(2)},
|
|
protocol.FileInfo{Name: "b", Sequence: 7, Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}, Blocks: genBlocks(2)},
|
|
@@ -157,6 +164,7 @@ func TestGlobalSet(t *testing.T) {
|
|
|
protocol.FileInfo{Name: "z", Sequence: 10, Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1001}}}, Deleted: true},
|
|
protocol.FileInfo{Name: "z", Sequence: 10, Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1001}}}, Deleted: true},
|
|
|
}
|
|
}
|
|
|
setSequence(localSeq, local1)
|
|
setSequence(localSeq, local1)
|
|
|
|
|
+ setBlocksHash(local1)
|
|
|
localTot := fileList{
|
|
localTot := fileList{
|
|
|
local1[0],
|
|
local1[0],
|
|
|
local1[1],
|
|
local1[1],
|
|
@@ -171,11 +179,13 @@ func TestGlobalSet(t *testing.T) {
|
|
|
protocol.FileInfo{Name: "c", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1001}}}, Blocks: genBlocks(5)},
|
|
protocol.FileInfo{Name: "c", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1001}}}, Blocks: genBlocks(5)},
|
|
|
}
|
|
}
|
|
|
remoteSeq := setSequence(0, remote0)
|
|
remoteSeq := setSequence(0, remote0)
|
|
|
|
|
+ setBlocksHash(remote0)
|
|
|
remote1 := fileList{
|
|
remote1 := fileList{
|
|
|
protocol.FileInfo{Name: "b", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1001}}}, Blocks: genBlocks(6)},
|
|
protocol.FileInfo{Name: "b", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1001}}}, Blocks: genBlocks(6)},
|
|
|
protocol.FileInfo{Name: "e", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}, Blocks: genBlocks(7)},
|
|
protocol.FileInfo{Name: "e", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}, Blocks: genBlocks(7)},
|
|
|
}
|
|
}
|
|
|
setSequence(remoteSeq, remote1)
|
|
setSequence(remoteSeq, remote1)
|
|
|
|
|
+ setBlocksHash(remote1)
|
|
|
remoteTot := fileList{
|
|
remoteTot := fileList{
|
|
|
remote0[0],
|
|
remote0[0],
|
|
|
remote1[0],
|
|
remote1[0],
|