forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin_test.go
41 lines (33 loc) · 1.07 KB
/
plugin_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package types
import (
"testing"
"github.com/stretchr/testify/assert"
abci "github.com/tendermint/abci/types"
)
//----------------------------------
type Dummy struct{}
func (d *Dummy) Name() string {
return "dummy"
}
func (d *Dummy) RunTx(store KVStore, ctx CallContext, txBytes []byte) (res abci.Result) {
return
}
func (d *Dummy) SetOption(storei KVStore, key, value string) (log string) {
return ""
}
func (d *Dummy) InitChain(store KVStore, vals []*abci.Validator) {
}
func (d *Dummy) BeginBlock(store KVStore, hash []byte, header *abci.Header) {
}
func (d *Dummy) EndBlock(store KVStore, height uint64) (res abci.ResponseEndBlock) {
return
}
//----------------------------------
func TestPlugin(t *testing.T) {
assert := assert.New(t)
plugins := NewPlugins()
assert.Zero(len(plugins.GetList()), "plugins object init with a objects")
plugins.RegisterPlugin(&Dummy{})
assert.Equal(len(plugins.GetList()), 1, "plugin wasn't added to plist after registered")
assert.Equal(plugins.GetByName("dummy").Name(), "dummy", "plugin wasn't retrieved properly with GetByName")
}