File tree Expand file tree Collapse file tree 4 files changed +338
-11
lines changed Expand file tree Collapse file tree 4 files changed +338
-11
lines changed Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ type CallbackContext struct {
155
155
156
156
// Callback function types
157
157
type AcquireFunc func (CallbackContext , AcquireTarget , bool ) error
158
- type QueryFunc func (CallbackContext , any ) (any , error )
158
+ type QueryFunc func (CallbackContext , QueryWrapper ) (any , error )
159
159
type ReleaseFunc func (CallbackContext ) error
160
160
161
161
// New returns a new LocalStateQuery object
Original file line number Diff line number Diff line change @@ -154,15 +154,17 @@ func NewMsgFailure(failure uint8) *MsgFailure {
154
154
155
155
type MsgQuery struct {
156
156
protocol.MessageBase
157
- Query interface {}
157
+ Query QueryWrapper
158
158
}
159
159
160
160
func NewMsgQuery (query interface {}) * MsgQuery {
161
161
m := & MsgQuery {
162
162
MessageBase : protocol.MessageBase {
163
163
MessageType : MessageTypeQuery ,
164
164
},
165
- Query : query ,
165
+ Query : QueryWrapper {
166
+ Query : query ,
167
+ },
166
168
}
167
169
return m
168
170
}
Original file line number Diff line number Diff line change @@ -16,11 +16,12 @@ package localstatequery
16
16
17
17
import (
18
18
"encoding/hex"
19
+ "reflect"
20
+ "testing"
21
+
19
22
"github.com/blinklabs-io/gouroboros/cbor"
20
23
"github.com/blinklabs-io/gouroboros/protocol"
21
24
"github.com/blinklabs-io/gouroboros/protocol/common"
22
- "reflect"
23
- "testing"
24
25
)
25
26
26
27
type testDefinition struct {
@@ -49,12 +50,12 @@ var tests = []testDefinition{
49
50
CborHex : "8203820082028101" ,
50
51
Message : NewMsgQuery (
51
52
// Current era hard-fork query
52
- [] interface {} {
53
- uint64 ( 0 ),
54
- [] interface {} {
55
- uint64 ( 2 ),
56
- [] interface {}{
57
- uint64 ( 1 ) ,
53
+ & BlockQuery {
54
+ Query : & HardForkQuery {
55
+ Query : & HardForkCurrentEraQuery {
56
+ simpleQueryBase {
57
+ Type : QueryTypeHardForkCurrentEra ,
58
+ } ,
58
59
},
59
60
},
60
61
},
@@ -105,6 +106,9 @@ func TestDecode(t *testing.T) {
105
106
}
106
107
// Set the raw CBOR so the comparison should succeed
107
108
test .Message .SetCbor (cborData )
109
+ if m , ok := msg .(* MsgQuery ); ok {
110
+ m .Query .SetCbor (nil )
111
+ }
108
112
if ! reflect .DeepEqual (msg , test .Message ) {
109
113
t .Fatalf (
110
114
"CBOR did not decode to expected message object\n got: %#v\n wanted: %#v" ,
You can’t perform that action at this time.
0 commit comments