Skip to content

Commit d296f98

Browse files
fix comments
1 parent 98a207f commit d296f98

File tree

4 files changed

+52
-61
lines changed

4 files changed

+52
-61
lines changed

src/test/app/ConfidentialTransfer_test.cpp

Lines changed: 36 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -429,64 +429,55 @@ class ConfidentialTransfer_test : public beast::unit_test::suite
429429
.auditorPubKey = mptAlice.getPubKey(alice),
430430
.err = temMALFORMED});
431431

432-
// Cannot set Holder and Keys in the same transaction
432+
// Cannot set Holder and issuer Keys in the same transaction
433433
mptAlice.set(
434434
{.account = alice,
435435
.holder = bob,
436436
.issuerPubKey = mptAlice.getPubKey(alice),
437437
.err = temMALFORMED});
438-
}
439-
440-
// issuance has disabled confidential transfer
441-
{
442-
Env env{*this, features};
443-
Account const alice("alice");
444-
Account const bob("bob");
445-
MPTTester mptAlice(env, alice, {.holders = {bob}});
446438

447-
// no tfMPTCanPrivacy flag enabled
448-
mptAlice.create(
449-
{.ownerCount = 1, .flags = tfMPTCanTransfer | tfMPTCanLock});
450-
451-
mptAlice.authorize({.account = bob});
452-
mptAlice.pay(alice, bob, 100);
439+
// Cannot set Holder and auditor Keys in the same transaction
440+
mptAlice.set(
441+
{.account = alice,
442+
.holder = bob,
443+
.auditorPubKey = mptAlice.getPubKey(alice),
444+
.err = temMALFORMED});
453445

454-
mptAlice.generateKeyPair(alice);
455-
mptAlice.generateKeyPair(bob);
446+
// Cannot set self as holder
447+
mptAlice.set(
448+
{.account = alice, .holder = alice, .err = temMALFORMED});
456449

450+
// Cannot Lock and Unlock simultaneously
457451
mptAlice.set(
458452
{.account = alice,
459-
.issuerPubKey = mptAlice.getPubKey(alice),
460-
.err = tecNO_PERMISSION});
453+
.holder = bob,
454+
.flags = tfMPTLock | tfMPTUnlock,
455+
.err = temINVALID_FLAG});
456+
457+
// Transaction does nothing
458+
mptAlice.set({.account = alice, .err = temMALFORMED});
461459
}
462460

463-
// issuer sets public key and then sets auditor public key
461+
// issuance has disabled confidential transfer
464462
{
465463
Env env{*this, features};
466464
Account const alice("alice");
467465
Account const bob("bob");
468-
Account const auditor("auditor");
469-
MPTTester mptAlice(
470-
env, alice, {.holders = {bob}, .auditor = auditor});
466+
MPTTester mptAlice(env, alice, {.holders = {bob}});
471467

468+
// no tfMPTCanPrivacy flag enabled
472469
mptAlice.create(
473-
{.ownerCount = 1,
474-
.flags = tfMPTCanTransfer | tfMPTCanLock | tfMPTCanPrivacy});
470+
{.ownerCount = 1, .flags = tfMPTCanTransfer | tfMPTCanLock});
475471

476472
mptAlice.authorize({.account = bob});
477473
mptAlice.pay(alice, bob, 100);
478474

479475
mptAlice.generateKeyPair(alice);
480476
mptAlice.generateKeyPair(bob);
481-
mptAlice.generateKeyPair(auditor);
482-
483-
mptAlice.set(
484-
{.account = alice, .issuerPubKey = mptAlice.getPubKey(alice)});
485477

