Documentation
¶
Overview ¶
Package mpt provides test helpers for MPT (Multi-Purpose Token) transaction testing. These helpers mirror rippled's test/jtx/mpt.h MPTTester class.
Index ¶
- Constants
- func MakeMPTIDHexFromAddr(sequence uint32, address string) string
- func PtrString(v string) *string
- func PtrUint8(v uint8) *uint8
- func PtrUint16(v uint16) *uint16
- func PtrUint32(v uint32) *uint32
- func PtrUint64(v uint64) *uint64
- type AuthorizeOpts
- type CreateOpts
- type DestroyOpts
- type MPTInit
- type MPTTester
- func (m *MPTTester) Authorize(opts AuthorizeOpts)
- func (m *MPTTester) CheckMPTokenAmount(holder *jtx.Account, expected int64) bool
- func (m *MPTTester) CheckMPTokenOutstandingAmount(expected int64) bool
- func (m *MPTTester) Claw(issuer, holder *jtx.Account, amount int64, expectedErr ...string)
- func (m *MPTTester) Create(opts CreateOpts)
- func (m *MPTTester) Destroy(opts DestroyOpts)
- func (m *MPTTester) IssuanceID() string
- func (m *MPTTester) Issuer() *jtx.Account
- func (m *MPTTester) MPTAmount(amount int64) tx.Amount
- func (m *MPTTester) Pay(src, dest *jtx.Account, amount int64, expectedErr ...string)
- func (m *MPTTester) PayFull(src, dest *jtx.Account, amount, sendMax, deliverMin int64, flags uint32, ...)
- func (m *MPTTester) PayWithFlags(src, dest *jtx.Account, amount int64, flags uint32, expectedErr ...string)
- func (m *MPTTester) PayWithSendMax(src, dest *jtx.Account, amount int64, sendMax int64, expectedErr ...string)
- func (m *MPTTester) RequireMPTokenAmount(holder *jtx.Account, expected int64)
- func (m *MPTTester) Set(opts SetOpts)
- type SetOpts
Constants ¶
const ( // MPTokenIssuanceCreate flags TfMPTCanLock = mpttx.MPTokenIssuanceCreateFlagCanLock TfMPTRequireAuth = mpttx.MPTokenIssuanceCreateFlagRequireAuth TfMPTCanEscrow = mpttx.MPTokenIssuanceCreateFlagCanEscrow TfMPTCanTrade = mpttx.MPTokenIssuanceCreateFlagCanTrade TfMPTCanTransfer = mpttx.MPTokenIssuanceCreateFlagCanTransfer TfMPTCanClawback = mpttx.MPTokenIssuanceCreateFlagCanClawback // MPTokenIssuanceSet flags TfMPTLock = mpttx.MPTokenIssuanceSetFlagLock TfMPTUnlock = mpttx.MPTokenIssuanceSetFlagUnlock TfMPTUnauthorize = mpttx.MPTokenAuthorizeFlagUnauthorize // Payment flags for MPT payment tests TfNoRippleDirect = payment.PaymentFlagNoDirectRipple TfLimitQuality = payment.PaymentFlagLimitQuality TfPartialPayment = payment.PaymentFlagPartialPayment // maxMPTokenAmount matches rippled's maxMPTokenAmount (63-bit max) MaxMPTokenAmount uint64 = 0x7FFFFFFFFFFFFFFF )
Variables ¶
This section is empty.
Functions ¶
func MakeMPTIDHexFromAddr ¶
MakeMPTIDHexFromAddr creates a hex-encoded MPTokenIssuanceID from sequence and address string. Useful for tests that need to compute an ID before the tester's Create() is called.
Types ¶
type AuthorizeOpts ¶
type AuthorizeOpts struct {
// Account is who submits the transaction (default: issuer)
Account *jtx.Account
// Holder is the holder field in the transaction (for issuer authorizing a holder)
Holder *jtx.Account
// ID overrides the issuance ID
ID string
// OwnerCount is the expected owner count for the submitter after the operation
OwnerCount *uint32
// HolderCount is the expected owner count for the holder/account
HolderCount *uint32
// Flags are the transaction flags (e.g., tfMPTUnauthorize)
Flags uint32
// Err is the expected error code (empty means expect success)
Err string
}
AuthorizeOpts configures an MPTokenAuthorize transaction. Reference: rippled MPTAuthorize struct
type CreateOpts ¶
type CreateOpts struct {
// MaxAmt is the maximum amount (optional)
MaxAmt *uint64
// AssetScale is the decimal scale (optional)
AssetScale *uint8
// TransferFee is the transfer fee in basis points (optional)
TransferFee *uint16
// Metadata is the hex-encoded metadata (optional).
// Use nil to not set metadata, use &"" to set empty metadata (should return temMALFORMED).
Metadata *string
// OwnerCount is the expected owner count after the operation (for verification)
OwnerCount *uint32
// HolderCount is the expected holder owner count (not used for create, but for parity)
HolderCount *uint32
// Flags are the transaction flags
Flags uint32
// Err is the expected error code (nil means expect success)
Err string
}
CreateOpts configures an MPTokenIssuanceCreate transaction. Reference: rippled MPTCreate struct
type DestroyOpts ¶
type DestroyOpts struct {
// Issuer overrides the account submitting the destroy (default: tester's issuer)
Issuer *jtx.Account
// ID overrides the issuance ID to destroy
ID string
// OwnerCount is the expected owner count after the operation
OwnerCount *uint32
// Flags are the transaction flags
Flags uint32
// Err is the expected error code (nil means expect success)
Err string
}
DestroyOpts configures an MPTokenIssuanceDestroy transaction. Reference: rippled MPTDestroy struct
type MPTInit ¶
type MPTInit struct {
// Holders are the holder accounts to create and fund
Holders []*jtx.Account
// XRP is the amount to fund the issuer (in drops). Default: 10,000 XRP
XRP uint64
// XRPHolders is the amount to fund each holder (in drops). Default: 10,000 XRP
XRPHolders uint64
// Fund controls whether accounts are funded. Default: true
Fund bool
}
MPTInit configures how the MPTTester is initialized. Reference: rippled MPTInit struct
type MPTTester ¶
type MPTTester struct {
// contains filtered or unexported fields
}
MPTTester manages an MPT issuance lifecycle for testing. It tracks the issuer, holders, and issuance ID, and provides convenience methods for creating, destroying, authorizing, and setting MPT issuances.
func NewMPTTester ¶
NewMPTTester creates a new MPTTester for the given issuer. It funds the issuer and holders unless Fund is false. Reference: rippled MPTTester::MPTTester()
func NewMPTTesterNoFund ¶
NewMPTTesterNoFund creates an MPTTester without funding accounts. Use this when you need to control funding yourself.
func (*MPTTester) Authorize ¶
func (m *MPTTester) Authorize(opts AuthorizeOpts)
Authorize submits an MPTokenAuthorize transaction. Reference: rippled MPTTester::authorize()
func (*MPTTester) CheckMPTokenAmount ¶
CheckMPTokenAmount verifies the MPTAmount balance for a holder. Reference: rippled MPTTester::checkMPTokenAmount()
func (*MPTTester) CheckMPTokenOutstandingAmount ¶
CheckMPTokenOutstandingAmount verifies the OutstandingAmount on the issuance. Reference: rippled MPTTester::checkMPTokenOutstandingAmount()
func (*MPTTester) Claw ¶
Claw submits an MPT clawback transaction. Reference: rippled MPTTester::claw()
func (*MPTTester) Create ¶
func (m *MPTTester) Create(opts CreateOpts)
Create submits an MPTokenIssuanceCreate transaction. Reference: rippled MPTTester::create()
func (*MPTTester) Destroy ¶
func (m *MPTTester) Destroy(opts DestroyOpts)
Destroy submits an MPTokenIssuanceDestroy transaction. Reference: rippled MPTTester::destroy()
func (*MPTTester) IssuanceID ¶
IssuanceID returns the 48-char hex MPTokenIssuanceID.
func (*MPTTester) MPTAmount ¶
MPTAmount creates an MPT tx.Amount for use in payments and other transactions. This creates an IOU-style amount with the MPT issuance ID as the "currency" and the issuer address.
func (*MPTTester) Pay ¶
Pay sends an MPT payment from src to dest. Reference: rippled MPTTester::pay()
func (*MPTTester) PayFull ¶
func (m *MPTTester) PayFull(src, dest *jtx.Account, amount, sendMax, deliverMin int64, flags uint32, expectedErr ...string)
PayFull sends an MPT payment with SendMax, DeliverMin, and flags.
func (*MPTTester) PayWithFlags ¶
func (m *MPTTester) PayWithFlags(src, dest *jtx.Account, amount int64, flags uint32, expectedErr ...string)
PayWithFlags sends an MPT payment with custom flags.
func (*MPTTester) PayWithSendMax ¶
func (m *MPTTester) PayWithSendMax(src, dest *jtx.Account, amount int64, sendMax int64, expectedErr ...string)
PayWithSendMax sends an MPT payment with SendMax.
func (*MPTTester) RequireMPTokenAmount ¶
RequireMPTokenAmount asserts the MPTAmount balance for a holder.
type SetOpts ¶
type SetOpts struct {
// Account is who submits the transaction (default: issuer)
Account *jtx.Account
// Holder is the holder account to modify
Holder *jtx.Account
// ID overrides the issuance ID
ID string
// Flags are the transaction flags (tfMPTLock, tfMPTUnlock)
Flags uint32
// Err is the expected error code (empty means expect success)
Err string
}
SetOpts configures an MPTokenIssuanceSet transaction. Reference: rippled MPTSet struct