|
@ -14,6 +14,7 @@ import ( |
|
|
"github.com/tendermint/tmlibs/log" |
|
|
"github.com/tendermint/tmlibs/log" |
|
|
|
|
|
|
|
|
cfg "github.com/tendermint/tendermint/config" |
|
|
cfg "github.com/tendermint/tendermint/config" |
|
|
|
|
|
cstypes "github.com/tendermint/tendermint/consensus/types" |
|
|
"github.com/tendermint/tendermint/p2p" |
|
|
"github.com/tendermint/tendermint/p2p" |
|
|
"github.com/tendermint/tendermint/types" |
|
|
"github.com/tendermint/tendermint/types" |
|
|
) |
|
|
) |
|
@ -130,8 +131,50 @@ func TestReactorBroadcastEvidence(t *testing.T) { |
|
|
// make reactors from statedb
|
|
|
// make reactors from statedb
|
|
|
reactors := makeAndConnectEvidenceReactors(config, stateDBs) |
|
|
reactors := makeAndConnectEvidenceReactors(config, stateDBs) |
|
|
|
|
|
|
|
|
|
|
|
// set the peer height on each reactor
|
|
|
|
|
|
for _, r := range reactors { |
|
|
|
|
|
for _, peer := range r.Switch.Peers().List() { |
|
|
|
|
|
ps := peerState{height} |
|
|
|
|
|
peer.Set(types.PeerStateKey, ps) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// send a bunch of valid evidence to the first reactor's evpool
|
|
|
// send a bunch of valid evidence to the first reactor's evpool
|
|
|
// and wait for them all to be received in the others
|
|
|
// and wait for them all to be received in the others
|
|
|
evList := sendEvidence(t, reactors[0].evpool, valAddr, NUM_EVIDENCE) |
|
|
evList := sendEvidence(t, reactors[0].evpool, valAddr, NUM_EVIDENCE) |
|
|
waitForEvidence(t, evList, reactors) |
|
|
waitForEvidence(t, evList, reactors) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type peerState struct { |
|
|
|
|
|
height int64 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (ps peerState) GetRoundState() *cstypes.PeerRoundState { |
|
|
|
|
|
return &cstypes.PeerRoundState{ |
|
|
|
|
|
Height: ps.height, |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestReactorSelectiveBroadcast(t *testing.T) { |
|
|
|
|
|
config := cfg.TestConfig() |
|
|
|
|
|
|
|
|
|
|
|
valAddr := []byte("myval") |
|
|
|
|
|
height1 := int64(NUM_EVIDENCE) + 10 |
|
|
|
|
|
height2 := int64(NUM_EVIDENCE) / 2 |
|
|
|
|
|
|
|
|
|
|
|
// DB1 is ahead of DB2
|
|
|
|
|
|
stateDB1 := initializeValidatorState(valAddr, height1) |
|
|
|
|
|
stateDB2 := initializeValidatorState(valAddr, height2) |
|
|
|
|
|
|
|
|
|
|
|
// make reactors from statedb
|
|
|
|
|
|
reactors := makeAndConnectEvidenceReactors(config, []dbm.DB{stateDB1, stateDB2}) |
|
|
|
|
|
peer := reactors[0].Switch.Peers().List()[0] |
|
|
|
|
|
ps := peerState{height2} |
|
|
|
|
|
peer.Set(types.PeerStateKey, ps) |
|
|
|
|
|
|
|
|
|
|
|
// send a bunch of valid evidence to the first reactor's evpool
|
|
|
|
|
|
evList := sendEvidence(t, reactors[0].evpool, valAddr, NUM_EVIDENCE) |
|
|
|
|
|
|
|
|
|
|
|
// only ones less than the peers height should make it through
|
|
|
|
|
|
waitForEvidence(t, evList[:NUM_EVIDENCE/2], reactors[1:2]) |
|
|
|
|
|
} |