Add height to context, cleanup, add to app and stack

This commit is contained in:
Ethan Frey
2017-07-10 12:19:42 +02:00
parent 100d88d7dd
commit b6197a1c12
12 changed files with 72 additions and 84 deletions
+2 -2
View File
@@ -40,7 +40,7 @@ func BenchmarkCheckOneSig(b *testing.B) {
h := makeHandler()
store := state.NewMemKVStore()
for i := 1; i <= b.N; i++ {
ctx := stack.NewContext("foo", log.NewNopLogger())
ctx := stack.NewContext("foo", 100, log.NewNopLogger())
_, err := h.DeliverTx(ctx, store, tx)
// never should error
if err != nil {
@@ -64,7 +64,7 @@ func benchmarkCheckMultiSig(b *testing.B, cnt int) {
h := makeHandler()
store := state.NewMemKVStore()
for i := 1; i <= b.N; i++ {
ctx := stack.NewContext("foo", log.NewNopLogger())
ctx := stack.NewContext("foo", 100, log.NewNopLogger())
_, err := h.DeliverTx(ctx, store, tx)
// never should error
if err != nil {
+1 -1
View File
@@ -18,7 +18,7 @@ func TestSignatureChecks(t *testing.T) {
assert := assert.New(t)
// generic args
ctx := stack.NewContext("test-chain", log.NewNopLogger())
ctx := stack.NewContext("test-chain", 100, log.NewNopLogger())
store := state.NewMemKVStore()
raw := stack.NewRawTx([]byte{1, 2, 3, 4})
+1 -1
View File
@@ -61,7 +61,7 @@ func TestChain(t *testing.T) {
}
// generic args here...
ctx := stack.NewContext(chainID, log.NewNopLogger())
ctx := stack.NewContext(chainID, 100, log.NewNopLogger())
store := state.NewMemKVStore()
// build the stack
+1 -1
View File
@@ -34,7 +34,7 @@ func BenchmarkSimpleTransfer(b *testing.B) {
// now, loop...
for i := 1; i <= b.N; i++ {
ctx := stack.MockContext("foo").WithPermissions(sender)
ctx := stack.MockContext("foo", 100).WithPermissions(sender)
tx := makeSimpleTx(sender, receiver, Coins{{"mycoin", 2}}, i)
_, err := h.DeliverTx(ctx, store, tx)
// never should error
+2 -2
View File
@@ -74,7 +74,7 @@ func TestHandlerValidation(t *testing.T) {
}
for i, tc := range cases {
ctx := stack.MockContext("base-chain").WithPermissions(tc.perms...)
ctx := stack.MockContext("base-chain", 100).WithPermissions(tc.perms...)
_, err := checkTx(ctx, tc.tx)
if tc.valid {
assert.Nil(err, "%d: %+v", i, err)
@@ -148,7 +148,7 @@ func TestDeliverTx(t *testing.T) {
require.Nil(err, "%d: %+v", i, err)
}
ctx := stack.MockContext("base-chain").WithPermissions(tc.perms...)
ctx := stack.MockContext("base-chain", 100).WithPermissions(tc.perms...)
_, err := h.DeliverTx(ctx, store, tc.tx)
if len(tc.final) > 0 { // valid
assert.Nil(err, "%d: %+v", i, err)