-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #196 from tendermint/feature/184-overhaul-handler-…
…interface Feature/184 overhaul handler interface
- Loading branch information
Showing
47 changed files
with
980 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Alexis: | ||
|
||
* merkle - proof (non-existence - maybe range) | ||
* intro to light-client and proofs | ||
light-client proofs: | ||
* make this sensible -> very tied to merkle proofs and API | ||
* support new proof types | ||
|
||
* expose more proof types in basecoin.Query | ||
|
||
|
||
* merkle - api cleanup (also Bonsai) | ||
* later: C bindings (to Bonsai?) | ||
|
||
|
||
* crypto-ledger (while ethan gone) | ||
|
||
light-client provider: | ||
* caching checkpoint on Verify | ||
* cleanup (trim old node) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package app | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
abci "github.com/tendermint/abci/types" | ||
"github.com/tendermint/basecoin/modules/base" | ||
wire "github.com/tendermint/go-wire" | ||
cmn "github.com/tendermint/tmlibs/common" | ||
"github.com/tendermint/tmlibs/log" | ||
) | ||
|
||
//----------------------------------- | ||
// Test cases start here | ||
|
||
func randPower() uint64 { | ||
return uint64(cmn.RandInt()%50 + 60) | ||
} | ||
|
||
func makeVal() *abci.Validator { | ||
return &abci.Validator{ | ||
PubKey: cmn.RandBytes(10), | ||
Power: randPower(), | ||
} | ||
} | ||
|
||
// withNewPower returns a copy of the validator with a different power | ||
func withNewPower(val *abci.Validator) *abci.Validator { | ||
res := *val | ||
res.Power = randPower() | ||
if res.Power == val.Power { | ||
panic("no no") | ||
} | ||
return &res | ||
} | ||
|
||
func TestEndBlock(t *testing.T) { | ||
assert, require := assert.New(t), require.New(t) | ||
|
||
logger := log.NewNopLogger() | ||
store := MockStore() | ||
handler := base.ValSetHandler{} | ||
app := NewBasecoin(handler, store, logger) | ||
|
||
val1 := makeVal() | ||
val2 := makeVal() | ||
val3 := makeVal() | ||
val1a := withNewPower(val1) | ||
val2a := withNewPower(val2) | ||
|
||
cases := [...]struct { | ||
changes [][]*abci.Validator | ||
expected []*abci.Validator | ||
}{ | ||
// Nothing in, nothing out, no crash | ||
0: {}, | ||
// One in, one out, no problem | ||
1: { | ||
changes: [][]*abci.Validator{{val1}}, | ||
expected: []*abci.Validator{val1}, | ||
}, | ||
// Combine a few ones | ||
2: { | ||
changes: [][]*abci.Validator{{val1}, {val2, val3}}, | ||
expected: []*abci.Validator{val1, val2, val3}, | ||
}, | ||
// Make sure changes all to one validators are squished into one diff | ||
3: { | ||
changes: [][]*abci.Validator{{val1}, {val2, val1a}, {val2a, val3}}, | ||
expected: []*abci.Validator{val1a, val2a, val3}, | ||
}, | ||
} | ||
|
||
for i, tc := range cases { | ||
app.BeginBlock(nil, nil) | ||
for _, c := range tc.changes { | ||
tx := base.ValChangeTx{c}.Wrap() | ||
txBytes := wire.BinaryBytes(tx) | ||
res := app.DeliverTx(txBytes) | ||
require.True(res.IsOK(), "%#v", res) | ||
} | ||
diff := app.EndBlock(app.height) | ||
// TODO: don't care about order here... | ||
assert.Equal(tc.expected, diff.Diffs, "%d", i) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.