20TEST(TransactionsEscrowFinishTests, BuilderSettersRoundTrip)
23 auto const [publicKey, secretKey] =
47 builder.setFulfillment(fulfillmentValue);
48 builder.setCondition(conditionValue);
49 builder.setCredentialIDs(credentialIDsValue);
51 auto tx = builder.build(publicKey, secretKey);
54 EXPECT_TRUE(tx.validate(reason)) << reason;
57 EXPECT_FALSE(tx.getSigningPubKey().empty());
58 EXPECT_TRUE(tx.hasTxnSignature());
61 EXPECT_EQ(tx.getAccount(), accountValue);
62 EXPECT_EQ(tx.getSequence(), sequenceValue);
63 EXPECT_EQ(tx.getFee(), feeValue);
67 auto const& expected = ownerValue;
68 auto const actual = tx.getOwner();
73 auto const& expected = offerSequenceValue;
74 auto const actual = tx.getOfferSequence();
80 auto const& expected = fulfillmentValue;
81 auto const actualOpt = tx.getFulfillment();
82 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfFulfillment should be present";
84 EXPECT_TRUE(tx.hasFulfillment());
88 auto const& expected = conditionValue;
89 auto const actualOpt = tx.getCondition();
90 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfCondition should be present";
92 EXPECT_TRUE(tx.hasCondition());
96 auto const& expected = credentialIDsValue;
97 auto const actualOpt = tx.getCredentialIDs();
98 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfCredentialIDs should be present";
100 EXPECT_TRUE(tx.hasCredentialIDs());
107TEST(TransactionsEscrowFinishTests, BuilderFromStTxRoundTrip)
110 auto const [publicKey, secretKey] =
134 initialBuilder.setFulfillment(fulfillmentValue);
135 initialBuilder.setCondition(conditionValue);
136 initialBuilder.setCredentialIDs(credentialIDsValue);
138 auto initialTx = initialBuilder.build(publicKey, secretKey);
143 auto rebuiltTx = builderFromTx.
build(publicKey, secretKey);
146 EXPECT_TRUE(rebuiltTx.validate(reason)) << reason;
149 EXPECT_EQ(rebuiltTx.getAccount(), accountValue);
150 EXPECT_EQ(rebuiltTx.getSequence(), sequenceValue);
151 EXPECT_EQ(rebuiltTx.getFee(), feeValue);
155 auto const& expected = ownerValue;
156 auto const actual = rebuiltTx.getOwner();
161 auto const& expected = offerSequenceValue;
162 auto const actual = rebuiltTx.getOfferSequence();
168 auto const& expected = fulfillmentValue;
169 auto const actualOpt = rebuiltTx.getFulfillment();
170 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfFulfillment should be present";
175 auto const& expected = conditionValue;
176 auto const actualOpt = rebuiltTx.getCondition();
177 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfCondition should be present";
182 auto const& expected = credentialIDsValue;
183 auto const actualOpt = rebuiltTx.getCredentialIDs();
184 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfCredentialIDs should be present";
219TEST(TransactionsEscrowFinishTests, OptionalFieldsReturnNullopt)
222 auto const [publicKey, secretKey] =
244 auto tx = builder.build(publicKey, secretKey);
247 EXPECT_FALSE(tx.hasFulfillment());
248 EXPECT_FALSE(tx.getFulfillment().has_value());
249 EXPECT_FALSE(tx.hasCondition());
250 EXPECT_FALSE(tx.getCondition().has_value());
251 EXPECT_FALSE(tx.hasCredentialIDs());
252 EXPECT_FALSE(tx.getCredentialIDs().has_value());