|
|
@ -353,9 +353,7 @@ func TestSimulateValidatorsChange(t *testing.T) { |
|
|
|
signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vss[1:nVals]...) |
|
|
|
ensureNewRound(newRoundCh, height+1, 0) |
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// HEIGHT 2
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
height++ |
|
|
|
incrementHeight(vss...) |
|
|
|
newValidatorPubKey1, err := css[nVals].privValidator.GetPubKey() |
|
|
@ -365,7 +363,7 @@ func TestSimulateValidatorsChange(t *testing.T) { |
|
|
|
newValidatorTx1 := kvstore.MakeValSetChangeTx(valPubKey1ABCI, testMinPower) |
|
|
|
err = assertMempool(css[0].txNotifier).CheckTx(newValidatorTx1, nil, mempl.TxInfo{}) |
|
|
|
assert.Nil(t, err) |
|
|
|
propBlock, _ := css[0].createProposalBlock() //changeProposer(t, cs1, vs2)
|
|
|
|
propBlock, _ := css[0].createProposalBlock() // changeProposer(t, cs1, vs2)
|
|
|
|
propBlockParts := propBlock.MakePartSet(partSize) |
|
|
|
blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} |
|
|
|
|
|
|
@ -385,9 +383,7 @@ func TestSimulateValidatorsChange(t *testing.T) { |
|
|
|
signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vss[1:nVals]...) |
|
|
|
ensureNewRound(newRoundCh, height+1, 0) |
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// HEIGHT 3
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
height++ |
|
|
|
incrementHeight(vss...) |
|
|
|
updateValidatorPubKey1, err := css[nVals].privValidator.GetPubKey() |
|
|
@ -397,7 +393,7 @@ func TestSimulateValidatorsChange(t *testing.T) { |
|
|
|
updateValidatorTx1 := kvstore.MakeValSetChangeTx(updatePubKey1ABCI, 25) |
|
|
|
err = assertMempool(css[0].txNotifier).CheckTx(updateValidatorTx1, nil, mempl.TxInfo{}) |
|
|
|
assert.Nil(t, err) |
|
|
|
propBlock, _ = css[0].createProposalBlock() //changeProposer(t, cs1, vs2)
|
|
|
|
propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2)
|
|
|
|
propBlockParts = propBlock.MakePartSet(partSize) |
|
|
|
blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} |
|
|
|
|
|
|
@ -417,9 +413,7 @@ func TestSimulateValidatorsChange(t *testing.T) { |
|
|
|
signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vss[1:nVals]...) |
|
|
|
ensureNewRound(newRoundCh, height+1, 0) |
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// HEIGHT 4
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
height++ |
|
|
|
incrementHeight(vss...) |
|
|
|
newValidatorPubKey2, err := css[nVals+1].privValidator.GetPubKey() |
|
|
@ -436,7 +430,7 @@ func TestSimulateValidatorsChange(t *testing.T) { |
|
|
|
newValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, testMinPower) |
|
|
|
err = assertMempool(css[0].txNotifier).CheckTx(newValidatorTx3, nil, mempl.TxInfo{}) |
|
|
|
assert.Nil(t, err) |
|
|
|
propBlock, _ = css[0].createProposalBlock() //changeProposer(t, cs1, vs2)
|
|
|
|
propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2)
|
|
|
|
propBlockParts = propBlock.MakePartSet(partSize) |
|
|
|
blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} |
|
|
|
newVss := make([]*validatorStub, nVals+1) |
|
|
@ -487,9 +481,7 @@ func TestSimulateValidatorsChange(t *testing.T) { |
|
|
|
|
|
|
|
ensureNewRound(newRoundCh, height+1, 0) |
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// HEIGHT 5
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
height++ |
|
|
|
incrementHeight(vss...) |
|
|
|
// Reflect the changes to vss[nVals] at height 3 and resort newVss.
|
|
|
@ -507,15 +499,13 @@ func TestSimulateValidatorsChange(t *testing.T) { |
|
|
|
} |
|
|
|
ensureNewRound(newRoundCh, height+1, 0) |
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// HEIGHT 6
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
height++ |
|
|
|
incrementHeight(vss...) |
|
|
|
removeValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, 0) |
|
|
|
err = assertMempool(css[0].txNotifier).CheckTx(removeValidatorTx3, nil, mempl.TxInfo{}) |
|
|
|
assert.Nil(t, err) |
|
|
|
propBlock, _ = css[0].createProposalBlock() //changeProposer(t, cs1, vs2)
|
|
|
|
propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2)
|
|
|
|
propBlockParts = propBlock.MakePartSet(partSize) |
|
|
|
blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} |
|
|
|
newVss = make([]*validatorStub, nVals+3) |
|
|
@ -594,7 +584,7 @@ func TestHandshakeReplayNone(t *testing.T) { |
|
|
|
|
|
|
|
// Test mockProxyApp should not panic when app return ABCIResponses with some empty ResponseDeliverTx
|
|
|
|
func TestMockProxyApp(t *testing.T) { |
|
|
|
sim.CleanupFunc() //clean the test env created in TestSimulateValidatorsChange
|
|
|
|
sim.CleanupFunc() // clean the test env created in TestSimulateValidatorsChange
|
|
|
|
logger := log.TestingLogger() |
|
|
|
var validTxs, invalidTxs = 0, 0 |
|
|
|
txIndex := 0 |
|
|
@ -676,7 +666,7 @@ func testHandshakeReplay(t *testing.T, config *cfg.Config, nBlocks int, mode uin |
|
|
|
chain = append([]*types.Block{}, sim.Chain...) // copy chain
|
|
|
|
commits = sim.Commits |
|
|
|
store = newMockBlockStore(config, genesisState.ConsensusParams) |
|
|
|
} else { //test single node
|
|
|
|
} else { // test single node
|
|
|
|
testConfig := ResetConfig(fmt.Sprintf("%s_%v_s", t.Name(), mode)) |
|
|
|
defer os.RemoveAll(testConfig.RootDir) |
|
|
|
walBody, err := WALWithNBlocks(t, numBlocks) |
|
|
@ -805,14 +795,14 @@ func buildAppStateFromChain(proxyApp proxy.AppConns, stateStore sm.Store, |
|
|
|
} |
|
|
|
defer proxyApp.Stop() //nolint:errcheck // ignore
|
|
|
|
|
|
|
|
state.Version.Consensus.App = kvstore.ProtocolVersion //simulate handshake, receive app version
|
|
|
|
state.Version.Consensus.App = kvstore.ProtocolVersion // simulate handshake, receive app version
|
|
|
|
validators := types.TM2PB.ValidatorUpdates(state.Validators) |
|
|
|
if _, err := proxyApp.Consensus().InitChainSync(abci.RequestInitChain{ |
|
|
|
Validators: validators, |
|
|
|
}); err != nil { |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
if err := stateStore.Save(state); err != nil { //save height 1's validatorsInfo
|
|
|
|
if err := stateStore.Save(state); err != nil { // save height 1's validatorsInfo
|
|
|
|
panic(err) |
|
|
|
} |
|
|
|
switch mode { |
|
|
@ -853,16 +843,16 @@ func buildTMStateFromChain( |
|
|
|
if err := proxyApp.Start(); err != nil { |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
defer proxyApp.Stop() //nolint:errcheck //ignore
|
|
|
|
defer proxyApp.Stop() //nolint:errcheck
|
|
|
|
|
|
|
|
state.Version.Consensus.App = kvstore.ProtocolVersion //simulate handshake, receive app version
|
|
|
|
state.Version.Consensus.App = kvstore.ProtocolVersion // simulate handshake, receive app version
|
|
|
|
validators := types.TM2PB.ValidatorUpdates(state.Validators) |
|
|
|
if _, err := proxyApp.Consensus().InitChainSync(abci.RequestInitChain{ |
|
|
|
Validators: validators, |
|
|
|
}); err != nil { |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
if err := stateStore.Save(state); err != nil { //save height 1's validatorsInfo
|
|
|
|
if err := stateStore.Save(state); err != nil { // save height 1's validatorsInfo
|
|
|
|
panic(err) |
|
|
|
} |
|
|
|
switch mode { |
|
|
|