fix: minor review cleanup (comment, test IDs, STTx test)

- Fix incorrect "O(1)" comment on std::map (it's O(log n))
- Replace fragile AccountID{1/2/3} with real test account IDs
- Uncomment STTx_test case 2: serialization now succeeds with optional
  fields, but isValidSignerEntry correctly rejects {Account+TxnSignature}
This commit is contained in:
Nicholas Dudfield
2026-02-10 12:25:18 +07:00
parent 23fd210e29
commit 8d9a38e44a
3 changed files with 17 additions and 8 deletions

View File

@@ -1015,7 +1015,7 @@ Transactor::checkMultiSign(PreclaimContext const& ctx)
if (!allowedSigners)
return allowedSigners.error();
// Build lookup map for O(1) signer validation and weight retrieval
// Build lookup map for signer validation and weight retrieval
std::map<AccountID, uint16_t> signerWeights;
uint32_t totalWeight{0}, cyclicWeight{0};
for (auto const& entry : *allowedSigners)

View File

@@ -1466,7 +1466,7 @@ public:
// Leaf signer: set Account + SigningPubKey + TxnSignature
{
STObject signer(sfSigner);
signer.setAccountID(sfAccount, AccountID{1});
signer.setAccountID(sfAccount, bogie.id());
signer.setFieldVL(sfSigningPubKey, Blob(33, 0x02));
signer.setFieldVL(sfTxnSignature, Blob(64, 0xAA));
signer.applyTemplateFromSField(sfSigner);
@@ -1487,7 +1487,7 @@ public:
// Nested signer: set Account + Signers
{
STObject signer(sfSigner);
signer.setAccountID(sfAccount, AccountID{2});
signer.setAccountID(sfAccount, demon.id());
signer.setFieldArray(sfSigners, STArray{});
signer.applyTemplateFromSField(sfSigner);
@@ -1504,7 +1504,7 @@ public:
// Invalid: all 4 fields set (both leaf and nested fields)
{
STObject signer(sfSigner);
signer.setAccountID(sfAccount, AccountID{3});
signer.setAccountID(sfAccount, ghost.id());
signer.setFieldVL(sfSigningPubKey, Blob(33, 0x02));
signer.setFieldVL(sfTxnSignature, Blob(64, 0xAA));
signer.setFieldArray(sfSigners, STArray{});

View File

@@ -1793,14 +1793,23 @@ public:
testMalformedSigningAccount(soTest1, true);
}
/*{ // RHNOTE: featureNestedMultiSign covers this in the
checkMultiSign()
{
// Test case 2. Omit sfSigningPubKey from SigningAccount.
// With featureNestedMultiSign, sfSigningPubKey is optional in the
// template so serialization succeeds. But the validation layer
// (isValidSignerEntry) correctly rejects {Account + TxnSignature}
// as neither a valid leaf nor nested signer.
STObject soTest2(sfSigner);
soTest2.setAccountID(sfAccount, id2);
soTest2.setFieldVL(sfTxnSignature, saMultiSignature);
testMalformedSigningAccount(soTest2, false);
}*/
testMalformedSigningAccount(soTest2, true); // serializes OK now
// But validation-layer helpers reject it
soTest2.applyTemplateFromSField(sfSigner);
BEAST_EXPECT(!isLeafSigner(soTest2));
BEAST_EXPECT(!isNestedSigner(soTest2));
BEAST_EXPECT(!isValidSignerEntry(soTest2));
}
{
// Test case 3. Extra sfAmount in SigningAccount.
STObject soTest3(sfSigner);