@@ -60,6 +60,13 @@ constexpr auto kINDEX1 = "1B8590C01B0006EDFA9ED60296DD052DC5E90F99659B25014D08E1
6060constexpr auto kINDEX2 = " E6DBAFC99223B42257915A63DFC6B0C032D4070F9A574B255AD97466726FC321" ;
6161constexpr auto kTXN_ID = " E3FE6EA3D48F0C2B639448020EA4F03D4F4F8FFDB243A852A0F59177921B4879" ;
6262
63+ struct ParameterTestBundle {
64+ std::string testName;
65+ std::string testJson;
66+ std::string expectedError;
67+ std::string expectedErrorMessage;
68+ std::uint32_t apiVersion = 1u ;
69+ };
6370} // namespace
6471
6572struct RPCGatewayBalancesHandlerTest : HandlerBaseTest {
@@ -69,21 +76,15 @@ struct RPCGatewayBalancesHandlerTest : HandlerBaseTest {
6976 }
7077};
7178
72- struct ParameterTestBundle {
73- std::string testName;
74- std::string testJson;
75- std::string expectedError;
76- std::string expectedErrorMessage;
77- };
78-
7979struct ParameterTest : public RPCGatewayBalancesHandlerTest , public WithParamInterface <ParameterTestBundle> {};
8080
8181TEST_P (ParameterTest, CheckError)
8282{
8383 auto bundle = GetParam ();
8484 auto const handler = AnyHandler{GatewayBalancesHandler{backend_}};
8585 runSpawn ([&](auto yield) {
86- auto const output = handler.process (json::parse (bundle.testJson ), Context{yield});
86+ auto const output =
87+ handler.process (json::parse (bundle.testJson ), Context{.yield = yield, .apiVersion = bundle.apiVersion });
8788 ASSERT_FALSE (output);
8889 auto const err = rpc::makeError (output.result .error ());
8990 EXPECT_EQ (err.at (" error" ).as_string (), bundle.expectedError );
@@ -155,53 +156,105 @@ generateParameterTestBundles()
155156 .expectedErrorMessage = " ledger_hashNotString"
156157 },
157158 ParameterTestBundle{
158- .testName = " WalletsNotStringOrArray " ,
159+ .testName = " WalletsNotStringOrArrayV1 " ,
159160 .testJson = fmt::format (
160161 R"( {{
161162 "account": "{}",
162163 "hotwallet": 12
163164 }})" ,
164165 kACCOUNT
165166 ),
166- .expectedError = " invalidParams " ,
167+ .expectedError = " invalidHotWallet " ,
167168 .expectedErrorMessage = " hotwalletNotStringOrArray"
168169 },
169170 ParameterTestBundle{
170- .testName = " WalletsNotStringAccount " ,
171+ .testName = " WalletsNotStringAccountV1 " ,
171172 .testJson = fmt::format (
172173 R"( {{
173174 "account": "{}",
174175 "hotwallet": [12]
175176 }})" ,
176177 kACCOUNT
177178 ),
178- .expectedError = " invalidParams " ,
179+ .expectedError = " invalidHotWallet " ,
179180 .expectedErrorMessage = " hotwalletMalformed"
180181 },
181182 ParameterTestBundle{
182- .testName = " WalletsInvalidAccount " ,
183+ .testName = " WalletsInvalidAccountV1 " ,
183184 .testJson = fmt::format (
184185 R"( {{
185186 "account": "{}",
186187 "hotwallet": ["12"]
187188 }})" ,
188189 kACCOUNT
189190 ),
190- .expectedError = " invalidParams " ,
191+ .expectedError = " invalidHotWallet " ,
191192 .expectedErrorMessage = " hotwalletMalformed"
192193 },
193194 ParameterTestBundle{
194- .testName = " WalletInvalidAccount " ,
195+ .testName = " WalletInvalidAccountV1 " ,
195196 .testJson = fmt::format (
196197 R"( {{
197198 "account": "{}",
198199 "hotwallet": "12"
199200 }})" ,
200201 kACCOUNT
201202 ),
202- .expectedError = " invalidParams " ,
203+ .expectedError = " invalidHotWallet " ,
203204 .expectedErrorMessage = " hotwalletMalformed"
204205 },
206+ ParameterTestBundle{
207+ .testName = " WalletsNotStringOrArrayV2" ,
208+ .testJson = fmt::format (
209+ R"( {{
210+ "account": "{}",
211+ "hotwallet": 12
212+ }})" ,
213+ kACCOUNT
214+ ),
215+ .expectedError = " invalidParams" ,
216+ .expectedErrorMessage = " hotwalletNotStringOrArray" ,
217+ .apiVersion = 2u
218+ },
219+ ParameterTestBundle{
220+ .testName = " WalletsNotStringAccountV2" ,
221+ .testJson = fmt::format (
222+ R"( {{
223+ "account": "{}",
224+ "hotwallet": [12]
225+ }})" ,
226+ kACCOUNT
227+ ),
228+ .expectedError = " invalidParams" ,
229+ .expectedErrorMessage = " hotwalletMalformed" ,
230+ .apiVersion = 2u
231+ },
232+ ParameterTestBundle{
233+ .testName = " WalletsInvalidAccountV2" ,
234+ .testJson = fmt::format (
235+ R"( {{
236+ "account": "{}",
237+ "hotwallet": ["12"]
238+ }})" ,
239+ kACCOUNT
240+ ),
241+ .expectedError = " invalidParams" ,
242+ .expectedErrorMessage = " hotwalletMalformed" ,
243+ .apiVersion = 2u
244+ },
245+ ParameterTestBundle{
246+ .testName = " WalletInvalidAccountV2" ,
247+ .testJson = fmt::format (
248+ R"( {{
249+ "account": "{}",
250+ "hotwallet": "12"
251+ }})" ,
252+ kACCOUNT
253+ ),
254+ .expectedError = " invalidParams" ,
255+ .expectedErrorMessage = " hotwalletMalformed" ,
256+ .apiVersion = 2u
257+ },
205258 };
206259}
207260
0 commit comments