20TEST(TransactionsConfidentialMPTConvertTests, BuilderSettersRoundTrip)
23 auto const [publicKey, secretKey] =
43 mPTokenIssuanceIDValue,
45 holderEncryptedAmountValue,
46 issuerEncryptedAmountValue,
57 auto tx = builder.
build(publicKey, secretKey);
60 EXPECT_TRUE(tx.validate(reason)) << reason;
63 EXPECT_FALSE(tx.getSigningPubKey().empty());
64 EXPECT_TRUE(tx.hasTxnSignature());
67 EXPECT_EQ(tx.getAccount(), accountValue);
68 EXPECT_EQ(tx.getSequence(), sequenceValue);
69 EXPECT_EQ(tx.getFee(), feeValue);
73 auto const& expected = mPTokenIssuanceIDValue;
74 auto const actual = tx.getMPTokenIssuanceID();
79 auto const& expected = mPTAmountValue;
80 auto const actual = tx.getMPTAmount();
85 auto const& expected = holderEncryptedAmountValue;
86 auto const actual = tx.getHolderEncryptedAmount();
91 auto const& expected = issuerEncryptedAmountValue;
92 auto const actual = tx.getIssuerEncryptedAmount();
97 auto const& expected = blindingFactorValue;
98 auto const actual = tx.getBlindingFactor();
104 auto const& expected = holderEncryptionKeyValue;
105 auto const actualOpt = tx.getHolderEncryptionKey();
106 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfHolderEncryptionKey should be present";
108 EXPECT_TRUE(tx.hasHolderEncryptionKey());
112 auto const& expected = auditorEncryptedAmountValue;
113 auto const actualOpt = tx.getAuditorEncryptedAmount();
114 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfAuditorEncryptedAmount should be present";
116 EXPECT_TRUE(tx.hasAuditorEncryptedAmount());
120 auto const& expected = zKProofValue;
121 auto const actualOpt = tx.getZKProof();
122 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfZKProof should be present";
124 EXPECT_TRUE(tx.hasZKProof());
131TEST(TransactionsConfidentialMPTConvertTests, BuilderFromStTxRoundTrip)
134 auto const [publicKey, secretKey] =
148 auto const auditorEncryptedAmountValue =
canonical_VL();
155 mPTokenIssuanceIDValue,
157 holderEncryptedAmountValue,
158 issuerEncryptedAmountValue,
168 auto initialTx = initialBuilder.
build(publicKey, secretKey);
173 auto rebuiltTx = builderFromTx.
build(publicKey, secretKey);
176 EXPECT_TRUE(rebuiltTx.validate(reason)) << reason;
179 EXPECT_EQ(rebuiltTx.getAccount(), accountValue);
180 EXPECT_EQ(rebuiltTx.getSequence(), sequenceValue);
181 EXPECT_EQ(rebuiltTx.getFee(), feeValue);
185 auto const& expected = mPTokenIssuanceIDValue;
186 auto const actual = rebuiltTx.getMPTokenIssuanceID();
191 auto const& expected = mPTAmountValue;
192 auto const actual = rebuiltTx.getMPTAmount();
197 auto const& expected = holderEncryptedAmountValue;
198 auto const actual = rebuiltTx.getHolderEncryptedAmount();
203 auto const& expected = issuerEncryptedAmountValue;
204 auto const actual = rebuiltTx.getIssuerEncryptedAmount();
209 auto const& expected = blindingFactorValue;
210 auto const actual = rebuiltTx.getBlindingFactor();
216 auto const& expected = holderEncryptionKeyValue;
217 auto const actualOpt = rebuiltTx.getHolderEncryptionKey();
218 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfHolderEncryptionKey should be present";
223 auto const& expected = auditorEncryptedAmountValue;
224 auto const actualOpt = rebuiltTx.getAuditorEncryptedAmount();
225 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfAuditorEncryptedAmount should be present";
230 auto const& expected = zKProofValue;
231 auto const actualOpt = rebuiltTx.getZKProof();
232 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfZKProof should be present";
267TEST(TransactionsConfidentialMPTConvertTests, OptionalFieldsReturnNullopt)
270 auto const [publicKey, secretKey] =
287 mPTokenIssuanceIDValue,
289 holderEncryptedAmountValue,
290 issuerEncryptedAmountValue,
298 auto tx = builder.
build(publicKey, secretKey);
301 EXPECT_FALSE(tx.hasHolderEncryptionKey());
302 EXPECT_FALSE(tx.getHolderEncryptionKey().has_value());
303 EXPECT_FALSE(tx.hasAuditorEncryptedAmount());
304 EXPECT_FALSE(tx.getAuditorEncryptedAmount().has_value());
305 EXPECT_FALSE(tx.hasZKProof());
306 EXPECT_FALSE(tx.getZKProof().has_value());