Skip to content

Commit

Permalink
Fix metadata and add metadata unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
gregtatcam committed Oct 12, 2024
1 parent 4bcf463 commit 9b8564e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libxrpl/protocol/SField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ CONSTRUCT_TYPED_SFIELD(sfXChainClaimID, "XChainClaimID", U
CONSTRUCT_TYPED_SFIELD(sfXChainAccountCreateCount, "XChainAccountCreateCount", UINT64, 21);
CONSTRUCT_TYPED_SFIELD(sfXChainAccountClaimCount, "XChainAccountClaimCount", UINT64, 22);
CONSTRUCT_TYPED_SFIELD(sfAssetPrice, "AssetPrice", UINT64, 23);
CONSTRUCT_TYPED_SFIELD(sfMaximumAmount, "MaximumAmount", UINT64, 24, SField::sMD_BaseTen);
CONSTRUCT_TYPED_SFIELD(sfOutstandingAmount, "OutstandingAmount", UINT64, 25, SField::sMD_BaseTen);
CONSTRUCT_TYPED_SFIELD(sfMPTAmount, "MPTAmount", UINT64, 26, SField::sMD_BaseTen);
CONSTRUCT_TYPED_SFIELD(sfMaximumAmount, "MaximumAmount", UINT64, 24, SField::sMD_BaseTen|SField::sMD_Default);
CONSTRUCT_TYPED_SFIELD(sfOutstandingAmount, "OutstandingAmount", UINT64, 25, SField::sMD_BaseTen|SField::sMD_Default);
CONSTRUCT_TYPED_SFIELD(sfMPTAmount, "MPTAmount", UINT64, 26, SField::sMD_BaseTen|SField::sMD_Default);

// 128-bit
CONSTRUCT_TYPED_SFIELD(sfEmailHash, "EmailHash", UINT128, 1);
Expand Down
18 changes: 18 additions & 0 deletions src/test/app/MPToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,24 @@ class MPToken_test : public beast::unit_test::suite
env(pay(bob, carol, MPT(10'000)),
sendmax(MPT(10'000)),
txflags(tfPartialPayment));
// Verify the metadata
auto const meta = env.meta()->getJson(
JsonOptions::none)[sfAffectedNodes.fieldName];
// Issuer got 10 in the transfer fees
BEAST_EXPECT(
meta[0u][sfModifiedNode.fieldName][sfFinalFields.fieldName]
[sfOutstandingAmount.fieldName] == "9990");
// Destination account got 9'990
BEAST_EXPECT(
meta[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName]
[sfMPTAmount.fieldName] == "9990");
// Source account spent 10'000
BEAST_EXPECT(
meta[2u][sfModifiedNode.fieldName][sfPreviousFields.fieldName]
[sfMPTAmount.fieldName] == "10000");
BEAST_EXPECT(
!meta[2u][sfModifiedNode.fieldName][sfFinalFields.fieldName]
.isMember(sfMPTAmount.fieldName));

// payment between the holders fails without
// partial payment
Expand Down

0 comments on commit 9b8564e

Please sign in to comment.