@@ -45,7 +45,8 @@ func TestWSConn_HandleConn(t *testing.T) {
45
45
res , err = wsconn .initStorageChangeListener (1 , nil )
46
46
require .Nil (t , res )
47
47
require .Len (t , wsconn .Subscriptions , 0 )
48
- require .EqualError (t , err , "unknown parameter type" )
48
+ require .ErrorIs (t , err , errUnexpectedType )
49
+ require .EqualError (t , err , "unexpected type: <nil>, expected type []interface{}" )
49
50
50
51
res , err = wsconn .initStorageChangeListener (2 , []interface {}{})
51
52
require .NotNil (t , res )
@@ -55,33 +56,35 @@ func TestWSConn_HandleConn(t *testing.T) {
55
56
require .NoError (t , err )
56
57
require .Equal (t , []byte (`{"jsonrpc":"2.0","result":1,"id":2}` + "\n " ), msg )
57
58
58
- res , err = wsconn .initStorageChangeListener (3 , []interface {}{"0x26aa" })
59
+ var testFilter0 = []interface {}{"0x26aa" }
60
+ res , err = wsconn .initStorageChangeListener (3 , testFilter0 )
59
61
require .NotNil (t , res )
60
62
require .NoError (t , err )
61
63
require .Len (t , wsconn .Subscriptions , 2 )
62
64
_ , msg , err = c .ReadMessage ()
63
65
require .NoError (t , err )
64
66
require .Equal (t , []byte (`{"jsonrpc":"2.0","result":2,"id":3}` + "\n " ), msg )
65
67
66
- var testFilters = []interface {}{}
67
- var testFilter1 = []interface {}{"0x26aa" , "0x26a1" }
68
- res , err = wsconn .initStorageChangeListener (4 , append (testFilters , testFilter1 ))
69
- require .NotNil (t , res )
68
+ var testFilter1 = []interface {}{[]interface {}{"0x26aa" , "0x26a1" }}
69
+ res , err = wsconn .initStorageChangeListener (4 , testFilter1 )
70
70
require .NoError (t , err )
71
+ require .NotNil (t , res )
71
72
require .Len (t , wsconn .Subscriptions , 3 )
72
73
_ , msg , err = c .ReadMessage ()
73
74
require .NoError (t , err )
74
75
require .Equal (t , []byte (`{"jsonrpc":"2.0","result":3,"id":4}` + "\n " ), msg )
75
76
76
- var testFilterWrongType = []interface {}{"0x26aa" , 1 }
77
- res , err = wsconn .initStorageChangeListener (5 , append (testFilters , testFilterWrongType ))
78
- require .EqualError (t , err , "unknown parameter type" )
77
+ var testFilterWrongType = []interface {}{[]int {123 }}
78
+ res , err = wsconn .initStorageChangeListener (5 , testFilterWrongType )
79
+ require .ErrorIs (t , err , errUnexpectedType )
80
+ require .EqualError (t , err , "unexpected type: []int, expected type string, []string, []interface{}" )
79
81
require .Nil (t , res )
80
82
// keep subscriptions len == 3, no additions was made
81
83
require .Len (t , wsconn .Subscriptions , 3 )
82
84
83
85
res , err = wsconn .initStorageChangeListener (6 , []interface {}{1 })
84
- require .EqualError (t , err , "unknown parameter type" )
86
+ require .ErrorIs (t , err , errUnexpectedType )
87
+ require .EqualError (t , err , "unexpected type: int, expected type string, []string, []interface{}" )
85
88
require .Nil (t , res )
86
89
require .Len (t , wsconn .Subscriptions , 3 )
87
90
@@ -207,7 +210,7 @@ func TestWSConn_HandleConn(t *testing.T) {
207
210
wsconn .CoreAPI = modules .NewMockCoreAPI ()
208
211
wsconn .BlockAPI = nil
209
212
wsconn .TxStateAPI = modules .NewMockTransactionStateAPI ()
210
- listner , err := wsconn .initExtrinsicWatch (0 , []interface {} {"NotHex" })
213
+ listner , err := wsconn .initExtrinsicWatch (0 , []string {"NotHex" })
211
214
require .EqualError (t , err , "could not byteify non 0x prefixed string: NotHex" )
212
215
require .Nil (t , listner )
213
216
0 commit comments