update for sdk2 libs. need to fix kv test

NOTE we only updating for tmlibs and abci
This commit is contained in:
Ethan Buchman
2018-01-06 01:26:51 -05:00
parent 4e3488c677
commit cd0fd06b0d
23 changed files with 130 additions and 346 deletions

View File

@ -77,9 +77,9 @@ func TestABCIResponsesSaveLoad1(t *testing.T) {
// build mock responses
block := makeBlock(state, 2)
abciResponses := NewABCIResponses(block)
abciResponses.DeliverTx[0] = &abci.ResponseDeliverTx{Data: []byte("foo"), Tags: []*abci.KVPair{}}
abciResponses.DeliverTx[1] = &abci.ResponseDeliverTx{Data: []byte("bar"), Log: "ok", Tags: []*abci.KVPair{}}
abciResponses.EndBlock = &abci.ResponseEndBlock{ValidatorUpdates: []*abci.Validator{
abciResponses.DeliverTx[0] = &abci.ResponseDeliverTx{Data: []byte("foo"), Tags: []cmn.KVPair{}}
abciResponses.DeliverTx[1] = &abci.ResponseDeliverTx{Data: []byte("bar"), Log: "ok", Tags: []cmn.KVPair{}}
abciResponses.EndBlock = &abci.ResponseEndBlock{ValidatorUpdates: []abci.Validator{
{
PubKey: crypto.GenPrivKeyEd25519().PubKey().Bytes(),
Power: 10,
@ -122,9 +122,9 @@ func TestABCIResponsesSaveLoad2(t *testing.T) {
[]*abci.ResponseDeliverTx{
{Code: 383},
{Data: []byte("Gotcha!"),
Tags: []*abci.KVPair{
abci.KVPairInt("a", 1),
abci.KVPairString("build", "stuff"),
Tags: []cmn.KVPair{
cmn.KVPair{[]byte("a"), []byte{1}},
cmn.KVPair{[]byte("build"), []byte("stuff")},
}},
},
types.ABCIResults{
@ -378,44 +378,44 @@ func TestLessThanOneThirdOfVotingPowerPerBlockEnforced(t *testing.T) {
testCases := []struct {
initialValSetSize int
shouldErr bool
valUpdatesFn func(vals *types.ValidatorSet) []*abci.Validator
valUpdatesFn func(vals *types.ValidatorSet) []abci.Validator
}{
///////////// 1 val (vp: 10) => less than 3 is ok ////////////////////////
// adding 1 validator => 10
0: {1, false, func(vals *types.ValidatorSet) []*abci.Validator {
return []*abci.Validator{
0: {1, false, func(vals *types.ValidatorSet) []abci.Validator {
return []abci.Validator{
{PubKey: pk(), Power: 2},
}
}},
1: {1, true, func(vals *types.ValidatorSet) []*abci.Validator {
return []*abci.Validator{
1: {1, true, func(vals *types.ValidatorSet) []abci.Validator {
return []abci.Validator{
{PubKey: pk(), Power: 3},
}
}},
2: {1, true, func(vals *types.ValidatorSet) []*abci.Validator {
return []*abci.Validator{
2: {1, true, func(vals *types.ValidatorSet) []abci.Validator {
return []abci.Validator{
{PubKey: pk(), Power: 100},
}
}},
///////////// 3 val (vp: 30) => less than 10 is ok ////////////////////////
// adding and removing validator => 20
3: {3, true, func(vals *types.ValidatorSet) []*abci.Validator {
3: {3, true, func(vals *types.ValidatorSet) []abci.Validator {
_, firstVal := vals.GetByIndex(0)
return []*abci.Validator{
return []abci.Validator{
{PubKey: firstVal.PubKey.Bytes(), Power: 0},
{PubKey: pk(), Power: 10},
}
}},
// adding 1 validator => 10
4: {3, true, func(vals *types.ValidatorSet) []*abci.Validator {
return []*abci.Validator{
4: {3, true, func(vals *types.ValidatorSet) []abci.Validator {
return []abci.Validator{
{PubKey: pk(), Power: 10},
}
}},
// adding 2 validators => 8
5: {3, false, func(vals *types.ValidatorSet) []*abci.Validator {
return []*abci.Validator{
5: {3, false, func(vals *types.ValidatorSet) []abci.Validator {
return []abci.Validator{
{PubKey: pk(), Power: 4},
{PubKey: pk(), Power: 4},
}
@ -450,20 +450,20 @@ func TestApplyUpdates(t *testing.T) {
cases := [...]struct {
init types.ConsensusParams
updates *abci.ConsensusParams
updates abci.ConsensusParams
expected types.ConsensusParams
}{
0: {initParams, nil, initParams},
1: {initParams, &abci.ConsensusParams{}, initParams},
0: {initParams, abci.ConsensusParams{}, initParams},
1: {initParams, abci.ConsensusParams{}, initParams},
2: {initParams,
&abci.ConsensusParams{
abci.ConsensusParams{
TxSize: &abci.TxSize{
MaxBytes: 123,
},
},
makeParams(1, 2, 3, 123, 5, 6)},
3: {initParams,
&abci.ConsensusParams{
abci.ConsensusParams{
BlockSize: &abci.BlockSize{
MaxTxs: 44,
MaxGas: 55,
@ -471,7 +471,7 @@ func TestApplyUpdates(t *testing.T) {
},
makeParams(1, 44, 55, 4, 5, 6)},
4: {initParams,
&abci.ConsensusParams{
abci.ConsensusParams{
BlockSize: &abci.BlockSize{
MaxTxs: 789,
},
@ -486,7 +486,7 @@ func TestApplyUpdates(t *testing.T) {
}
for i, tc := range cases {
res := tc.init.Update(tc.updates)
res := tc.init.Update(&(tc.updates))
assert.Equal(t, tc.expected, res, "case %d", i)
}
}
@ -496,14 +496,14 @@ func makeHeaderPartsResponsesValPubKeyChange(state State, height int64,
block := makeBlock(state, height)
abciResponses := &ABCIResponses{
EndBlock: &abci.ResponseEndBlock{ValidatorUpdates: []*abci.Validator{}},
EndBlock: &abci.ResponseEndBlock{ValidatorUpdates: []abci.Validator{}},
}
// if the pubkey is new, remove the old and add the new
_, val := state.Validators.GetByIndex(0)
if !bytes.Equal(pubkey.Bytes(), val.PubKey.Bytes()) {
abciResponses.EndBlock = &abci.ResponseEndBlock{
ValidatorUpdates: []*abci.Validator{
ValidatorUpdates: []abci.Validator{
{val.PubKey.Bytes(), 0},
{pubkey.Bytes(), 10},
},
@ -518,14 +518,14 @@ func makeHeaderPartsResponsesValPowerChange(state State, height int64,
block := makeBlock(state, height)
abciResponses := &ABCIResponses{
EndBlock: &abci.ResponseEndBlock{ValidatorUpdates: []*abci.Validator{}},
EndBlock: &abci.ResponseEndBlock{ValidatorUpdates: []abci.Validator{}},
}
// if the pubkey is new, remove the old and add the new
_, val := state.Validators.GetByIndex(0)
if val.VotingPower != power {
abciResponses.EndBlock = &abci.ResponseEndBlock{
ValidatorUpdates: []*abci.Validator{
ValidatorUpdates: []abci.Validator{
{val.PubKey.Bytes(), power},
},
}