486478
mptAlice.set(
487479
{.account = alice,
488480
.issuerPubKey = mptAlice.getPubKey(alice),
489-
.auditorPubKey = mptAlice.getPubKey(auditor),
490481
.err = tecNO_PERMISSION});
491482
}
492483
}
@@ -1246,7 +1237,6 @@ class ConfidentialTransfer_test : public beast::unit_test::suite
12461237
.issuerEncryptedAmt =
12471238
Buffer(ripple::ecGamalEncryptedTotalLength),
12481239
.err = temBAD_CIPHERTEXT});
1249-
12501240
// dest encrypted amount wrong length
12511241
mptAlice.send(
12521242
{.account = bob,
@@ -1258,7 +1248,6 @@ class ConfidentialTransfer_test : public beast::unit_test::suite
12581248
.issuerEncryptedAmt =
12591249
Buffer(ripple::ecGamalEncryptedTotalLength),
12601250
.err = temBAD_CIPHERTEXT});
1261-
12621251
// issuer encrypted amount wrong length
12631252
mptAlice.send(
12641253
{.account = bob,
@@ -1272,7 +1261,6 @@ class ConfidentialTransfer_test : public beast::unit_test::suite
12721261
.err = temBAD_CIPHERTEXT});
12731262

12741263
// auto const ciphertextHex = generatePlaceholderCiphertext();
1275-
12761264
// sender encrypted amount malformed
12771265
mptAlice.send(
12781266
{.account = bob,
@@ -1281,7 +1269,6 @@ class ConfidentialTransfer_test : public beast::unit_test::suite
12811269
.senderEncryptedAmt =
12821270
Buffer(ripple::ecGamalEncryptedTotalLength),
12831271
.err = temBAD_CIPHERTEXT});
1284-
12851272
// dest encrypted amount malformed
12861273
mptAlice.send(
12871274
{.account = bob,
@@ -1290,7 +1277,6 @@ class ConfidentialTransfer_test : public beast::unit_test::suite
12901277
.destEncryptedAmt =
12911278
Buffer(ripple::ecGamalEncryptedTotalLength),
12921279
.err = temBAD_CIPHERTEXT});
1293-
12941280
// issuer encrypted amount malformed
12951281
mptAlice.send(
12961282
{.account = bob,
@@ -2211,34 +2197,34 @@ class ConfidentialTransfer_test : public beast::unit_test::suite
22112197
Account const alice("alice");
22122198
Account const bob("bob");
22132199
Account const auditor("auditor");
2214-
MPTTester mpt(env, alice, {.holders = {bob}, .auditor = auditor});
2200+
MPTTester mptAlice(
2201+
env, alice, {.holders = {bob}, .auditor = auditor});
22152202

2216-
mpt.create(
2203+
mptAlice.create(
22172204
{.flags = tfMPTCanTransfer | tfMPTCanLock | tfMPTCanPrivacy});
2218-
mpt.authorize({.account = bob});
2219-
mpt.pay(alice, bob, 100);
2205+
mptAlice.authorize({.account = bob});
2206+
mptAlice.pay(alice, bob, 100);
22202207

2221-
mpt.generateKeyPair(alice);
2222-
mpt.generateKeyPair(bob);
2223-
mpt.generateKeyPair(auditor);
2224-
mpt.set(
2208+
mptAlice.generateKeyPair(alice);
2209+
mptAlice.generateKeyPair(bob);
2210+
mptAlice.generateKeyPair(auditor);
2211+
mptAlice.set(
22252212
{.account = alice,
2226-
.issuerPubKey = mpt.getPubKey(alice),
2227-
.auditorPubKey = mpt.getPubKey(auditor)});
2213+
.issuerPubKey = mptAlice.getPubKey(alice),
2214+
.auditorPubKey = mptAlice.getPubKey(auditor)});
22282215

22292216
// Convert funds so Bob has a balance
2230-
mpt.convert({
2217+
mptAlice.convert({
22312218
.account = bob,
22322219
.amt = 50,
2233-
.holderPubKey = mpt.getPubKey(bob),
2220+
.holderPubKey = mptAlice.getPubKey(bob),
22342221
});
2235-
mpt.mergeInbox({.account = bob});
2222+
mptAlice.mergeInbox({.account = bob});
22362223

22372224
// ConvertBack WITHOUT auditorEncryptedAmt
2238-
mpt.convertBack({
2225+
mptAlice.convertBack({
22392226
.account = bob,
22402227
.amt = 10,
2241-
// we omit .auditorEncryptedAmt.
22422228
.fillAuditorEncryptedAmt = false,
22432229
.err = tecNO_PERMISSION,
22442230
});

src/test/jtx/impl/mpt.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,17 @@ MPTTester::set(MPTSet const& arg)
482482
return forObject([&](SLEP const& sle) -> bool {
483483
if (sle)
484484
{
485+
if (!auditor_.has_value())
486+
Throw<std::runtime_error>(
487+
"MPTTester::set: auditor is not set");
488+
489+
auto const auditorPubKey = getPubKey(*auditor_);
490+
if (!auditorPubKey)
491+
Throw<std::runtime_error>(
492+
"MPTTester::set: auditor's pubkey is not set");
493+
485494
return strHex((*sle)[sfAuditorElGamalPublicKey]) ==
486-
strHex(*arg.auditorPubKey);
495+
strHex(*auditorPubKey);
487496
}
488497
return false;
489498
});
@@ -1011,8 +1020,7 @@ MPTTester::fillConversionCiphertexts(
10111020
Buffer& holderCiphertext,
10121021
Buffer& issuerCiphertext,
10131022
std::optional<Buffer>& auditorCiphertext,
1014-
Buffer& blindingFactor,
1015-
bool fillAuditorEncryptedAmt) const
1023+
Buffer& blindingFactor) const
10161024
{
10171025
blindingFactor =
10181026
arg.blindingFactor ? *arg.blindingFactor : generateBlindingFactor();
@@ -1037,7 +1045,7 @@ MPTTester::fillConversionCiphertexts(
10371045
// Handle Auditor
10381046
if (arg.auditorEncryptedAmt)
10391047
auditorCiphertext = *arg.auditorEncryptedAmt;
1040-
else if (auditor_.has_value() && fillAuditorEncryptedAmt)
1048+
else if (auditor_.has_value() && *arg.fillAuditorEncryptedAmt)
10411049
auditorCiphertext = encryptAmount(*auditor_, *arg.amt, blindingFactor);
10421050

10431051
// Update auditor JSON only if ciphertext exists
@@ -1080,8 +1088,7 @@ MPTTester::convert(MPTConvert const& arg)
10801088
holderCiphertext,
10811089
issuerCiphertext,
10821090
auditorCiphertext,
1083-
blindingFactor,
1084-
*arg.fillAuditorEncryptedAmt);
1091+
blindingFactor);
10851092

10861093
jv[sfBlindingFactor.jsonName] = strHex(blindingFactor);
10871094
if (arg.proof)
@@ -1768,8 +1775,7 @@ MPTTester::convertBack(MPTConvertBack const& arg)
17681775
holderCiphertext,
17691776
issuerCiphertext,
17701777
auditorCiphertext,
1771-
blindingFactor,
1772-
*arg.fillAuditorEncryptedAmt);
1778+
blindingFactor);
17731779

17741780
jv[sfBlindingFactor] = strHex(blindingFactor);
17751781

src/test/jtx/mpt.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,7 @@ class MPTTester
535535
Buffer& holderCiphertext,
536536
Buffer& issuerCiphertext,
537537
std::optional<Buffer>& auditorCiphertext,
538-
Buffer& blindingFactor,
539-
bool fillAuditorEncryptedAmt = true) const;
538+
Buffer& blindingFactor) const;
540539
};
541540

542541
} // namespace jtx

src/xrpld/app/tx/detail/MPTokenIssuanceSet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ MPTokenIssuanceSet::preclaim(PreclaimContext const& ctx)
323323
if (ctx.tx.isFieldPresent(sfAuditorElGamalPublicKey) &&
324324
sleMptIssuance->isFieldPresent(sfAuditorElGamalPublicKey))
325325
{
326-
return tecNO_PERMISSION;
326+
return tecNO_PERMISSION; // LCOV_EXCL_LINE
327327
}
328328

329329
if (ctx.tx.isFieldPresent(sfIssuerElGamalPublicKey) &&

0 commit comments

Comments
 (0)