@@ -18,44 +18,50 @@ const (
18
18
gasWanted = uint64 (100 )
19
19
)
20
20
21
- // tests acknowledgement.ValidateBasic and acknowledgement.GetBytes
21
+ // tests acknowledgement.ValidateBasic and acknowledgement.Acknowledgement
22
22
func (suite TypesTestSuite ) TestAcknowledgement () { //nolint:govet // this is a test, we are okay with copying locks
23
23
testCases := []struct {
24
- name string
25
- ack types.Acknowledgement
26
- expSuccess bool // indicate if this is a success or failed ack
27
- expPass bool
24
+ name string
25
+ ack types.Acknowledgement
26
+ expValidates bool
27
+ expBytes []byte
28
+ expSuccess bool // indicate if this is a success or failed ack
28
29
}{
29
30
{
30
31
"valid successful ack" ,
31
32
types .NewResultAcknowledgement ([]byte ("success" )),
32
33
true ,
34
+ []byte (`{"result":"c3VjY2Vzcw=="}` ),
33
35
true ,
34
36
},
35
37
{
36
38
"valid failed ack" ,
37
39
types .NewErrorAcknowledgement (fmt .Errorf ("error" )),
38
- false ,
39
40
true ,
41
+ []byte (`{"error":"ABCI code: 1: error handling packet: see events for details"}` ),
42
+ false ,
40
43
},
41
44
{
42
45
"empty successful ack" ,
43
46
types .NewResultAcknowledgement ([]byte {}),
44
- true ,
45
47
false ,
48
+ nil ,
49
+ true ,
46
50
},
47
51
{
48
52
"empty failed ack" ,
49
53
types .NewErrorAcknowledgement (fmt .Errorf (" " )),
50
- false ,
51
54
true ,
55
+ []byte (`{"error":"ABCI code: 1: error handling packet: see events for details"}` ),
56
+ false ,
52
57
},
53
58
{
54
59
"nil response" ,
55
60
types.Acknowledgement {
56
61
Response : nil ,
57
62
},
58
63
false ,
64
+ nil ,
59
65
false ,
60
66
},
61
67
}
@@ -68,18 +74,19 @@ func (suite TypesTestSuite) TestAcknowledgement() { //nolint:govet // this is a
68
74
69
75
err := tc .ack .ValidateBasic ()
70
76
71
- if tc .expPass {
77
+ if tc .expValidates {
72
78
suite .Require ().NoError (err )
79
+
80
+ // expect all valid acks to be able to be marshaled
81
+ suite .NotPanics (func () {
82
+ bz := tc .ack .Acknowledgement ()
83
+ suite .Require ().NotNil (bz )
84
+ suite .Require ().Equal (tc .expBytes , bz )
85
+ })
73
86
} else {
74
87
suite .Require ().Error (err )
75
88
}
76
89
77
- // expect all acks to be able to be marshaled
78
- suite .NotPanics (func () {
79
- bz := tc .ack .Acknowledgement ()
80
- suite .Require ().NotNil (bz )
81
- })
82
-
83
90
suite .Require ().Equal (tc .expSuccess , tc .ack .Success ())
84
91
})
85
92
}
0 commit comments