20TEST(TransactionsDepositPreauthTests, BuilderSettersRoundTrip)
23 auto const [publicKey, secretKey] =
44 builder.setAuthorize(authorizeValue);
45 builder.setUnauthorize(unauthorizeValue);
46 builder.setAuthorizeCredentials(authorizeCredentialsValue);
47 builder.setUnauthorizeCredentials(unauthorizeCredentialsValue);
49 auto tx = builder.build(publicKey, secretKey);
52 EXPECT_TRUE(tx.validate(reason)) << reason;
55 EXPECT_FALSE(tx.getSigningPubKey().empty());
56 EXPECT_TRUE(tx.hasTxnSignature());
59 EXPECT_EQ(tx.getAccount(), accountValue);
60 EXPECT_EQ(tx.getSequence(), sequenceValue);
61 EXPECT_EQ(tx.getFee(), feeValue);
66 auto const& expected = authorizeValue;
67 auto const actualOpt = tx.getAuthorize();
68 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfAuthorize should be present";
70 EXPECT_TRUE(tx.hasAuthorize());
74 auto const& expected = unauthorizeValue;
75 auto const actualOpt = tx.getUnauthorize();
76 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfUnauthorize should be present";
78 EXPECT_TRUE(tx.hasUnauthorize());
82 auto const& expected = authorizeCredentialsValue;
83 auto const actualOpt = tx.getAuthorizeCredentials();
84 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfAuthorizeCredentials should be present";
86 EXPECT_TRUE(tx.hasAuthorizeCredentials());
90 auto const& expected = unauthorizeCredentialsValue;
91 auto const actualOpt = tx.getUnauthorizeCredentials();
92 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfUnauthorizeCredentials should be present";
94 EXPECT_TRUE(tx.hasUnauthorizeCredentials());
101TEST(TransactionsDepositPreauthTests, BuilderFromStTxRoundTrip)
104 auto const [publicKey, secretKey] =
125 initialBuilder.setAuthorize(authorizeValue);
126 initialBuilder.setUnauthorize(unauthorizeValue);
127 initialBuilder.setAuthorizeCredentials(authorizeCredentialsValue);
128 initialBuilder.setUnauthorizeCredentials(unauthorizeCredentialsValue);
130 auto initialTx = initialBuilder.build(publicKey, secretKey);
135 auto rebuiltTx = builderFromTx.
build(publicKey, secretKey);
138 EXPECT_TRUE(rebuiltTx.validate(reason)) << reason;
141 EXPECT_EQ(rebuiltTx.getAccount(), accountValue);
142 EXPECT_EQ(rebuiltTx.getSequence(), sequenceValue);
143 EXPECT_EQ(rebuiltTx.getFee(), feeValue);
148 auto const& expected = authorizeValue;
149 auto const actualOpt = rebuiltTx.getAuthorize();
150 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfAuthorize should be present";
155 auto const& expected = unauthorizeValue;
156 auto const actualOpt = rebuiltTx.getUnauthorize();
157 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfUnauthorize should be present";
162 auto const& expected = authorizeCredentialsValue;
163 auto const actualOpt = rebuiltTx.getAuthorizeCredentials();
164 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfAuthorizeCredentials should be present";
169 auto const& expected = unauthorizeCredentialsValue;
170 auto const actualOpt = rebuiltTx.getUnauthorizeCredentials();
171 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfUnauthorizeCredentials should be present";
206TEST(TransactionsDepositPreauthTests, OptionalFieldsReturnNullopt)
209 auto const [publicKey, secretKey] =
227 auto tx = builder.build(publicKey, secretKey);
230 EXPECT_FALSE(tx.hasAuthorize());
231 EXPECT_FALSE(tx.getAuthorize().has_value());
232 EXPECT_FALSE(tx.hasUnauthorize());
233 EXPECT_FALSE(tx.getUnauthorize().has_value());
234 EXPECT_FALSE(tx.hasAuthorizeCredentials());
235 EXPECT_FALSE(tx.getAuthorizeCredentials().has_value());
236 EXPECT_FALSE(tx.hasUnauthorizeCredentials());
237 EXPECT_FALSE(tx.getUnauthorizeCredentials().has_value());