20TEST(TransactionsPaymentChannelClaimTests, BuilderSettersRoundTrip)
23 auto const [publicKey, secretKey] =
47 builder.setAmount(amountValue);
48 builder.setBalance(balanceValue);
49 builder.setSignature(signatureValue);
50 builder.setPublicKey(publicKeyValue);
51 builder.setCredentialIDs(credentialIDsValue);
53 auto tx = builder.build(publicKey, secretKey);
56 EXPECT_TRUE(tx.validate(reason)) << reason;
59 EXPECT_FALSE(tx.getSigningPubKey().empty());
60 EXPECT_TRUE(tx.hasTxnSignature());
63 EXPECT_EQ(tx.getAccount(), accountValue);
64 EXPECT_EQ(tx.getSequence(), sequenceValue);
65 EXPECT_EQ(tx.getFee(), feeValue);
69 auto const& expected = channelValue;
70 auto const actual = tx.getChannel();
76 auto const& expected = amountValue;
77 auto const actualOpt = tx.getAmount();
78 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfAmount should be present";
80 EXPECT_TRUE(tx.hasAmount());
84 auto const& expected = balanceValue;
85 auto const actualOpt = tx.getBalance();
86 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfBalance should be present";
88 EXPECT_TRUE(tx.hasBalance());
92 auto const& expected = signatureValue;
93 auto const actualOpt = tx.getSignature();
94 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfSignature should be present";
96 EXPECT_TRUE(tx.hasSignature());
100 auto const& expected = publicKeyValue;
101 auto const actualOpt = tx.getPublicKey();
102 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfPublicKey should be present";
104 EXPECT_TRUE(tx.hasPublicKey());
108 auto const& expected = credentialIDsValue;
109 auto const actualOpt = tx.getCredentialIDs();
110 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfCredentialIDs should be present";
112 EXPECT_TRUE(tx.hasCredentialIDs());
119TEST(TransactionsPaymentChannelClaimTests, BuilderFromStTxRoundTrip)
122 auto const [publicKey, secretKey] =
146 initialBuilder.setAmount(amountValue);
147 initialBuilder.setBalance(balanceValue);
148 initialBuilder.setSignature(signatureValue);
149 initialBuilder.setPublicKey(publicKeyValue);
150 initialBuilder.setCredentialIDs(credentialIDsValue);
152 auto initialTx = initialBuilder.build(publicKey, secretKey);
157 auto rebuiltTx = builderFromTx.
build(publicKey, secretKey);
160 EXPECT_TRUE(rebuiltTx.validate(reason)) << reason;
163 EXPECT_EQ(rebuiltTx.getAccount(), accountValue);
164 EXPECT_EQ(rebuiltTx.getSequence(), sequenceValue);
165 EXPECT_EQ(rebuiltTx.getFee(), feeValue);
169 auto const& expected = channelValue;
170 auto const actual = rebuiltTx.getChannel();
176 auto const& expected = amountValue;
177 auto const actualOpt = rebuiltTx.getAmount();
178 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfAmount should be present";
183 auto const& expected = balanceValue;
184 auto const actualOpt = rebuiltTx.getBalance();
185 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfBalance should be present";
190 auto const& expected = signatureValue;
191 auto const actualOpt = rebuiltTx.getSignature();
192 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfSignature should be present";
197 auto const& expected = publicKeyValue;
198 auto const actualOpt = rebuiltTx.getPublicKey();
199 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfPublicKey should be present";
204 auto const& expected = credentialIDsValue;
205 auto const actualOpt = rebuiltTx.getCredentialIDs();
206 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfCredentialIDs should be present";
241TEST(TransactionsPaymentChannelClaimTests, OptionalFieldsReturnNullopt)
244 auto const [publicKey, secretKey] =
264 auto tx = builder.build(publicKey, secretKey);
267 EXPECT_FALSE(tx.hasAmount());
268 EXPECT_FALSE(tx.getAmount().has_value());
269 EXPECT_FALSE(tx.hasBalance());
270 EXPECT_FALSE(tx.getBalance().has_value());
271 EXPECT_FALSE(tx.hasSignature());
272 EXPECT_FALSE(tx.getSignature().has_value());
273 EXPECT_FALSE(tx.hasPublicKey());
274 EXPECT_FALSE(tx.getPublicKey().has_value());
275 EXPECT_FALSE(tx.hasCredentialIDs());
276 EXPECT_FALSE(tx.getCredentialIDs().has_value());