18
18
import java .util .Collections ;
19
19
import java .util .List ;
20
20
21
- import org .junit .Test ;
21
+ import org .junit .jupiter . api . Test ;
22
22
23
23
import org .web3j .abi .datatypes .DynamicArray ;
24
24
import org .web3j .abi .datatypes .DynamicBytes ;
34
34
import org .web3j .crypto .Hash ;
35
35
import org .web3j .utils .Numeric ;
36
36
37
- import static org .hamcrest .CoreMatchers .is ;
38
- import static org .hamcrest .core .IsEqual .equalTo ;
39
- import static org .junit .Assert .assertThat ;
37
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
40
38
41
39
public class FunctionReturnDecoderTest {
42
40
@@ -48,11 +46,11 @@ public void testSimpleFunctionDecode() {
48
46
Collections .<Type >emptyList (),
49
47
Collections .singletonList (new TypeReference <Uint >() {}));
50
48
51
- assertThat (
49
+ assertEquals (
52
50
FunctionReturnDecoder .decode (
53
51
"0x0000000000000000000000000000000000000000000000000000000000000037" ,
54
52
function .getOutputParameters ()),
55
- equalTo (Collections .singletonList (new Uint (BigInteger .valueOf (55 )))));
53
+ (Collections .singletonList (new Uint (BigInteger .valueOf (55 )))));
56
54
}
57
55
58
56
@ Test
@@ -70,7 +68,7 @@ public void testSimpleFunctionStringResultDecode() {
70
68
+ "6f6e65206d6f72652074696d6500000000000000000000000000000000000000" ,
71
69
function .getOutputParameters ());
72
70
73
- assertThat (utf8Strings .get (0 ).getValue (), is ("one more time" ));
71
+ assertEquals (utf8Strings .get (0 ).getValue (), ("one more time" ));
74
72
}
75
73
76
74
@ Test
@@ -87,7 +85,7 @@ public void testFunctionEmptyStringResultDecode() {
87
85
+ "0000000000000000000000000000000000000000000000000000000000000000" ,
88
86
function .getOutputParameters ());
89
87
90
- assertThat (utf8Strings .get (0 ).getValue (), is ("" ));
88
+ assertEquals (utf8Strings .get (0 ).getValue (), ("" ));
91
89
}
92
90
93
91
@ Test
@@ -98,15 +96,12 @@ public void testMultipleResultFunctionDecode() {
98
96
Collections .<Type >emptyList (),
99
97
Arrays .asList (new TypeReference <Uint >() {}, new TypeReference <Uint >() {}));
100
98
101
- assertThat (
99
+ assertEquals (
102
100
FunctionReturnDecoder .decode (
103
101
"0x0000000000000000000000000000000000000000000000000000000000000037"
104
102
+ "0000000000000000000000000000000000000000000000000000000000000007" ,
105
103
function .getOutputParameters ()),
106
- equalTo (
107
- Arrays .asList (
108
- new Uint (BigInteger .valueOf (55 )),
109
- new Uint (BigInteger .valueOf (7 )))));
104
+ (Arrays .asList (new Uint (BigInteger .valueOf (55 )), new Uint (BigInteger .valueOf (7 )))));
110
105
}
111
106
112
107
@ Test
@@ -121,7 +116,7 @@ public void testDecodeMultipleStringValues() {
121
116
new TypeReference <Utf8String >() {},
122
117
new TypeReference <Utf8String >() {}));
123
118
124
- assertThat (
119
+ assertEquals (
125
120
FunctionReturnDecoder .decode (
126
121
"0x0000000000000000000000000000000000000000000000000000000000000080"
127
122
+ "00000000000000000000000000000000000000000000000000000000000000c0"
@@ -136,10 +131,9 @@ public void testDecodeMultipleStringValues() {
136
131
+ "0000000000000000000000000000000000000000000000000000000000000004"
137
132
+ "6d6e6f3200000000000000000000000000000000000000000000000000000000" ,
138
133
function .getOutputParameters ()),
139
- equalTo (
140
- Arrays .asList (
141
- new Utf8String ("def1" ), new Utf8String ("ghi1" ),
142
- new Utf8String ("jkl1" ), new Utf8String ("mno2" ))));
134
+ (Arrays .asList (
135
+ new Utf8String ("def1" ), new Utf8String ("ghi1" ),
136
+ new Utf8String ("jkl1" ), new Utf8String ("mno2" ))));
143
137
}
144
138
145
139
@ Test
@@ -163,16 +157,16 @@ public void testDecodeStaticArrayValue() {
163
157
new Uint256 (BigInteger .valueOf (55 )), new Uint256 (BigInteger .ONE ));
164
158
165
159
List <Type > expected = Arrays .asList (uint256StaticArray2 , new Uint256 (BigInteger .TEN ));
166
- assertThat (decoded , equalTo (expected ));
160
+ assertEquals (decoded , (expected ));
167
161
}
168
162
169
163
@ Test
170
164
public void testVoidResultFunctionDecode () {
171
165
Function function = new Function ("test" , Collections .emptyList (), Collections .emptyList ());
172
166
173
- assertThat (
167
+ assertEquals (
174
168
FunctionReturnDecoder .decode ("0x" , function .getOutputParameters ()),
175
- is (Collections .emptyList ()));
169
+ (Collections .emptyList ()));
176
170
}
177
171
178
172
@ Test
@@ -183,19 +177,19 @@ public void testEmptyResultFunctionDecode() {
183
177
Collections .emptyList (),
184
178
Collections .singletonList (new TypeReference <Uint >() {}));
185
179
186
- assertThat (
180
+ assertEquals (
187
181
FunctionReturnDecoder .decode ("0x" , function .getOutputParameters ()),
188
- is (Collections .emptyList ()));
182
+ (Collections .emptyList ()));
189
183
}
190
184
191
185
@ Test
192
186
public void testDecodeIndexedUint256Value () {
193
187
Uint256 value = new Uint256 (BigInteger .TEN );
194
188
String encoded = TypeEncoder .encodeNumeric (value );
195
189
196
- assertThat (
190
+ assertEquals (
197
191
FunctionReturnDecoder .decodeIndexedValue (encoded , new TypeReference <Uint256 >() {}),
198
- equalTo (value ));
192
+ (value ));
199
193
}
200
194
201
195
@ Test
@@ -204,29 +198,29 @@ public void testDecodeIndexedStringValue() {
204
198
String encoded = TypeEncoder .encodeString (string );
205
199
String hash = Hash .sha3 (encoded );
206
200
207
- assertThat (
201
+ assertEquals (
208
202
FunctionReturnDecoder .decodeIndexedValue (hash , new TypeReference <Utf8String >() {}),
209
- equalTo (new Bytes32 (Numeric .hexStringToByteArray (hash ))));
203
+ (new Bytes32 (Numeric .hexStringToByteArray (hash ))));
210
204
}
211
205
212
206
@ Test
213
207
public void testDecodeIndexedBytes32Value () {
214
208
String rawInput = "0x1234567890123456789012345678901234567890123456789012345678901234" ;
215
209
byte [] rawInputBytes = Numeric .hexStringToByteArray (rawInput );
216
210
217
- assertThat (
211
+ assertEquals (
218
212
FunctionReturnDecoder .decodeIndexedValue (rawInput , new TypeReference <Bytes32 >() {}),
219
- equalTo (new Bytes32 (rawInputBytes )));
213
+ (new Bytes32 (rawInputBytes )));
220
214
}
221
215
222
216
@ Test
223
217
public void testDecodeIndexedBytes16Value () {
224
218
String rawInput = "0x1234567890123456789012345678901200000000000000000000000000000000" ;
225
219
byte [] rawInputBytes = Numeric .hexStringToByteArray (rawInput .substring (0 , 34 ));
226
220
227
- assertThat (
221
+ assertEquals (
228
222
FunctionReturnDecoder .decodeIndexedValue (rawInput , new TypeReference <Bytes16 >() {}),
229
- equalTo (new Bytes16 (rawInputBytes )));
223
+ (new Bytes16 (rawInputBytes )));
230
224
}
231
225
232
226
@ Test
@@ -235,10 +229,10 @@ public void testDecodeIndexedDynamicBytesValue() {
235
229
String encoded = TypeEncoder .encodeDynamicBytes (bytes );
236
230
String hash = Hash .sha3 (encoded );
237
231
238
- assertThat (
232
+ assertEquals (
239
233
FunctionReturnDecoder .decodeIndexedValue (
240
234
hash , new TypeReference <DynamicBytes >() {}),
241
- equalTo (new Bytes32 (Numeric .hexStringToByteArray (hash ))));
235
+ (new Bytes32 (Numeric .hexStringToByteArray (hash ))));
242
236
}
243
237
244
238
@ Test
@@ -249,9 +243,9 @@ public void testDecodeIndexedDynamicArrayValue() {
249
243
String encoded = TypeEncoder .encodeDynamicArray (array );
250
244
String hash = Hash .sha3 (encoded );
251
245
252
- assertThat (
246
+ assertEquals (
253
247
FunctionReturnDecoder .decodeIndexedValue (
254
248
hash , new TypeReference <DynamicArray >() {}),
255
- equalTo (new Bytes32 (Numeric .hexStringToByteArray (hash ))));
249
+ (new Bytes32 (Numeric .hexStringToByteArray (hash ))));
256
250
}
257
251
}
0 commit comments