-
Notifications
You must be signed in to change notification settings - Fork 386
/
testutil.go
84 lines (60 loc) · 2.13 KB
/
testutil.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package mempool
import (
"fmt"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
txsigning "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
"google.golang.org/protobuf/proto"
)
// testPubKey is a dummy implementation of PubKey used for testing.
type testPubKey struct {
address sdk.AccAddress
}
func (t testPubKey) Reset() { panic("not implemented") }
func (t testPubKey) String() string { panic("not implemented") }
func (t testPubKey) ProtoMessage() { panic("not implemented") }
func (t testPubKey) Address() cryptotypes.Address { return t.address.Bytes() }
func (t testPubKey) Bytes() []byte { panic("not implemented") }
func (t testPubKey) VerifySignature(msg, sig []byte) bool { panic("not implemented") }
func (t testPubKey) Equals(key cryptotypes.PubKey) bool { panic("not implemented") }
func (t testPubKey) Type() string { panic("not implemented") }
// testTx is a dummy implementation of Tx used for testing.
type testTx struct {
address sdk.AccAddress
nonce uint64
}
func (tx testTx) GetMsgsV2() ([]proto.Message, error) {
panic("implement me")
}
func (tx testTx) GetSigners() ([][]byte, error) { panic("not implemented") }
func (tx testTx) GetPubKeys() ([]cryptotypes.PubKey, error) { panic("not implemented") }
func (tx testTx) GetSignaturesV2() ([]txsigning.SignatureV2, error) {
return []txsigning.SignatureV2{{
PubKey: testPubKey{address: tx.address},
Data: nil,
Sequence: tx.nonce,
}}, nil
}
func (tx testTx) GetGas() uint64 {
return 10
}
func (tx testTx) GetFee() sdk.Coins {
return sdk.NewCoins(sdk.NewInt64Coin("stake", int64(5)))
}
func (tx testTx) FeePayer() sdk.AccAddress {
return tx.address
}
func (tx testTx) FeeGranter() sdk.AccAddress {
return tx.address
}
var (
_ sdk.Tx = (*testTx)(nil)
_ signing.SigVerifiableTx = (*testTx)(nil)
_ cryptotypes.PubKey = (*testPubKey)(nil)
)
func (tx testTx) GetMsgs() []sdk.Msg { return nil }
func (tx testTx) ValidateBasic() error { return nil }
func (tx testTx) String() string {
return fmt.Sprintf("tx a: %s, n: %d", tx.address, tx.nonce)
}