TestBeginBlockByzantineValidators ensures we send byzantine validators list.
(t *testing.T)
| 126 | |
| 127 | // TestBeginBlockByzantineValidators ensures we send byzantine validators list. |
| 128 | func TestBeginBlockByzantineValidators(t *testing.T) { |
| 129 | app := &testApp{} |
| 130 | cc := proxy.NewLocalClientCreator(app) |
| 131 | proxyApp := proxy.NewAppConns(cc) |
| 132 | err := proxyApp.Start() |
| 133 | require.Nil(t, err) |
| 134 | defer proxyApp.Stop() //nolint:errcheck // ignore for tests |
| 135 | |
| 136 | state, stateDB, privVals := makeState(1, 1) |
| 137 | stateStore := sm.NewStore(stateDB, sm.StoreOptions{ |
| 138 | DiscardABCIResponses: false, |
| 139 | }) |
| 140 | |
| 141 | defaultEvidenceTime := time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC) |
| 142 | privVal := privVals[state.Validators.Validators[0].Address.String()] |
| 143 | blockID := makeBlockID([]byte("headerhash"), 1000, []byte("partshash")) |
| 144 | header := &types.Header{ |
| 145 | Version: tmversion.Consensus{Block: version.BlockProtocol, App: 1}, |
| 146 | ChainID: state.ChainID, |
| 147 | Height: 10, |
| 148 | Time: defaultEvidenceTime, |
| 149 | LastBlockID: blockID, |
| 150 | LastCommitHash: crypto.CRandBytes(tmhash.Size), |
| 151 | DataHash: crypto.CRandBytes(tmhash.Size), |
| 152 | ValidatorsHash: state.Validators.Hash(), |
| 153 | NextValidatorsHash: state.Validators.Hash(), |
| 154 | ConsensusHash: crypto.CRandBytes(tmhash.Size), |
| 155 | AppHash: crypto.CRandBytes(tmhash.Size), |
| 156 | LastResultsHash: crypto.CRandBytes(tmhash.Size), |
| 157 | EvidenceHash: crypto.CRandBytes(tmhash.Size), |
| 158 | ProposerAddress: crypto.CRandBytes(crypto.AddressSize), |
| 159 | } |
| 160 | |
| 161 | // we don't need to worry about validating the evidence as long as they pass validate basic |
| 162 | dve := types.NewMockDuplicateVoteEvidenceWithValidator(3, defaultEvidenceTime, privVal, state.ChainID) |
| 163 | dve.ValidatorPower = 1000 |
| 164 | lcae := &types.LightClientAttackEvidence{ |
| 165 | ConflictingBlock: &types.LightBlock{ |
| 166 | SignedHeader: &types.SignedHeader{ |
| 167 | Header: header, |
| 168 | Commit: types.NewCommit(10, 0, makeBlockID(header.Hash(), 100, []byte("partshash")), []types.CommitSig{{ |
| 169 | BlockIDFlag: types.BlockIDFlagNil, |
| 170 | ValidatorAddress: crypto.AddressHash([]byte("validator_address")), |
| 171 | Timestamp: defaultEvidenceTime, |
| 172 | Signature: crypto.CRandBytes(types.MaxSignatureSize), |
| 173 | }}), |
| 174 | }, |
| 175 | ValidatorSet: state.Validators, |
| 176 | }, |
| 177 | CommonHeight: 8, |
| 178 | ByzantineValidators: []*types.Validator{state.Validators.Validators[0]}, |
| 179 | TotalVotingPower: 12, |
| 180 | Timestamp: defaultEvidenceTime, |
| 181 | } |
| 182 | |
| 183 | ev := []types.Evidence{dve, lcae} |
| 184 | |
| 185 | abciEv := []abci.Evidence{ |
nothing calls this directly
no test coverage detected