MCPcopy
hub / github.com/canopy-network/canopy / TestTransactionCheckBasic

Function TestTransactionCheckBasic

lib/tx_test.go:13–162  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestTransactionCheckBasic(t *testing.T) {
14 // pre-define a test message
15 sig := &Signature{
16 PublicKey: newTestPublicKeyBytes(t),
17 Signature: newTestPublicKeyBytes(t),
18 }
19 // pre-define an any for testing
20 a, e := NewAny(sig)
21 require.NoError(t, e)
22 // define test cases
23 tests := []struct {
24 name string
25 detail string
26 transaction *Transaction
27 error string
28 }{
29 {
30 name: "nil transaction",
31 detail: "a nil or empty transaction",
32 transaction: nil,
33 error: "transaction is empty",
34 },
35 {
36 name: "nil message",
37 detail: "a nil or empty message",
38 transaction: &Transaction{
39 MessageType: "",
40 Msg: nil,
41 Signature: nil,
42 Time: 0,
43 Fee: 0,
44 Memo: "",
45 },
46 error: "message is empty",
47 },
48 {
49 name: "empty signature",
50 detail: "the signature is empty",
51 transaction: &Transaction{
52 MessageType: testMessageName,
53 Msg: a,
54 Signature: nil,
55 Time: 0,
56 Fee: 0,
57 Memo: "",
58 },
59 error: "signature is empty",
60 },
61 {
62 name: "tx height is invalid",
63 detail: "the signature is empty",
64 transaction: &Transaction{
65 MessageType: testMessageName,
66 Msg: a,
67 Signature: sig,
68 Time: 0,
69 Fee: 0,
70 Memo: "",

Callers

nothing calls this directly

Calls 5

NewAnyFunction · 0.85
RunMethod · 0.80
EqualMethod · 0.80
newTestPublicKeyBytesFunction · 0.70
CheckBasicMethod · 0.45

Tested by

no test coverage detected