20 #include <ripple/basics/StringUtilities.h>
21 #include <ripple/protocol/Feature.h>
22 #include <ripple/protocol/jss.h>
24 #include <test/jtx/WSClient.h>
26 #include <ripple/resource/Charge.h>
27 #include <ripple/resource/Fees.h>
28 #include <ripple/rpc/GRPCHandlers.h>
29 #include <test/rpc/GRPCTestClientBase.h>
40 org::xrpl::rpc::v1::SubmitTransactionRequest
request;
41 org::xrpl::rpc::v1::SubmitTransactionResponse
reply;
61 const static int fund = 10000;
67 testcase(
"fill test data");
71 auto const alice =
Account(
"alice");
72 auto const bob =
Account(
"bob");
81 reinterpret_cast<char const*
>(blob->data()), blob->
size()};
89 jrequestXrp[jss::tx_json] =
91 Json::Value jreply_xrp = wsc->invoke(
"sign", jrequestXrp);
93 if (!BEAST_EXPECT(jreply_xrp.
isMember(jss::result)))
95 if (!BEAST_EXPECT(jreply_xrp[jss::result].isMember(jss::tx_blob)))
98 toBinary(jreply_xrp[jss::result][jss::tx_blob].asString());
99 if (!BEAST_EXPECT(jreply_xrp[jss::result].isMember(jss::tx_json)))
102 jreply_xrp[jss::result][jss::tx_json].isMember(jss::hash)))
105 jreply_xrp[jss::result][jss::tx_json][jss::hash].asString());
110 jrequestUsd[jss::tx_json] =
112 Json::Value jreply_usd = wsc->invoke(
"sign", jrequestUsd);
114 if (!BEAST_EXPECT(jreply_usd.
isMember(jss::result)))
116 if (!BEAST_EXPECT(jreply_usd[jss::result].isMember(jss::tx_blob)))
119 toBinary(jreply_usd[jss::result][jss::tx_blob].asString());
120 if (!BEAST_EXPECT(jreply_usd[jss::result].isMember(jss::tx_json)))
123 jreply_usd[jss::result][jss::tx_json].isMember(jss::hash)))
126 jreply_usd[jss::result][jss::tx_json][jss::hash].asString());
133 testcase(
"Submit good blobs, XRP, USD, and same transaction twice");
138 Env env(*
this, std::move(config));
139 auto const alice =
Account(
"alice");
140 auto const bob =
Account(
"bob");
145 auto getClient = [&grpcPort]() {
return SubmitClient(grpcPort); };
149 auto client = getClient();
151 client.SubmitTransaction();
152 if (!BEAST_EXPECT(client.status.ok()))
156 BEAST_EXPECT(client.reply.engine_result().result() ==
"tesSUCCESS");
157 BEAST_EXPECT(client.reply.engine_result_code() == 0);
162 auto client = getClient();
164 client.SubmitTransaction();
165 if (!BEAST_EXPECT(client.status.ok()))
169 BEAST_EXPECT(client.reply.engine_result().result() ==
"tesSUCCESS");
170 BEAST_EXPECT(client.reply.engine_result_code() == 0);
175 auto client = getClient();
177 client.SubmitTransaction();
178 if (!BEAST_EXPECT(client.status.ok()))
183 client.reply.engine_result().result() ==
"tefPAST_SEQ");
184 BEAST_EXPECT(client.reply.engine_result_code() == -190);
191 testcase(
"Submit error, bad blob, no account");
196 Env env(*
this, std::move(config));
198 auto getClient = [&grpcPort]() {
return SubmitClient(grpcPort); };
202 auto client = getClient();
203 client.request.set_signed_transaction(
"deadbeef");
204 client.SubmitTransaction();
205 BEAST_EXPECT(!client.status.ok());
209 auto client = getClient();
211 std::reverse(xrpTxBlobCopy.begin(), xrpTxBlobCopy.end());
212 client.request.set_signed_transaction(xrpTxBlobCopy);
213 client.SubmitTransaction();
214 BEAST_EXPECT(!client.status.ok());
218 auto client = getClient();
220 client.SubmitTransaction();
221 if (!BEAST_EXPECT(client.status.ok()))
226 client.reply.engine_result().result() ==
"terNO_ACCOUNT");
227 BEAST_EXPECT(client.reply.engine_result_code() == -96);
234 testcase(
"Submit good blobs but insufficient funds");
239 Env env(*
this, std::move(config));
241 auto const alice =
Account(
"alice");
242 auto const bob =
Account(
"bob");
253 if (!BEAST_EXPECT(client.
status.ok()))
258 client.
reply.engine_result().result() ==
"tecUNFUNDED_PAYMENT");
259 BEAST_EXPECT(client.
reply.engine_result_code() == 104);