|
|
@ -20,9 +20,9 @@ type scTestParams struct { |
|
|
|
initHeight int64 |
|
|
|
height int64 |
|
|
|
allB []int64 |
|
|
|
pending map[int64]p2p.ID |
|
|
|
pending map[int64]p2p.NodeID |
|
|
|
pendingTime map[int64]time.Time |
|
|
|
received map[int64]p2p.ID |
|
|
|
received map[int64]p2p.NodeID |
|
|
|
peerTimeout time.Duration |
|
|
|
minRecvRate int64 |
|
|
|
targetPending int |
|
|
@ -41,7 +41,7 @@ func verifyScheduler(sc *scheduler) { |
|
|
|
} |
|
|
|
|
|
|
|
func newTestScheduler(params scTestParams) *scheduler { |
|
|
|
peers := make(map[p2p.ID]*scPeer) |
|
|
|
peers := make(map[p2p.NodeID]*scPeer) |
|
|
|
var maxHeight int64 |
|
|
|
|
|
|
|
initHeight := params.initHeight |
|
|
@ -54,8 +54,8 @@ func newTestScheduler(params scTestParams) *scheduler { |
|
|
|
} |
|
|
|
|
|
|
|
for id, peer := range params.peers { |
|
|
|
peer.peerID = p2p.ID(id) |
|
|
|
peers[p2p.ID(id)] = peer |
|
|
|
peer.peerID = p2p.NodeID(id) |
|
|
|
peers[p2p.NodeID(id)] = peer |
|
|
|
if maxHeight < peer.height { |
|
|
|
maxHeight = peer.height |
|
|
|
} |
|
|
@ -122,7 +122,7 @@ func TestScMaxHeights(t *testing.T) { |
|
|
|
name: "one ready peer", |
|
|
|
sc: scheduler{ |
|
|
|
height: 3, |
|
|
|
peers: map[p2p.ID]*scPeer{"P1": {height: 6, state: peerStateReady}}, |
|
|
|
peers: map[p2p.NodeID]*scPeer{"P1": {height: 6, state: peerStateReady}}, |
|
|
|
}, |
|
|
|
wantMax: 6, |
|
|
|
}, |
|
|
@ -130,7 +130,7 @@ func TestScMaxHeights(t *testing.T) { |
|
|
|
name: "ready and removed peers", |
|
|
|
sc: scheduler{ |
|
|
|
height: 1, |
|
|
|
peers: map[p2p.ID]*scPeer{ |
|
|
|
peers: map[p2p.NodeID]*scPeer{ |
|
|
|
"P1": {height: 4, state: peerStateReady}, |
|
|
|
"P2": {height: 10, state: peerStateRemoved}}, |
|
|
|
}, |
|
|
@ -140,7 +140,7 @@ func TestScMaxHeights(t *testing.T) { |
|
|
|
name: "removed peers", |
|
|
|
sc: scheduler{ |
|
|
|
height: 1, |
|
|
|
peers: map[p2p.ID]*scPeer{ |
|
|
|
peers: map[p2p.NodeID]*scPeer{ |
|
|
|
"P1": {height: 4, state: peerStateRemoved}, |
|
|
|
"P2": {height: 10, state: peerStateRemoved}}, |
|
|
|
}, |
|
|
@ -150,7 +150,7 @@ func TestScMaxHeights(t *testing.T) { |
|
|
|
name: "new peers", |
|
|
|
sc: scheduler{ |
|
|
|
height: 1, |
|
|
|
peers: map[p2p.ID]*scPeer{ |
|
|
|
peers: map[p2p.NodeID]*scPeer{ |
|
|
|
"P1": {base: -1, height: -1, state: peerStateNew}, |
|
|
|
"P2": {base: -1, height: -1, state: peerStateNew}}, |
|
|
|
}, |
|
|
@ -160,7 +160,7 @@ func TestScMaxHeights(t *testing.T) { |
|
|
|
name: "mixed peers", |
|
|
|
sc: scheduler{ |
|
|
|
height: 1, |
|
|
|
peers: map[p2p.ID]*scPeer{ |
|
|
|
peers: map[p2p.NodeID]*scPeer{ |
|
|
|
"P1": {height: -1, state: peerStateNew}, |
|
|
|
"P2": {height: 10, state: peerStateReady}, |
|
|
|
"P3": {height: 20, state: peerStateRemoved}, |
|
|
@ -187,7 +187,7 @@ func TestScMaxHeights(t *testing.T) { |
|
|
|
func TestScEnsurePeer(t *testing.T) { |
|
|
|
|
|
|
|
type args struct { |
|
|
|
peerID p2p.ID |
|
|
|
peerID p2p.NodeID |
|
|
|
} |
|
|
|
tests := []struct { |
|
|
|
name string |
|
|
@ -244,7 +244,7 @@ func TestScTouchPeer(t *testing.T) { |
|
|
|
now := time.Now() |
|
|
|
|
|
|
|
type args struct { |
|
|
|
peerID p2p.ID |
|
|
|
peerID p2p.NodeID |
|
|
|
time time.Time |
|
|
|
} |
|
|
|
|
|
|
@ -316,13 +316,13 @@ func TestScPrunablePeers(t *testing.T) { |
|
|
|
name string |
|
|
|
fields scTestParams |
|
|
|
args args |
|
|
|
wantResult []p2p.ID |
|
|
|
wantResult []p2p.NodeID |
|
|
|
}{ |
|
|
|
{ |
|
|
|
name: "no peers", |
|
|
|
fields: scTestParams{peers: map[string]*scPeer{}}, |
|
|
|
args: args{threshold: time.Second, time: now.Add(time.Second + time.Millisecond), minSpeed: 100}, |
|
|
|
wantResult: []p2p.ID{}, |
|
|
|
wantResult: []p2p.NodeID{}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: "mixed peers", |
|
|
@ -341,7 +341,7 @@ func TestScPrunablePeers(t *testing.T) { |
|
|
|
"P6": {state: peerStateReady, lastTouched: now.Add(time.Second), lastRate: 90}, |
|
|
|
}}, |
|
|
|
args: args{threshold: time.Second, time: now.Add(time.Second + time.Millisecond), minSpeed: 100}, |
|
|
|
wantResult: []p2p.ID{"P4", "P5", "P6"}, |
|
|
|
wantResult: []p2p.NodeID{"P4", "P5", "P6"}, |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
@ -361,7 +361,7 @@ func TestScPrunablePeers(t *testing.T) { |
|
|
|
func TestScRemovePeer(t *testing.T) { |
|
|
|
|
|
|
|
type args struct { |
|
|
|
peerID p2p.ID |
|
|
|
peerID p2p.NodeID |
|
|
|
} |
|
|
|
tests := []struct { |
|
|
|
name string |
|
|
@ -424,13 +424,13 @@ func TestScRemovePeer(t *testing.T) { |
|
|
|
fields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 3, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3}, |
|
|
|
pending: map[int64]p2p.ID{1: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{1: "P1"}, |
|
|
|
}, |
|
|
|
args: args{peerID: "P1"}, |
|
|
|
wantFields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 3, state: peerStateRemoved}}, |
|
|
|
allB: []int64{}, |
|
|
|
pending: map[int64]p2p.ID{}, |
|
|
|
pending: map[int64]p2p.NodeID{}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
@ -438,13 +438,13 @@ func TestScRemovePeer(t *testing.T) { |
|
|
|
fields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 3, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3}, |
|
|
|
received: map[int64]p2p.ID{1: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{1: "P1"}, |
|
|
|
}, |
|
|
|
args: args{peerID: "P1"}, |
|
|
|
wantFields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 3, state: peerStateRemoved}}, |
|
|
|
allB: []int64{}, |
|
|
|
received: map[int64]p2p.ID{}, |
|
|
|
received: map[int64]p2p.NodeID{}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
@ -452,15 +452,15 @@ func TestScRemovePeer(t *testing.T) { |
|
|
|
fields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 4, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
pending: map[int64]p2p.ID{1: "P1", 3: "P1"}, |
|
|
|
received: map[int64]p2p.ID{2: "P1", 4: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{1: "P1", 3: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{2: "P1", 4: "P1"}, |
|
|
|
}, |
|
|
|
args: args{peerID: "P1"}, |
|
|
|
wantFields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 4, state: peerStateRemoved}}, |
|
|
|
allB: []int64{}, |
|
|
|
pending: map[int64]p2p.ID{}, |
|
|
|
received: map[int64]p2p.ID{}, |
|
|
|
pending: map[int64]p2p.NodeID{}, |
|
|
|
received: map[int64]p2p.NodeID{}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
@ -471,8 +471,8 @@ func TestScRemovePeer(t *testing.T) { |
|
|
|
"P2": {height: 6, state: peerStateReady}, |
|
|
|
}, |
|
|
|
allB: []int64{1, 2, 3, 4, 5, 6}, |
|
|
|
pending: map[int64]p2p.ID{1: "P1", 3: "P2", 6: "P1"}, |
|
|
|
received: map[int64]p2p.ID{2: "P1", 4: "P2", 5: "P2"}, |
|
|
|
pending: map[int64]p2p.NodeID{1: "P1", 3: "P2", 6: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{2: "P1", 4: "P2", 5: "P2"}, |
|
|
|
}, |
|
|
|
args: args{peerID: "P1"}, |
|
|
|
wantFields: scTestParams{ |
|
|
@ -481,8 +481,8 @@ func TestScRemovePeer(t *testing.T) { |
|
|
|
"P2": {height: 6, state: peerStateReady}, |
|
|
|
}, |
|
|
|
allB: []int64{1, 2, 3, 4, 5, 6}, |
|
|
|
pending: map[int64]p2p.ID{3: "P2"}, |
|
|
|
received: map[int64]p2p.ID{4: "P2", 5: "P2"}, |
|
|
|
pending: map[int64]p2p.NodeID{3: "P2"}, |
|
|
|
received: map[int64]p2p.NodeID{4: "P2", 5: "P2"}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
@ -501,7 +501,7 @@ func TestScRemovePeer(t *testing.T) { |
|
|
|
func TestScSetPeerRange(t *testing.T) { |
|
|
|
|
|
|
|
type args struct { |
|
|
|
peerID p2p.ID |
|
|
|
peerID p2p.NodeID |
|
|
|
base int64 |
|
|
|
height int64 |
|
|
|
} |
|
|
@ -622,25 +622,25 @@ func TestScGetPeersWithHeight(t *testing.T) { |
|
|
|
name string |
|
|
|
fields scTestParams |
|
|
|
args args |
|
|
|
wantResult []p2p.ID |
|
|
|
wantResult []p2p.NodeID |
|
|
|
}{ |
|
|
|
{ |
|
|
|
name: "no peers", |
|
|
|
fields: scTestParams{peers: map[string]*scPeer{}}, |
|
|
|
args: args{height: 10}, |
|
|
|
wantResult: []p2p.ID{}, |
|
|
|
wantResult: []p2p.NodeID{}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: "only new peers", |
|
|
|
fields: scTestParams{peers: map[string]*scPeer{"P1": {height: -1, state: peerStateNew}}}, |
|
|
|
args: args{height: 10}, |
|
|
|
wantResult: []p2p.ID{}, |
|
|
|
wantResult: []p2p.NodeID{}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: "only Removed peers", |
|
|
|
fields: scTestParams{peers: map[string]*scPeer{"P1": {height: 4, state: peerStateRemoved}}}, |
|
|
|
args: args{height: 2}, |
|
|
|
wantResult: []p2p.ID{}, |
|
|
|
wantResult: []p2p.NodeID{}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: "one Ready shorter peer", |
|
|
@ -649,7 +649,7 @@ func TestScGetPeersWithHeight(t *testing.T) { |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
}, |
|
|
|
args: args{height: 5}, |
|
|
|
wantResult: []p2p.ID{}, |
|
|
|
wantResult: []p2p.NodeID{}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: "one Ready equal peer", |
|
|
@ -658,7 +658,7 @@ func TestScGetPeersWithHeight(t *testing.T) { |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
}, |
|
|
|
args: args{height: 4}, |
|
|
|
wantResult: []p2p.ID{"P1"}, |
|
|
|
wantResult: []p2p.NodeID{"P1"}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: "one Ready higher peer", |
|
|
@ -668,7 +668,7 @@ func TestScGetPeersWithHeight(t *testing.T) { |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
}, |
|
|
|
args: args{height: 4}, |
|
|
|
wantResult: []p2p.ID{"P1"}, |
|
|
|
wantResult: []p2p.NodeID{"P1"}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: "one Ready higher peer at base", |
|
|
@ -678,7 +678,7 @@ func TestScGetPeersWithHeight(t *testing.T) { |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
}, |
|
|
|
args: args{height: 4}, |
|
|
|
wantResult: []p2p.ID{"P1"}, |
|
|
|
wantResult: []p2p.NodeID{"P1"}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: "one Ready higher peer with higher base", |
|
|
@ -688,7 +688,7 @@ func TestScGetPeersWithHeight(t *testing.T) { |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
}, |
|
|
|
args: args{height: 4}, |
|
|
|
wantResult: []p2p.ID{}, |
|
|
|
wantResult: []p2p.NodeID{}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: "multiple mixed peers", |
|
|
@ -703,7 +703,7 @@ func TestScGetPeersWithHeight(t *testing.T) { |
|
|
|
allB: []int64{8, 9, 10, 11}, |
|
|
|
}, |
|
|
|
args: args{height: 8}, |
|
|
|
wantResult: []p2p.ID{"P2", "P5"}, |
|
|
|
wantResult: []p2p.NodeID{"P2", "P5"}, |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
@ -725,7 +725,7 @@ func TestScMarkPending(t *testing.T) { |
|
|
|
now := time.Now() |
|
|
|
|
|
|
|
type args struct { |
|
|
|
peerID p2p.ID |
|
|
|
peerID p2p.NodeID |
|
|
|
height int64 |
|
|
|
tm time.Time |
|
|
|
} |
|
|
@ -821,14 +821,14 @@ func TestScMarkPending(t *testing.T) { |
|
|
|
fields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 2, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2}, |
|
|
|
pending: map[int64]p2p.ID{1: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{1: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{1: now}, |
|
|
|
}, |
|
|
|
args: args{peerID: "P1", height: 2, tm: now.Add(time.Millisecond)}, |
|
|
|
wantFields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 2, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2}, |
|
|
|
pending: map[int64]p2p.ID{1: "P1", 2: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{1: "P1", 2: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{1: now, 2: now.Add(time.Millisecond)}, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -851,7 +851,7 @@ func TestScMarkReceived(t *testing.T) { |
|
|
|
now := time.Now() |
|
|
|
|
|
|
|
type args struct { |
|
|
|
peerID p2p.ID |
|
|
|
peerID p2p.NodeID |
|
|
|
height int64 |
|
|
|
size int64 |
|
|
|
tm time.Time |
|
|
@ -891,7 +891,7 @@ func TestScMarkReceived(t *testing.T) { |
|
|
|
"P2": {height: 4, state: peerStateReady}, |
|
|
|
}, |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
pending: map[int64]p2p.ID{1: "P1", 2: "P2", 3: "P2", 4: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{1: "P1", 2: "P2", 3: "P2", 4: "P1"}, |
|
|
|
}, |
|
|
|
args: args{peerID: "P1", height: 2, size: 1000, tm: now}, |
|
|
|
wantFields: scTestParams{ |
|
|
@ -900,7 +900,7 @@ func TestScMarkReceived(t *testing.T) { |
|
|
|
"P2": {height: 4, state: peerStateReady}, |
|
|
|
}, |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
pending: map[int64]p2p.ID{1: "P1", 2: "P2", 3: "P2", 4: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{1: "P1", 2: "P2", 3: "P2", 4: "P1"}, |
|
|
|
}, |
|
|
|
wantErr: true, |
|
|
|
}, |
|
|
@ -909,13 +909,13 @@ func TestScMarkReceived(t *testing.T) { |
|
|
|
fields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 4, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
pending: map[int64]p2p.ID{}, |
|
|
|
pending: map[int64]p2p.NodeID{}, |
|
|
|
}, |
|
|
|
args: args{peerID: "P1", height: 2, size: 1000, tm: now}, |
|
|
|
wantFields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 4, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
pending: map[int64]p2p.ID{}, |
|
|
|
pending: map[int64]p2p.NodeID{}, |
|
|
|
}, |
|
|
|
wantErr: true, |
|
|
|
}, |
|
|
@ -924,14 +924,14 @@ func TestScMarkReceived(t *testing.T) { |
|
|
|
fields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 2, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2}, |
|
|
|
pending: map[int64]p2p.ID{1: "P1", 2: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{1: "P1", 2: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{1: now, 2: now.Add(time.Second)}, |
|
|
|
}, |
|
|
|
args: args{peerID: "P1", height: 2, size: 1000, tm: now}, |
|
|
|
wantFields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 2, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2}, |
|
|
|
pending: map[int64]p2p.ID{1: "P1", 2: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{1: "P1", 2: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{1: now, 2: now.Add(time.Second)}, |
|
|
|
}, |
|
|
|
wantErr: true, |
|
|
@ -941,16 +941,16 @@ func TestScMarkReceived(t *testing.T) { |
|
|
|
fields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 2, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2}, |
|
|
|
pending: map[int64]p2p.ID{1: "P1", 2: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{1: "P1", 2: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{1: now, 2: now}, |
|
|
|
}, |
|
|
|
args: args{peerID: "P1", height: 2, size: 1000, tm: now.Add(time.Millisecond)}, |
|
|
|
wantFields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 2, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2}, |
|
|
|
pending: map[int64]p2p.ID{1: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{1: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{1: now}, |
|
|
|
received: map[int64]p2p.ID{2: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{2: "P1"}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
@ -991,7 +991,7 @@ func TestScMarkProcessed(t *testing.T) { |
|
|
|
height: 2, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 4, state: peerStateReady}}, |
|
|
|
allB: []int64{2}, |
|
|
|
pending: map[int64]p2p.ID{2: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{2: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{2: now}, |
|
|
|
targetPending: 1, |
|
|
|
}, |
|
|
@ -1009,15 +1009,15 @@ func TestScMarkProcessed(t *testing.T) { |
|
|
|
height: 1, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 2, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2}, |
|
|
|
pending: map[int64]p2p.ID{2: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{2: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{2: now}, |
|
|
|
received: map[int64]p2p.ID{1: "P1"}}, |
|
|
|
received: map[int64]p2p.NodeID{1: "P1"}}, |
|
|
|
args: args{height: 1}, |
|
|
|
wantFields: scTestParams{ |
|
|
|
height: 2, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 2, state: peerStateReady}}, |
|
|
|
allB: []int64{2}, |
|
|
|
pending: map[int64]p2p.ID{2: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{2: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{2: now}}, |
|
|
|
}, |
|
|
|
} |
|
|
@ -1101,7 +1101,7 @@ func TestScAllBlocksProcessed(t *testing.T) { |
|
|
|
fields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 4, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
pending: map[int64]p2p.ID{1: "P1", 2: "P1", 3: "P1", 4: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{1: "P1", 2: "P1", 3: "P1", 4: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{1: now, 2: now, 3: now, 4: now}, |
|
|
|
}, |
|
|
|
wantResult: false, |
|
|
@ -1111,7 +1111,7 @@ func TestScAllBlocksProcessed(t *testing.T) { |
|
|
|
fields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 4, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
received: map[int64]p2p.ID{1: "P1", 2: "P1", 3: "P1", 4: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{1: "P1", 2: "P1", 3: "P1", 4: "P1"}, |
|
|
|
}, |
|
|
|
wantResult: false, |
|
|
|
}, |
|
|
@ -1122,7 +1122,7 @@ func TestScAllBlocksProcessed(t *testing.T) { |
|
|
|
peers: map[string]*scPeer{ |
|
|
|
"P1": {height: 4, state: peerStateReady}}, |
|
|
|
allB: []int64{4}, |
|
|
|
received: map[int64]p2p.ID{4: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{4: "P1"}, |
|
|
|
}, |
|
|
|
wantResult: true, |
|
|
|
}, |
|
|
@ -1131,7 +1131,7 @@ func TestScAllBlocksProcessed(t *testing.T) { |
|
|
|
fields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 4, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
pending: map[int64]p2p.ID{2: "P1", 4: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{2: "P1", 4: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{2: now, 4: now}, |
|
|
|
}, |
|
|
|
wantResult: false, |
|
|
@ -1179,7 +1179,7 @@ func TestScNextHeightToSchedule(t *testing.T) { |
|
|
|
initHeight: 1, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 4, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
pending: map[int64]p2p.ID{1: "P1", 2: "P1", 3: "P1", 4: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{1: "P1", 2: "P1", 3: "P1", 4: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{1: now, 2: now, 3: now, 4: now}, |
|
|
|
}, |
|
|
|
wantHeight: -1, |
|
|
@ -1190,7 +1190,7 @@ func TestScNextHeightToSchedule(t *testing.T) { |
|
|
|
initHeight: 1, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 4, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
received: map[int64]p2p.ID{1: "P1", 2: "P1", 3: "P1", 4: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{1: "P1", 2: "P1", 3: "P1", 4: "P1"}, |
|
|
|
}, |
|
|
|
wantHeight: -1, |
|
|
|
}, |
|
|
@ -1209,7 +1209,7 @@ func TestScNextHeightToSchedule(t *testing.T) { |
|
|
|
initHeight: 1, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 4, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
pending: map[int64]p2p.ID{2: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{2: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{2: now}, |
|
|
|
}, |
|
|
|
wantHeight: 1, |
|
|
@ -1239,7 +1239,7 @@ func TestScSelectPeer(t *testing.T) { |
|
|
|
name string |
|
|
|
fields scTestParams |
|
|
|
args args |
|
|
|
wantResult p2p.ID |
|
|
|
wantResult p2p.NodeID |
|
|
|
wantError bool |
|
|
|
}{ |
|
|
|
{ |
|
|
@ -1307,7 +1307,7 @@ func TestScSelectPeer(t *testing.T) { |
|
|
|
"P1": {height: 8, state: peerStateReady}, |
|
|
|
"P2": {height: 9, state: peerStateReady}}, |
|
|
|
allB: []int64{4, 5, 6, 7, 8, 9}, |
|
|
|
pending: map[int64]p2p.ID{ |
|
|
|
pending: map[int64]p2p.NodeID{ |
|
|
|
4: "P1", 6: "P1", |
|
|
|
5: "P2", |
|
|
|
}, |
|
|
@ -1323,7 +1323,7 @@ func TestScSelectPeer(t *testing.T) { |
|
|
|
"P1": {height: 15, state: peerStateReady}, |
|
|
|
"P3": {height: 15, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, |
|
|
|
pending: map[int64]p2p.ID{ |
|
|
|
pending: map[int64]p2p.NodeID{ |
|
|
|
1: "P1", 2: "P1", |
|
|
|
3: "P3", 4: "P3", |
|
|
|
5: "P2", 6: "P2", |
|
|
@ -1392,7 +1392,7 @@ func TestScHandleBlockResponse(t *testing.T) { |
|
|
|
now := time.Now() |
|
|
|
block6FromP1 := bcBlockResponse{ |
|
|
|
time: now.Add(time.Millisecond), |
|
|
|
peerID: p2p.ID("P1"), |
|
|
|
peerID: p2p.NodeID("P1"), |
|
|
|
size: 100, |
|
|
|
block: makeScBlock(6), |
|
|
|
} |
|
|
@ -1433,7 +1433,7 @@ func TestScHandleBlockResponse(t *testing.T) { |
|
|
|
fields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P2": {height: 8, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4, 5, 6, 7, 8}, |
|
|
|
pending: map[int64]p2p.ID{6: "P2"}, |
|
|
|
pending: map[int64]p2p.NodeID{6: "P2"}, |
|
|
|
pendingTime: map[int64]time.Time{6: now}, |
|
|
|
}, |
|
|
|
args: args{event: block6FromP1}, |
|
|
@ -1444,7 +1444,7 @@ func TestScHandleBlockResponse(t *testing.T) { |
|
|
|
fields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 8, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4, 5, 6, 7, 8}, |
|
|
|
pending: map[int64]p2p.ID{6: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{6: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{6: now.Add(time.Second)}, |
|
|
|
}, |
|
|
|
args: args{event: block6FromP1}, |
|
|
@ -1455,7 +1455,7 @@ func TestScHandleBlockResponse(t *testing.T) { |
|
|
|
fields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 8, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4, 5, 6, 7, 8}, |
|
|
|
pending: map[int64]p2p.ID{6: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{6: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{6: now}, |
|
|
|
}, |
|
|
|
args: args{event: block6FromP1}, |
|
|
@ -1477,7 +1477,7 @@ func TestScHandleNoBlockResponse(t *testing.T) { |
|
|
|
now := time.Now() |
|
|
|
noBlock6FromP1 := bcNoBlockResponse{ |
|
|
|
time: now.Add(time.Millisecond), |
|
|
|
peerID: p2p.ID("P1"), |
|
|
|
peerID: p2p.NodeID("P1"), |
|
|
|
height: 6, |
|
|
|
} |
|
|
|
|
|
|
@ -1513,14 +1513,14 @@ func TestScHandleNoBlockResponse(t *testing.T) { |
|
|
|
fields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P2": {height: 8, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4, 5, 6, 7, 8}, |
|
|
|
pending: map[int64]p2p.ID{6: "P2"}, |
|
|
|
pending: map[int64]p2p.NodeID{6: "P2"}, |
|
|
|
pendingTime: map[int64]time.Time{6: now}, |
|
|
|
}, |
|
|
|
wantEvent: noOpEvent{}, |
|
|
|
wantFields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P2": {height: 8, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4, 5, 6, 7, 8}, |
|
|
|
pending: map[int64]p2p.ID{6: "P2"}, |
|
|
|
pending: map[int64]p2p.NodeID{6: "P2"}, |
|
|
|
pendingTime: map[int64]time.Time{6: now}, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1529,7 +1529,7 @@ func TestScHandleNoBlockResponse(t *testing.T) { |
|
|
|
fields: scTestParams{ |
|
|
|
peers: map[string]*scPeer{"P1": {height: 8, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4, 5, 6, 7, 8}, |
|
|
|
pending: map[int64]p2p.ID{6: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{6: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{6: now}, |
|
|
|
}, |
|
|
|
wantEvent: scPeerError{peerID: "P1", reason: fmt.Errorf("some error")}, |
|
|
@ -1552,7 +1552,7 @@ func TestScHandleNoBlockResponse(t *testing.T) { |
|
|
|
func TestScHandleBlockProcessed(t *testing.T) { |
|
|
|
now := time.Now() |
|
|
|
processed6FromP1 := pcBlockProcessed{ |
|
|
|
peerID: p2p.ID("P1"), |
|
|
|
peerID: p2p.NodeID("P1"), |
|
|
|
height: 6, |
|
|
|
} |
|
|
|
|
|
|
@ -1579,7 +1579,7 @@ func TestScHandleBlockProcessed(t *testing.T) { |
|
|
|
initHeight: 6, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 8, state: peerStateReady}}, |
|
|
|
allB: []int64{6, 7, 8}, |
|
|
|
pending: map[int64]p2p.ID{6: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{6: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{6: now}, |
|
|
|
}, |
|
|
|
args: args{event: processed6FromP1}, |
|
|
@ -1591,7 +1591,7 @@ func TestScHandleBlockProcessed(t *testing.T) { |
|
|
|
initHeight: 6, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 7, state: peerStateReady}}, |
|
|
|
allB: []int64{6, 7}, |
|
|
|
received: map[int64]p2p.ID{6: "P1", 7: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{6: "P1", 7: "P1"}, |
|
|
|
}, |
|
|
|
args: args{event: processed6FromP1}, |
|
|
|
wantEvent: scFinishedEv{}, |
|
|
@ -1602,8 +1602,8 @@ func TestScHandleBlockProcessed(t *testing.T) { |
|
|
|
initHeight: 6, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 8, state: peerStateReady}}, |
|
|
|
allB: []int64{6, 7, 8}, |
|
|
|
pending: map[int64]p2p.ID{7: "P1", 8: "P1"}, |
|
|
|
received: map[int64]p2p.ID{6: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{7: "P1", 8: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{6: "P1"}, |
|
|
|
}, |
|
|
|
args: args{event: processed6FromP1}, |
|
|
|
wantEvent: noOpEvent{}, |
|
|
@ -1646,7 +1646,7 @@ func TestScHandleBlockVerificationFailure(t *testing.T) { |
|
|
|
initHeight: 6, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 8, state: peerStateReady}}, |
|
|
|
allB: []int64{6, 7, 8}, |
|
|
|
pending: map[int64]p2p.ID{6: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{6: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{6: now}, |
|
|
|
}, |
|
|
|
args: args{event: pcBlockVerificationFailure{height: 10, firstPeerID: "P1", secondPeerID: "P1"}}, |
|
|
@ -1658,7 +1658,7 @@ func TestScHandleBlockVerificationFailure(t *testing.T) { |
|
|
|
initHeight: 6, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 8, state: peerStateReady}, "P2": {height: 8, state: peerStateReady}}, |
|
|
|
allB: []int64{6, 7, 8}, |
|
|
|
pending: map[int64]p2p.ID{6: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{6: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{6: now}, |
|
|
|
}, |
|
|
|
args: args{event: pcBlockVerificationFailure{height: 10, firstPeerID: "P1", secondPeerID: "P1"}}, |
|
|
@ -1670,7 +1670,7 @@ func TestScHandleBlockVerificationFailure(t *testing.T) { |
|
|
|
initHeight: 6, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 7, state: peerStateReady}}, |
|
|
|
allB: []int64{6, 7}, |
|
|
|
received: map[int64]p2p.ID{6: "P1", 7: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{6: "P1", 7: "P1"}, |
|
|
|
}, |
|
|
|
args: args{event: pcBlockVerificationFailure{height: 7, firstPeerID: "P1", secondPeerID: "P1"}}, |
|
|
|
wantEvent: scFinishedEv{}, |
|
|
@ -1681,8 +1681,8 @@ func TestScHandleBlockVerificationFailure(t *testing.T) { |
|
|
|
initHeight: 5, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 8, state: peerStateReady}, "P2": {height: 8, state: peerStateReady}}, |
|
|
|
allB: []int64{5, 6, 7, 8}, |
|
|
|
pending: map[int64]p2p.ID{7: "P1", 8: "P1"}, |
|
|
|
received: map[int64]p2p.ID{5: "P1", 6: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{7: "P1", 8: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{5: "P1", 6: "P1"}, |
|
|
|
}, |
|
|
|
args: args{event: pcBlockVerificationFailure{height: 5, firstPeerID: "P1", secondPeerID: "P1"}}, |
|
|
|
wantEvent: noOpEvent{}, |
|
|
@ -1697,8 +1697,8 @@ func TestScHandleBlockVerificationFailure(t *testing.T) { |
|
|
|
"P3": {height: 8, state: peerStateReady}, |
|
|
|
}, |
|
|
|
allB: []int64{5, 6, 7, 8}, |
|
|
|
pending: map[int64]p2p.ID{7: "P1", 8: "P1"}, |
|
|
|
received: map[int64]p2p.ID{5: "P1", 6: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{7: "P1", 8: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{5: "P1", 6: "P1"}, |
|
|
|
}, |
|
|
|
args: args{event: pcBlockVerificationFailure{height: 5, firstPeerID: "P1", secondPeerID: "P2"}}, |
|
|
|
wantEvent: noOpEvent{}, |
|
|
@ -1717,7 +1717,7 @@ func TestScHandleBlockVerificationFailure(t *testing.T) { |
|
|
|
|
|
|
|
func TestScHandleAddNewPeer(t *testing.T) { |
|
|
|
addP1 := bcAddNewPeer{ |
|
|
|
peerID: p2p.ID("P1"), |
|
|
|
peerID: p2p.NodeID("P1"), |
|
|
|
} |
|
|
|
type args struct { |
|
|
|
event bcAddNewPeer |
|
|
@ -1828,7 +1828,7 @@ func TestScHandleTryPrunePeer(t *testing.T) { |
|
|
|
allB: []int64{1, 2, 3, 4, 5, 6, 7}, |
|
|
|
peerTimeout: time.Second}, |
|
|
|
args: args{event: pruneEv}, |
|
|
|
wantEvent: scPeersPruned{peers: []p2p.ID{"P4", "P5", "P6"}}, |
|
|
|
wantEvent: scPeersPruned{peers: []p2p.NodeID{"P4", "P5", "P6"}}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: "mixed peers, finish after pruning", |
|
|
@ -1926,7 +1926,7 @@ func TestScHandleTrySchedule(t *testing.T) { |
|
|
|
"P1": {height: 4, state: peerStateReady}, |
|
|
|
"P2": {height: 5, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4, 5}, |
|
|
|
pending: map[int64]p2p.ID{ |
|
|
|
pending: map[int64]p2p.NodeID{ |
|
|
|
1: "P1", 2: "P1", |
|
|
|
3: "P2", |
|
|
|
}, |
|
|
@ -1944,7 +1944,7 @@ func TestScHandleTrySchedule(t *testing.T) { |
|
|
|
"P1": {height: 8, state: peerStateReady}, |
|
|
|
"P3": {height: 8, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3, 4, 5, 6, 7, 8}, |
|
|
|
pending: map[int64]p2p.ID{ |
|
|
|
pending: map[int64]p2p.NodeID{ |
|
|
|
1: "P1", 2: "P1", |
|
|
|
3: "P3", 4: "P3", |
|
|
|
5: "P2", 6: "P2", |
|
|
@ -2106,7 +2106,7 @@ func TestScHandle(t *testing.T) { |
|
|
|
startTime: now, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 3, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3}, |
|
|
|
pending: map[int64]p2p.ID{1: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{1: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{1: tick[1]}, |
|
|
|
height: 1, |
|
|
|
}, |
|
|
@ -2118,7 +2118,7 @@ func TestScHandle(t *testing.T) { |
|
|
|
startTime: now, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 3, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3}, |
|
|
|
pending: map[int64]p2p.ID{1: "P1", 2: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{1: "P1", 2: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{1: tick[1], 2: tick[2]}, |
|
|
|
height: 1, |
|
|
|
}, |
|
|
@ -2130,7 +2130,7 @@ func TestScHandle(t *testing.T) { |
|
|
|
startTime: now, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 3, state: peerStateReady}}, |
|
|
|
allB: []int64{1, 2, 3}, |
|
|
|
pending: map[int64]p2p.ID{1: "P1", 2: "P1", 3: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{1: "P1", 2: "P1", 3: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{1: tick[1], 2: tick[2], 3: tick[3]}, |
|
|
|
height: 1, |
|
|
|
}, |
|
|
@ -2142,9 +2142,9 @@ func TestScHandle(t *testing.T) { |
|
|
|
startTime: now, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 3, state: peerStateReady, lastTouched: tick[4]}}, |
|
|
|
allB: []int64{1, 2, 3}, |
|
|
|
pending: map[int64]p2p.ID{2: "P1", 3: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{2: "P1", 3: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{2: tick[2], 3: tick[3]}, |
|
|
|
received: map[int64]p2p.ID{1: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{1: "P1"}, |
|
|
|
height: 1, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -2155,9 +2155,9 @@ func TestScHandle(t *testing.T) { |
|
|
|
startTime: now, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 3, state: peerStateReady, lastTouched: tick[5]}}, |
|
|
|
allB: []int64{1, 2, 3}, |
|
|
|
pending: map[int64]p2p.ID{3: "P1"}, |
|
|
|
pending: map[int64]p2p.NodeID{3: "P1"}, |
|
|
|
pendingTime: map[int64]time.Time{3: tick[3]}, |
|
|
|
received: map[int64]p2p.ID{1: "P1", 2: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{1: "P1", 2: "P1"}, |
|
|
|
height: 1, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -2168,29 +2168,29 @@ func TestScHandle(t *testing.T) { |
|
|
|
startTime: now, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 3, state: peerStateReady, lastTouched: tick[6]}}, |
|
|
|
allB: []int64{1, 2, 3}, |
|
|
|
received: map[int64]p2p.ID{1: "P1", 2: "P1", 3: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{1: "P1", 2: "P1", 3: "P1"}, |
|
|
|
height: 1, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ // processed block 1
|
|
|
|
args: args{event: pcBlockProcessed{peerID: p2p.ID("P1"), height: 1}}, |
|
|
|
args: args{event: pcBlockProcessed{peerID: p2p.NodeID("P1"), height: 1}}, |
|
|
|
wantEvent: noOpEvent{}, |
|
|
|
wantSc: &scTestParams{ |
|
|
|
startTime: now, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 3, state: peerStateReady, lastTouched: tick[6]}}, |
|
|
|
allB: []int64{2, 3}, |
|
|
|
received: map[int64]p2p.ID{2: "P1", 3: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{2: "P1", 3: "P1"}, |
|
|
|
height: 2, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ // processed block 2
|
|
|
|
args: args{event: pcBlockProcessed{peerID: p2p.ID("P1"), height: 2}}, |
|
|
|
args: args{event: pcBlockProcessed{peerID: p2p.NodeID("P1"), height: 2}}, |
|
|
|
wantEvent: scFinishedEv{}, |
|
|
|
wantSc: &scTestParams{ |
|
|
|
startTime: now, |
|
|
|
peers: map[string]*scPeer{"P1": {height: 3, state: peerStateReady, lastTouched: tick[6]}}, |
|
|
|
allB: []int64{3}, |
|
|
|
received: map[int64]p2p.ID{3: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{3: "P1"}, |
|
|
|
height: 3, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -2206,7 +2206,7 @@ func TestScHandle(t *testing.T) { |
|
|
|
"P1": {height: 4, state: peerStateReady, lastTouched: tick[6]}, |
|
|
|
"P2": {height: 3, state: peerStateReady, lastTouched: tick[6]}}, |
|
|
|
allB: []int64{1, 2, 3, 4}, |
|
|
|
received: map[int64]p2p.ID{1: "P1", 2: "P1", 3: "P1"}, |
|
|
|
received: map[int64]p2p.NodeID{1: "P1", 2: "P1", 3: "P1"}, |
|
|
|
height: 1, |
|
|
|
}, |
|
|
|
args: args{event: pcBlockVerificationFailure{height: 1, firstPeerID: "P1", secondPeerID: "P1"}}, |
|
|
@ -2217,7 +2217,7 @@ func TestScHandle(t *testing.T) { |
|
|
|
"P1": {height: 4, state: peerStateRemoved, lastTouched: tick[6]}, |
|
|
|
"P2": {height: 3, state: peerStateReady, lastTouched: tick[6]}}, |
|
|
|
allB: []int64{1, 2, 3}, |
|
|
|
received: map[int64]p2p.ID{}, |
|
|
|
received: map[int64]p2p.NodeID{}, |
|
|
|
height: 1, |
|
|
|
}, |
|
|
|
}, |
|
|
|