Adds @xrplf prettier config (#1598)

* build: new prettier config
This commit is contained in:
Nathan Nichols
2021-09-03 15:41:20 -07:00
committed by Mayukha Vadari
parent 8c5bc22317
commit e200de3073
263 changed files with 10185 additions and 10133 deletions

View File

@@ -1,77 +1,77 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyAccountDelete } from "../../src/models/transactions/accountDelete";
import { verifyAccountDelete } from '../../src/models/transactions/accountDelete'
/**
* AccountDelete Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("AccountDelete", function () {
describe('AccountDelete', function () {
it(`verifies valid AccountDelete`, function () {
const validAccountDelete = {
TransactionType: "AccountDelete",
Account: "rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm",
Destination: "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
TransactionType: 'AccountDelete',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Destination: 'rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe',
DestinationTag: 13,
Fee: "5000000",
Fee: '5000000',
Sequence: 2470665,
Flags: 2147483648,
} as any;
} as any
assert.doesNotThrow(() => verifyAccountDelete(validAccountDelete));
});
assert.doesNotThrow(() => verifyAccountDelete(validAccountDelete))
})
it(`throws w/ missing Destination`, function () {
const invalidDestination = {
TransactionType: "AccountDelete",
Account: "rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm",
Fee: "5000000",
TransactionType: 'AccountDelete',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
Sequence: 2470665,
Flags: 2147483648,
} as any;
} as any
assert.throws(
() => verifyAccountDelete(invalidDestination),
ValidationError,
"AccountDelete: missing field Destination"
);
});
'AccountDelete: missing field Destination',
)
})
it(`throws w/ invalid Destination`, function () {
const invalidDestination = {
TransactionType: "AccountDelete",
Account: "rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm",
TransactionType: 'AccountDelete',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Destination: 65478965,
Fee: "5000000",
Fee: '5000000',
Sequence: 2470665,
Flags: 2147483648,
} as any;
} as any
assert.throws(
() => verifyAccountDelete(invalidDestination),
ValidationError,
"AccountDelete: invalid Destination"
);
});
'AccountDelete: invalid Destination',
)
})
it(`throws w/ invalid DestinationTag`, function () {
const invalidDestinationTag = {
TransactionType: "AccountDelete",
Account: "rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm",
Destination: "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
DestinationTag: "gvftyujnbv",
Fee: "5000000",
TransactionType: 'AccountDelete',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Destination: 'rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe',
DestinationTag: 'gvftyujnbv',
Fee: '5000000',
Sequence: 2470665,
Flags: 2147483648,
} as any;
} as any
assert.throws(
() => verifyAccountDelete(invalidDestinationTag),
ValidationError,
"AccountDelete: invalid DestinationTag"
);
});
});
'AccountDelete: invalid DestinationTag',
)
})
})

View File

@@ -1,111 +1,111 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyAccountSet } from "../../src/models/transactions/accountSet";
import { verifyAccountSet } from '../../src/models/transactions/accountSet'
/**
* AccountSet Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("AccountSet", function () {
let account;
describe('AccountSet', function () {
let account
beforeEach(function () {
account = {
TransactionType: "AccountSet",
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
Fee: "12",
TransactionType: 'AccountSet',
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
Fee: '12',
Sequence: 5,
Domain: "6578616D706C652E636F6D",
Domain: '6578616D706C652E636F6D',
SetFlag: 5,
MessageKey:
"03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB",
} as any;
});
'03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB',
} as any
})
it(`verifies valid AccountSet`, function () {
assert.doesNotThrow(() => verifyAccountSet(account));
});
assert.doesNotThrow(() => verifyAccountSet(account))
})
it(`throws w/ invalid SetFlag (out of range)`, function () {
account.SetFlag = 12;
account.SetFlag = 12
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid SetFlag"
);
});
'AccountSet: invalid SetFlag',
)
})
it(`throws w/ invalid SetFlag (incorrect type)`, function () {
account.SetFlag = "abc";
account.SetFlag = 'abc'
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid SetFlag"
);
});
'AccountSet: invalid SetFlag',
)
})
it(`throws w/ invalid ClearFlag`, function () {
account.ClearFlag = 12;
account.ClearFlag = 12
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid ClearFlag"
);
});
'AccountSet: invalid ClearFlag',
)
})
it(`throws w/ invalid Domain`, function () {
account.Domain = 6578616;
account.Domain = 6578616
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid Domain"
);
});
'AccountSet: invalid Domain',
)
})
it(`throws w/ invalid EmailHash`, function () {
account.EmailHash = 6578656789876543;
account.EmailHash = 6578656789876543
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid EmailHash"
);
});
'AccountSet: invalid EmailHash',
)
})
it(`throws w/ invalid MessageKey`, function () {
account.MessageKey = 6578656789876543;
account.MessageKey = 6578656789876543
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid MessageKey"
);
});
'AccountSet: invalid MessageKey',
)
})
it(`throws w/ invalid TransferRate`, function () {
account.TransferRate = "1000000001";
account.TransferRate = '1000000001'
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid TransferRate"
);
});
'AccountSet: invalid TransferRate',
)
})
it(`throws w/ invalid TickSize`, function () {
account.TickSize = 20;
account.TickSize = 20
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid TickSize"
);
});
});
'AccountSet: invalid TickSize',
)
})
})

View File

@@ -1,232 +1,232 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyBaseTransaction } from "../../src/models/transactions/common";
import { verifyBaseTransaction } from '../../src/models/transactions/common'
/**
* Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("BaseTransaction", function () {
describe('BaseTransaction', function () {
it(`Verifies all optional BaseTransaction`, function () {
const txJson = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Fee: "12",
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
Fee: '12',
Sequence: 100,
AccountTxnID: "DEADBEEF",
AccountTxnID: 'DEADBEEF',
Flags: 15,
LastLedgerSequence: 1383,
Memos: [
{
Memo: {
MemoType:
"687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963",
MemoData: "72656e74",
'687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963',
MemoData: '72656e74',
},
},
{
Memo: {
MemoFormat:
"687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963",
MemoData: "72656e74",
'687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963',
MemoData: '72656e74',
},
},
{
Memo: {
MemoType: "72656e74",
MemoType: '72656e74',
},
},
],
Signers: [
{
Account: "r....",
TxnSignature: "DEADBEEF",
SigningPubKey: "hex-string",
Account: 'r....',
TxnSignature: 'DEADBEEF',
SigningPubKey: 'hex-string',
},
],
SourceTag: 31,
SigningPublicKey:
"03680DD274EE55594F7244F489CD38CF3A5A1A4657122FB8143E185B2BA043DF36",
'03680DD274EE55594F7244F489CD38CF3A5A1A4657122FB8143E185B2BA043DF36',
TicketSequence: 10,
TxnSignature:
"3045022100C6708538AE5A697895937C758E99A595B57A16393F370F11B8D4C032E80B532002207776A8E85BB9FAF460A92113B9C60F170CD964196B1F084E0DAB65BAEC368B66",
};
'3045022100C6708538AE5A697895937C758E99A595B57A16393F370F11B8D4C032E80B532002207776A8E85BB9FAF460A92113B9C60F170CD964196B1F084E0DAB65BAEC368B66',
}
assert.doesNotThrow(() => verifyBaseTransaction(txJson));
});
assert.doesNotThrow(() => verifyBaseTransaction(txJson))
})
it(`Verifies only required BaseTransaction`, function () {
const txJson = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
};
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
}
assert.doesNotThrow(() => verifyBaseTransaction(txJson));
});
assert.doesNotThrow(() => verifyBaseTransaction(txJson))
})
it(`Handles invalid Fee`, function () {
const invalidFee = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
Fee: 1000,
} as any;
} as any
assert.throws(
() => verifyBaseTransaction(invalidFee),
ValidationError,
"BaseTransaction: invalid Fee"
);
});
'BaseTransaction: invalid Fee',
)
})
it(`Handles invalid Sequence`, function () {
const invalidSeq = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Sequence: "145",
} as any;
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
Sequence: '145',
} as any
assert.throws(
() => verifyBaseTransaction(invalidSeq),
ValidationError,
"BaseTransaction: invalid Sequence"
);
});
'BaseTransaction: invalid Sequence',
)
})
it(`Handles invalid AccountTxnID`, function () {
const invalidID = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
AccountTxnID: ["WRONG"],
} as any;
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
AccountTxnID: ['WRONG'],
} as any
assert.throws(
() => verifyBaseTransaction(invalidID),
ValidationError,
"BaseTransaction: invalid AccountTxnID"
);
});
'BaseTransaction: invalid AccountTxnID',
)
})
it(`Handles invalid LastLedgerSequence`, function () {
const invalidLastLedgerSequence = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
LastLedgerSequence: "1000",
} as any;
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
LastLedgerSequence: '1000',
} as any
assert.throws(
() => verifyBaseTransaction(invalidLastLedgerSequence),
ValidationError,
"BaseTransaction: invalid LastLedgerSequence"
);
});
'BaseTransaction: invalid LastLedgerSequence',
)
})
it(`Handles invalid SourceTag`, function () {
const invalidSourceTag = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
SourceTag: ["ARRAY"],
} as any;
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
SourceTag: ['ARRAY'],
} as any
assert.throws(
() => verifyBaseTransaction(invalidSourceTag),
ValidationError,
"BaseTransaction: invalid SourceTag"
);
});
'BaseTransaction: invalid SourceTag',
)
})
it(`Handles invalid SigningPubKey`, function () {
const invalidSigningPubKey = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
SigningPubKey: 1000,
} as any;
} as any
assert.throws(
() => verifyBaseTransaction(invalidSigningPubKey),
ValidationError,
"BaseTransaction: invalid SigningPubKey"
);
});
'BaseTransaction: invalid SigningPubKey',
)
})
it(`Handles invalid TicketSequence`, function () {
const invalidTicketSequence = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
TicketSequence: "1000",
} as any;
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
TicketSequence: '1000',
} as any
assert.throws(
() => verifyBaseTransaction(invalidTicketSequence),
ValidationError,
"BaseTransaction: invalid TicketSequence"
);
});
'BaseTransaction: invalid TicketSequence',
)
})
it(`Handles invalid TxnSignature`, function () {
const invalidTxnSignature = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
TxnSignature: 1000,
} as any;
} as any
assert.throws(
() => verifyBaseTransaction(invalidTxnSignature),
ValidationError,
"BaseTransaction: invalid TxnSignature"
);
});
'BaseTransaction: invalid TxnSignature',
)
})
it(`Handles invalid Signers`, function () {
const invalidSigners = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
Signers: [],
} as any;
} as any
assert.throws(
() => verifyBaseTransaction(invalidSigners),
ValidationError,
"BaseTransaction: invalid Signers"
);
'BaseTransaction: invalid Signers',
)
const invalidSigners2 = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
Signers: [
{
Account: "r....",
Account: 'r....',
},
],
} as any;
} as any
assert.throws(
() => verifyBaseTransaction(invalidSigners2),
ValidationError,
"BaseTransaction: invalid Signers"
);
});
'BaseTransaction: invalid Signers',
)
})
it(`Handles invalid Memo`, function () {
const invalidMemo = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
Memos: [
{
Memo: {
MemoData: "HI",
Address: "WRONG",
MemoData: 'HI',
Address: 'WRONG',
},
},
],
} as any;
} as any
assert.throws(
() => verifyBaseTransaction(invalidMemo),
ValidationError,
"BaseTransaction: invalid Memos"
);
});
});
'BaseTransaction: invalid Memos',
)
})
})

View File

@@ -1,37 +1,37 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyCheckCancel } from "../../src/models/transactions/checkCancel";
import { verifyCheckCancel } from '../../src/models/transactions/checkCancel'
/**
* CheckCancel Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("CheckCancel", function () {
describe('CheckCancel', function () {
it(`verifies valid CheckCancel`, function () {
const validCheckCancel = {
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
TransactionType: "CheckCancel",
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
TransactionType: 'CheckCancel',
CheckID:
"49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0",
} as any;
'49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0',
} as any
assert.doesNotThrow(() => verifyCheckCancel(validCheckCancel));
});
assert.doesNotThrow(() => verifyCheckCancel(validCheckCancel))
})
it(`throws w/ invalid CheckCancel`, function () {
const invalidCheckID = {
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
TransactionType: "CheckCancel",
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
TransactionType: 'CheckCancel',
CheckID: 4964734566545678,
} as any;
} as any
assert.throws(
() => verifyCheckCancel(invalidCheckID),
ValidationError,
"CheckCancel: invalid CheckID"
);
});
});
'CheckCancel: invalid CheckID',
)
})
})

View File

@@ -1,89 +1,89 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyCheckCash } from "../../src/models/transactions/checkCash";
import { verifyCheckCash } from '../../src/models/transactions/checkCash'
/**
* CheckCash Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("CheckCash", function () {
describe('CheckCash', function () {
it(`verifies valid CheckCash`, function () {
const validCheckCash = {
Account: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType: "CheckCash",
Amount: "100000000",
Account: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
TransactionType: 'CheckCash',
Amount: '100000000',
CheckID:
"838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334",
Fee: "12",
} as any;
'838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334',
Fee: '12',
} as any
assert.doesNotThrow(() => verifyCheckCash(validCheckCash));
});
assert.doesNotThrow(() => verifyCheckCash(validCheckCash))
})
it(`throws w/ invalid CheckID`, function () {
const invalidCheckID = {
Account: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType: "CheckCash",
Amount: "100000000",
Account: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
TransactionType: 'CheckCash',
Amount: '100000000',
CheckID: 83876645678567890,
} as any;
} as any
assert.throws(
() => verifyCheckCash(invalidCheckID),
ValidationError,
"CheckCash: invalid CheckID"
);
});
'CheckCash: invalid CheckID',
)
})
it(`throws w/ invalid Amount`, function () {
const invalidAmount = {
Account: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType: "CheckCash",
Account: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
TransactionType: 'CheckCash',
Amount: 100000000,
CheckID:
"838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334",
} as any;
'838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334',
} as any
assert.throws(
() => verifyCheckCash(invalidAmount),
ValidationError,
"CheckCash: invalid Amount"
);
});
'CheckCash: invalid Amount',
)
})
it(`throws w/ having both Amount and DeliverMin`, function () {
const invalidDeliverMin = {
Account: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType: "CheckCash",
Amount: "100000000",
Account: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
TransactionType: 'CheckCash',
Amount: '100000000',
DeliverMin: 852156963,
CheckID:
"838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334",
} as any;
'838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334',
} as any
assert.throws(
() => verifyCheckCash(invalidDeliverMin),
ValidationError,
"CheckCash: cannot have both Amount and DeliverMin"
);
});
'CheckCash: cannot have both Amount and DeliverMin',
)
})
it(`throws w/ invalid DeliverMin`, function () {
const invalidDeliverMin = {
Account: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType: "CheckCash",
Account: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
TransactionType: 'CheckCash',
DeliverMin: 852156963,
CheckID:
"838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334",
} as any;
'838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334',
} as any
assert.throws(
() => verifyCheckCash(invalidDeliverMin),
ValidationError,
"CheckCash: invalid DeliverMin"
);
});
});
'CheckCash: invalid DeliverMin',
)
})
})

View File

@@ -1,127 +1,127 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyCheckCreate } from "../../src/models/transactions/checkCreate";
import { verifyCheckCreate } from '../../src/models/transactions/checkCreate'
/**
* CheckCreate Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("CheckCreate", function () {
describe('CheckCreate', function () {
it(`verifies valid CheckCreate`, function () {
const validCheck = {
TransactionType: "CheckCreate",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
SendMax: "100000000",
TransactionType: 'CheckCreate',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
Destination: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
SendMax: '100000000',
Expiration: 570113521,
InvoiceID:
"6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
'6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B',
DestinationTag: 1,
Fee: "12",
} as any;
Fee: '12',
} as any
assert.doesNotThrow(() => verifyCheckCreate(validCheck));
});
assert.doesNotThrow(() => verifyCheckCreate(validCheck))
})
it(`throws w/ invalid Destination`, function () {
const invalidDestination = {
TransactionType: "CheckCreate",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
TransactionType: 'CheckCreate',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
Destination: 7896214789632154,
SendMax: "100000000",
SendMax: '100000000',
Expiration: 570113521,
InvoiceID:
"6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
'6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B',
DestinationTag: 1,
Fee: "12",
} as any;
Fee: '12',
} as any
assert.throws(
() => verifyCheckCreate(invalidDestination),
ValidationError,
"CheckCreate: invalid Destination"
);
});
'CheckCreate: invalid Destination',
)
})
it(`throws w/ invalid SendMax`, function () {
const invalidSendMax = {
TransactionType: "CheckCreate",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType: 'CheckCreate',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
Destination: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
SendMax: 100000000,
Expiration: 570113521,
InvoiceID:
"6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
'6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B',
DestinationTag: 1,
Fee: "12",
} as any;
Fee: '12',
} as any
assert.throws(
() => verifyCheckCreate(invalidSendMax),
ValidationError,
"CheckCreate: invalid SendMax"
);
});
'CheckCreate: invalid SendMax',
)
})
it(`throws w/ invalid DestinationTag`, function () {
const invalidDestinationTag = {
TransactionType: "CheckCreate",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
SendMax: "100000000",
TransactionType: 'CheckCreate',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
Destination: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
SendMax: '100000000',
Expiration: 570113521,
InvoiceID:
"6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
DestinationTag: "1",
Fee: "12",
} as any;
'6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B',
DestinationTag: '1',
Fee: '12',
} as any
assert.throws(
() => verifyCheckCreate(invalidDestinationTag),
ValidationError,
"CheckCreate: invalid DestinationTag"
);
});
'CheckCreate: invalid DestinationTag',
)
})
it(`throws w/ invalid Expiration`, function () {
const invalidExpiration = {
TransactionType: "CheckCreate",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
SendMax: "100000000",
Expiration: "570113521",
TransactionType: 'CheckCreate',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
Destination: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
SendMax: '100000000',
Expiration: '570113521',
InvoiceID:
"6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
'6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B',
DestinationTag: 1,
Fee: "12",
} as any;
Fee: '12',
} as any
assert.throws(
() => verifyCheckCreate(invalidExpiration),
ValidationError,
"CheckCreate: invalid Expiration"
);
});
'CheckCreate: invalid Expiration',
)
})
it(`throws w/ invalid InvoiceID`, function () {
const invalidInvoiceID = {
TransactionType: "CheckCreate",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
SendMax: "100000000",
TransactionType: 'CheckCreate',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
Destination: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
SendMax: '100000000',
Expiration: 570113521,
InvoiceID: 789656963258531,
DestinationTag: 1,
Fee: "12",
} as any;
Fee: '12',
} as any
assert.throws(
() => verifyCheckCreate(invalidInvoiceID),
ValidationError,
"CheckCreate: invalid InvoiceID"
);
});
});
'CheckCreate: invalid InvoiceID',
)
})
})

View File

@@ -1,85 +1,85 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyDepositPreauth } from "../../src/models/transactions/depositPreauth";
import { verifyDepositPreauth } from '../../src/models/transactions/depositPreauth'
/**
* DepositPreauth Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("DepositPreauth", function () {
let depositPreauth;
describe('DepositPreauth', function () {
let depositPreauth
beforeEach(function () {
depositPreauth = {
TransactionType: "DepositPreauth",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
} as any;
});
TransactionType: 'DepositPreauth',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
} as any
})
it("verifies valid DepositPreauth when only Authorize is provided", function () {
depositPreauth.Authorize = "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW";
assert.doesNotThrow(() => verifyDepositPreauth(depositPreauth));
});
it('verifies valid DepositPreauth when only Authorize is provided', function () {
depositPreauth.Authorize = 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW'
assert.doesNotThrow(() => verifyDepositPreauth(depositPreauth))
})
it("verifies valid DepositPreauth when only Unauthorize is provided", function () {
depositPreauth.Unauthorize = "raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n";
assert.doesNotThrow(() => verifyDepositPreauth(depositPreauth));
});
it('verifies valid DepositPreauth when only Unauthorize is provided', function () {
depositPreauth.Unauthorize = 'raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n'
assert.doesNotThrow(() => verifyDepositPreauth(depositPreauth))
})
it("throws when both Authorize and Unauthorize are provided", function () {
depositPreauth.Authorize = "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW";
depositPreauth.Unauthorize = "raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n";
it('throws when both Authorize and Unauthorize are provided', function () {
depositPreauth.Authorize = 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW'
depositPreauth.Unauthorize = 'raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n'
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
"DepositPreauth: can't provide both Authorize and Unauthorize fields"
);
});
"DepositPreauth: can't provide both Authorize and Unauthorize fields",
)
})
it("throws when neither Authorize nor Unauthorize are provided", function () {
it('throws when neither Authorize nor Unauthorize are provided', function () {
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
"DepositPreauth: must provide either Authorize or Unauthorize field"
);
});
'DepositPreauth: must provide either Authorize or Unauthorize field',
)
})
it("throws when Authorize is not a string", function () {
depositPreauth.Authorize = 1234;
it('throws when Authorize is not a string', function () {
depositPreauth.Authorize = 1234
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
"DepositPreauth: Authorize must be a string"
);
});
'DepositPreauth: Authorize must be a string',
)
})
it("throws when an Account attempts to preauthorize its own address", function () {
depositPreauth.Authorize = depositPreauth.Account;
it('throws when an Account attempts to preauthorize its own address', function () {
depositPreauth.Authorize = depositPreauth.Account
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
"DepositPreauth: Account can't preauthorize its own address"
);
});
"DepositPreauth: Account can't preauthorize its own address",
)
})
it("throws when Unauthorize is not a string", function () {
depositPreauth.Unauthorize = 1234;
it('throws when Unauthorize is not a string', function () {
depositPreauth.Unauthorize = 1234
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
"DepositPreauth: Unauthorize must be a string"
);
});
'DepositPreauth: Unauthorize must be a string',
)
})
it("throws when an Account attempts to unauthorize its own address", function () {
depositPreauth.Unauthorize = depositPreauth.Account;
it('throws when an Account attempts to unauthorize its own address', function () {
depositPreauth.Unauthorize = depositPreauth.Account
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
"DepositPreauth: Account can't unauthorize its own address"
);
});
});
"DepositPreauth: Account can't unauthorize its own address",
)
})
})

View File

@@ -1,66 +1,66 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "../../src/common/errors";
import { verifyEscrowCancel } from "../../src/models/transactions/escrowCancel";
import { ValidationError } from '../../src/common/errors'
import { verifyEscrowCancel } from '../../src/models/transactions/escrowCancel'
/**
* Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("EscrowCancel", function () {
let cancel;
describe('EscrowCancel', function () {
let cancel
beforeEach(function () {
cancel = {
TransactionType: "EscrowCancel",
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
Owner: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
TransactionType: 'EscrowCancel',
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
Owner: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
OfferSequence: 7,
};
});
}
})
it(`Valid EscrowCancel`, function () {
assert.doesNotThrow(() => verifyEscrowCancel(cancel));
});
assert.doesNotThrow(() => verifyEscrowCancel(cancel))
})
it(`Invalid EscrowCancel missing owner`, function () {
delete cancel.Owner;
delete cancel.Owner
assert.throws(
() => verifyEscrowCancel(cancel),
ValidationError,
"EscrowCancel: missing Owner"
);
});
'EscrowCancel: missing Owner',
)
})
it(`Invalid EscrowCancel missing offerSequence`, function () {
delete cancel.OfferSequence;
delete cancel.OfferSequence
assert.throws(
() => verifyEscrowCancel(cancel),
ValidationError,
"EscrowCancel: missing OfferSequence"
);
});
'EscrowCancel: missing OfferSequence',
)
})
it(`Invalid OfferSequence`, function () {
cancel.Owner = 10;
cancel.Owner = 10
assert.throws(
() => verifyEscrowCancel(cancel),
ValidationError,
"EscrowCancel: Owner must be a string"
);
});
'EscrowCancel: Owner must be a string',
)
})
it(`Invalid owner`, function () {
cancel.OfferSequence = "10";
cancel.OfferSequence = '10'
assert.throws(
() => verifyEscrowCancel(cancel),
ValidationError,
"EscrowCancel: OfferSequence must be a number"
);
});
});
'EscrowCancel: OfferSequence must be a number',
)
})
})

View File

@@ -1,135 +1,135 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyEscrowCreate } from "../../src/models/transactions/escrowCreate";
import { verifyEscrowCreate } from '../../src/models/transactions/escrowCreate'
/**
* EscrowCreate Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("EscrowCreate", function () {
let escrow;
describe('EscrowCreate', function () {
let escrow
beforeEach(function () {
escrow = {
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
TransactionType: "EscrowCreate",
Amount: "10000",
Destination: "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
TransactionType: 'EscrowCreate',
Amount: '10000',
Destination: 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW',
CancelAfter: 533257958,
FinishAfter: 533171558,
Condition:
"A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100",
'A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100',
DestinationTag: 23480,
SourceTag: 11747,
};
});
}
})
it(`verifies valid EscrowCreate`, function () {
assert.doesNotThrow(() => verifyEscrowCreate(escrow));
});
assert.doesNotThrow(() => verifyEscrowCreate(escrow))
})
it(`Missing amount`, function () {
delete escrow.Amount;
delete escrow.Amount
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: missing field Amount"
);
});
'EscrowCreate: missing field Amount',
)
})
it(`Missing destination`, function () {
delete escrow.Destination;
delete escrow.Destination
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: missing field Destination"
);
});
'EscrowCreate: missing field Destination',
)
})
it(`throws w/ invalid Destination`, function () {
escrow.Destination = 10;
escrow.Destination = 10
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: Destination must be a string"
);
});
'EscrowCreate: Destination must be a string',
)
})
it(`throws w/ invalid Amount`, function () {
escrow.Amount = 1000;
escrow.Amount = 1000
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: Amount must be a string"
);
});
'EscrowCreate: Amount must be a string',
)
})
it(`invalid CancelAfter`, function () {
escrow.CancelAfter = "100";
escrow.CancelAfter = '100'
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: CancelAfter must be a number"
);
});
'EscrowCreate: CancelAfter must be a number',
)
})
it(`invalid FinishAfter`, function () {
escrow.FinishAfter = "1000";
escrow.FinishAfter = '1000'
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: FinishAfter must be a number"
);
});
'EscrowCreate: FinishAfter must be a number',
)
})
it(`invalid Condition`, function () {
escrow.Condition = 0x141243;
escrow.Condition = 0x141243
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: Condition must be a string"
);
});
'EscrowCreate: Condition must be a string',
)
})
it(`invalid DestinationTag`, function () {
escrow.DestinationTag = "100";
escrow.DestinationTag = '100'
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: DestinationTag must be a number"
);
});
'EscrowCreate: DestinationTag must be a number',
)
})
it(`Missing both CancelAfter and FinishAfter`, function () {
delete escrow.CancelAfter;
delete escrow.FinishAfter;
delete escrow.CancelAfter
delete escrow.FinishAfter
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: Either CancelAfter or FinishAfter must be specified"
);
});
'EscrowCreate: Either CancelAfter or FinishAfter must be specified',
)
})
it(`Missing both Condition and FinishAfter`, function () {
delete escrow.Condition;
delete escrow.FinishAfter;
delete escrow.Condition
delete escrow.FinishAfter
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: Either Condition or FinishAfter must be specified"
);
});
});
'EscrowCreate: Either Condition or FinishAfter must be specified',
)
})
})

View File

@@ -1,76 +1,76 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyEscrowFinish } from "../../src/models/transactions/escrowFinish";
import { verifyEscrowFinish } from '../../src/models/transactions/escrowFinish'
/**
* EscrowFinish Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("EscrowFinish", function () {
let escrow;
describe('EscrowFinish', function () {
let escrow
beforeEach(function () {
escrow = {
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
TransactionType: "EscrowFinish",
Owner: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
TransactionType: 'EscrowFinish',
Owner: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
OfferSequence: 7,
Condition:
"A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100",
Fulfillment: "A0028000",
};
});
'A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100',
Fulfillment: 'A0028000',
}
})
it(`verifies valid EscrowFinish`, function () {
assert.doesNotThrow(() => verifyEscrowFinish(escrow));
});
assert.doesNotThrow(() => verifyEscrowFinish(escrow))
})
it(`verifies valid EscrowFinish w/o optional`, function () {
delete escrow.Condition;
delete escrow.Fulfillment;
delete escrow.Condition
delete escrow.Fulfillment
assert.doesNotThrow(() => verifyEscrowFinish(escrow));
});
assert.doesNotThrow(() => verifyEscrowFinish(escrow))
})
it(`throws w/ invalid Owner`, function () {
escrow.Owner = 0x15415253;
escrow.Owner = 0x15415253
assert.throws(
() => verifyEscrowFinish(escrow),
ValidationError,
"EscrowFinish: Owner must be a string"
);
});
'EscrowFinish: Owner must be a string',
)
})
it(`throws w/ invalid OfferSequence`, function () {
escrow.OfferSequence = "10";
escrow.OfferSequence = '10'
assert.throws(
() => verifyEscrowFinish(escrow),
ValidationError,
"EscrowFinish: OfferSequence must be a number"
);
});
'EscrowFinish: OfferSequence must be a number',
)
})
it(`throws w/ invalid Condition`, function () {
escrow.Condition = 10;
escrow.Condition = 10
assert.throws(
() => verifyEscrowFinish(escrow),
ValidationError,
"EscrowFinish: Condition must be a string"
);
});
'EscrowFinish: Condition must be a string',
)
})
it(`throws w/ invalid Fulfillment`, function () {
escrow.Fulfillment = 0x142341;
escrow.Fulfillment = 0x142341
assert.throws(
() => verifyEscrowFinish(escrow),
ValidationError,
"EscrowFinish: Fulfillment must be a string"
);
});
});
'EscrowFinish: Fulfillment must be a string',
)
})
})

View File

@@ -1,57 +1,57 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyOfferCancel } from "../../src/models/transactions/offerCancel";
import { verifyOfferCancel } from '../../src/models/transactions/offerCancel'
/**
* OfferCancel Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("OfferCancel", function () {
let offer;
describe('OfferCancel', function () {
let offer
beforeEach(function () {
offer = {
Account: "rnKiczmiQkZFiDES8THYyLA2pQohC5C6EF",
Fee: "10",
Account: 'rnKiczmiQkZFiDES8THYyLA2pQohC5C6EF',
Fee: '10',
LastLedgerSequence: 65477334,
OfferSequence: 60797528,
Sequence: 60797535,
SigningPubKey:
"0361BFD43D1EEA54B77CC152887312949EBF052997FBFFCDAF6F2653164B55B21...",
TransactionType: "OfferCancel",
'0361BFD43D1EEA54B77CC152887312949EBF052997FBFFCDAF6F2653164B55B21...',
TransactionType: 'OfferCancel',
TxnSignature:
"30450221008C43BDCFC68B4793857CA47DF454C07E5B45D3F80E8E6785CAB9292...",
date: "2021-08-06T21:04:11Z",
} as any;
});
'30450221008C43BDCFC68B4793857CA47DF454C07E5B45D3F80E8E6785CAB9292...',
date: '2021-08-06T21:04:11Z',
} as any
})
it(`verifies valid OfferCancel`, function () {
assert.doesNotThrow(() => verifyOfferCancel(offer));
});
assert.doesNotThrow(() => verifyOfferCancel(offer))
})
it(`verifies valid OfferCancel with flags`, function () {
offer.Flags = 2147483648;
assert.doesNotThrow(() => verifyOfferCancel(offer));
});
offer.Flags = 2147483648
assert.doesNotThrow(() => verifyOfferCancel(offer))
})
it(`throws w/ OfferSequence must be a number`, function () {
offer.OfferSequence = "99";
offer.OfferSequence = '99'
assert.throws(
() => verifyOfferCancel(offer),
ValidationError,
"OfferCancel: OfferSequence must be a number"
);
});
'OfferCancel: OfferSequence must be a number',
)
})
it(`throws w/ missing OfferSequence`, function () {
delete offer.OfferSequence;
delete offer.OfferSequence
assert.throws(
() => verifyOfferCancel(offer),
ValidationError,
"OfferCancel: missing field OfferSequence"
);
});
});
'OfferCancel: missing field OfferSequence',
)
})
})

View File

@@ -1,191 +1,191 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyOfferCreate } from "../../src/models/transactions/offerCreate";
import { verifyOfferCreate } from '../../src/models/transactions/offerCreate'
/**
* OfferCreate Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("OfferCreate", function () {
describe('OfferCreate', function () {
it(`verifies valid OfferCreate`, function () {
const offer = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
Fee: '10',
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey:
"03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
'03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22',
Expiration: 10,
OfferSequence: 12,
TakerGets: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009",
currency: 'DSH',
issuer: 'rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX',
value: '43.11584856965009',
},
TakerPays: "12928290425",
TransactionType: "OfferCreate",
TakerPays: '12928290425',
TransactionType: 'OfferCreate',
TxnSignature:
"3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any;
'3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91',
} as any
assert.doesNotThrow(() => verifyOfferCreate(offer));
assert.doesNotThrow(() => verifyOfferCreate(offer))
const offer2 = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
Fee: '10',
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey:
"03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
TakerGets: "12928290425",
'03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22',
TakerGets: '12928290425',
TakerPays: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009",
currency: 'DSH',
issuer: 'rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX',
value: '43.11584856965009',
},
TransactionType: "OfferCreate",
TransactionType: 'OfferCreate',
TxnSignature:
"3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any;
'3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91',
} as any
assert.doesNotThrow(() => verifyOfferCreate(offer2));
assert.doesNotThrow(() => verifyOfferCreate(offer2))
const offer3 = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
Fee: '10',
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey:
"03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
'03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22',
TakerGets: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009",
currency: 'DSH',
issuer: 'rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX',
value: '43.11584856965009',
},
TakerPays: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009",
currency: 'DSH',
issuer: 'rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX',
value: '43.11584856965009',
},
TransactionType: "OfferCreate",
TransactionType: 'OfferCreate',
TxnSignature:
"3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any;
'3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91',
} as any
assert.doesNotThrow(() => verifyOfferCreate(offer3));
});
assert.doesNotThrow(() => verifyOfferCreate(offer3))
})
it(`throws w/ invalid Expiration`, function () {
const offer = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
Fee: '10',
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey:
"03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
Expiration: "11",
TakerGets: "12928290425",
'03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22',
Expiration: '11',
TakerGets: '12928290425',
TakerPays: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009",
currency: 'DSH',
issuer: 'rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX',
value: '43.11584856965009',
},
TransactionType: "OfferCreate",
TransactionType: 'OfferCreate',
TxnSignature:
"3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any;
'3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91',
} as any
assert.throws(
() => verifyOfferCreate(offer),
ValidationError,
"OfferCreate: invalid Expiration"
);
});
'OfferCreate: invalid Expiration',
)
})
it(`throws w/ invalid OfferSequence`, function () {
const offer = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
Fee: '10',
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey:
"03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
OfferSequence: "11",
TakerGets: "12928290425",
'03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22',
OfferSequence: '11',
TakerGets: '12928290425',
TakerPays: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009",
currency: 'DSH',
issuer: 'rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX',
value: '43.11584856965009',
},
TransactionType: "OfferCreate",
TransactionType: 'OfferCreate',
TxnSignature:
"3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any;
'3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91',
} as any
assert.throws(
() => verifyOfferCreate(offer),
ValidationError,
"OfferCreate: invalid OfferSequence"
);
});
'OfferCreate: invalid OfferSequence',
)
})
it(`throws w/ invalid TakerPays`, function () {
const offer = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
Fee: '10',
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey:
"03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
OfferSequence: "11",
TakerGets: "12928290425",
'03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22',
OfferSequence: '11',
TakerGets: '12928290425',
TakerPays: 10,
TransactionType: "OfferCreate",
TransactionType: 'OfferCreate',
TxnSignature:
"3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any;
'3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91',
} as any
assert.throws(
() => verifyOfferCreate(offer),
ValidationError,
"OfferCreate: invalid TakerPays"
);
});
'OfferCreate: invalid TakerPays',
)
})
it(`throws w/ invalid TakerGets`, function () {
const offer = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
Fee: '10',
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey:
"03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
OfferSequence: "11",
'03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22',
OfferSequence: '11',
TakerGets: 11,
TakerPays: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009",
currency: 'DSH',
issuer: 'rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX',
value: '43.11584856965009',
},
TransactionType: "OfferCreate",
TransactionType: 'OfferCreate',
TxnSignature:
"3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any;
'3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91',
} as any
assert.throws(
() => verifyOfferCreate(offer),
ValidationError,
"OfferCreate: invalid TakerGets"
);
});
});
'OfferCreate: invalid TakerGets',
)
})
})

View File

@@ -1,138 +1,138 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import {
PaymentTransactionFlagsEnum,
verifyPayment,
} from "../../src/models/transactions/payment";
} from '../../src/models/transactions/payment'
/**
* PaymentTransaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("Payment", function () {
let paymentTransaction;
describe('Payment', function () {
let paymentTransaction
beforeEach(function () {
paymentTransaction = {
TransactionType: "Payment",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Amount: "1234",
Destination: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType: 'Payment',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
Amount: '1234',
Destination: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
DestinationTag: 1,
InvoiceID:
"6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
Paths: [[{ currency: "BTC", issuer: "apsoeijf90wp34fh" }]],
SendMax: "100000000",
} as any;
});
'6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B',
Paths: [[{ currency: 'BTC', issuer: 'apsoeijf90wp34fh' }]],
SendMax: '100000000',
} as any
})
it(`verifies valid PaymentTransaction`, function () {
assert.doesNotThrow(() => verifyPayment(paymentTransaction));
});
assert.doesNotThrow(() => verifyPayment(paymentTransaction))
})
it(`throws when Amount is missing`, function () {
delete paymentTransaction.Amount;
delete paymentTransaction.Amount
assert.throws(
() => verifyPayment(paymentTransaction),
ValidationError,
"PaymentTransaction: missing field Amount"
);
});
'PaymentTransaction: missing field Amount',
)
})
it(`throws when Amount is invalid`, function () {
paymentTransaction.Amount = 1234;
paymentTransaction.Amount = 1234
assert.throws(
() => verifyPayment(paymentTransaction),
ValidationError,
"PaymentTransaction: invalid Amount"
);
});
'PaymentTransaction: invalid Amount',
)
})
it(`throws when Destination is missing`, function () {
delete paymentTransaction.Destination;
delete paymentTransaction.Destination
assert.throws(
() => verifyPayment(paymentTransaction),
ValidationError,
"PaymentTransaction: missing field Destination"
);
});
'PaymentTransaction: missing field Destination',
)
})
it(`throws when Destination is invalid`, function () {
paymentTransaction.Destination = 7896214;
paymentTransaction.Destination = 7896214
assert.throws(
() => verifyPayment(paymentTransaction),
ValidationError,
"PaymentTransaction: invalid Destination"
);
});
'PaymentTransaction: invalid Destination',
)
})
it(`throws when DestinationTag is not a number`, function () {
paymentTransaction.DestinationTag = "1";
paymentTransaction.DestinationTag = '1'
assert.throws(
() => verifyPayment(paymentTransaction),
ValidationError,
"PaymentTransaction: DestinationTag must be a number"
);
});
'PaymentTransaction: DestinationTag must be a number',
)
})
it(`throws when InvoiceID is not a string`, function () {
paymentTransaction.InvoiceID = 19832;
paymentTransaction.InvoiceID = 19832
assert.throws(
() => verifyPayment(paymentTransaction),
ValidationError,
"PaymentTransaction: InvoiceID must be a string"
);
});
'PaymentTransaction: InvoiceID must be a string',
)
})
it(`throws when Paths is invalid`, function () {
paymentTransaction.Paths = [[{ account: 123 }]];
paymentTransaction.Paths = [[{ account: 123 }]]
assert.throws(
() => verifyPayment(paymentTransaction),
ValidationError,
"PaymentTransaction: invalid Paths"
);
});
'PaymentTransaction: invalid Paths',
)
})
it(`throws when SendMax is invalid`, function () {
paymentTransaction.SendMax = 100000000;
paymentTransaction.SendMax = 100000000
assert.throws(
() => verifyPayment(paymentTransaction),
ValidationError,
"PaymentTransaction: invalid SendMax"
);
});
'PaymentTransaction: invalid SendMax',
)
})
it(`verifies valid DeliverMin with tfPartialPayment flag set as a number`, function () {
paymentTransaction.DeliverMin = "10000";
paymentTransaction.Flags = PaymentTransactionFlagsEnum.tfPartialPayment;
assert.doesNotThrow(() => verifyPayment(paymentTransaction));
});
paymentTransaction.DeliverMin = '10000'
paymentTransaction.Flags = PaymentTransactionFlagsEnum.tfPartialPayment
assert.doesNotThrow(() => verifyPayment(paymentTransaction))
})
it(`verifies valid DeliverMin with tfPartialPayment flag set as a boolean`, function () {
paymentTransaction.DeliverMin = "10000";
paymentTransaction.Flags = { tfPartialPayment: true };
assert.doesNotThrow(() => verifyPayment(paymentTransaction));
});
paymentTransaction.DeliverMin = '10000'
paymentTransaction.Flags = { tfPartialPayment: true }
assert.doesNotThrow(() => verifyPayment(paymentTransaction))
})
it(`throws when DeliverMin is invalid`, function () {
paymentTransaction.DeliverMin = 10000;
paymentTransaction.Flags = { tfPartialPayment: true };
paymentTransaction.DeliverMin = 10000
paymentTransaction.Flags = { tfPartialPayment: true }
assert.throws(
() => verifyPayment(paymentTransaction),
ValidationError,
"PaymentTransaction: invalid DeliverMin"
);
});
'PaymentTransaction: invalid DeliverMin',
)
})
it(`throws when tfPartialPayment flag is missing with valid DeliverMin`, function () {
paymentTransaction.DeliverMin = "10000";
paymentTransaction.DeliverMin = '10000'
assert.throws(
() => verifyPayment(paymentTransaction),
ValidationError,
"PaymentTransaction: tfPartialPayment flag required with DeliverMin"
);
});
});
'PaymentTransaction: tfPartialPayment flag required with DeliverMin',
)
})
})

View File

@@ -1,102 +1,102 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyPaymentChannelClaim } from "../../src/models/transactions/paymentChannelClaim";
import { verifyPaymentChannelClaim } from '../../src/models/transactions/paymentChannelClaim'
/**
* PaymentChannelClaim Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("PaymentChannelClaim", function () {
let channel;
describe('PaymentChannelClaim', function () {
let channel
beforeEach(function () {
channel = {
Account: "r...",
TransactionType: "PaymentChannelClaim",
Account: 'r...',
TransactionType: 'PaymentChannelClaim',
Channel:
"C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198",
Balance: "1000000",
Amount: "1000000",
'C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198',
Balance: '1000000',
Amount: '1000000',
Signature:
"30440220718D264EF05CAED7C781FF6DE298DCAC68D002562C9BF3A07C1E721B420C0DAB02203A5A4779EF4D2CCC7BC3EF886676D803A9981B928D3B8ACA483B80ECA3CD7B9B",
'30440220718D264EF05CAED7C781FF6DE298DCAC68D002562C9BF3A07C1E721B420C0DAB02203A5A4779EF4D2CCC7BC3EF886676D803A9981B928D3B8ACA483B80ECA3CD7B9B',
PublicKey:
"32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A",
};
});
'32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A',
}
})
it(`verifies valid PaymentChannelClaim`, function () {
assert.doesNotThrow(() => verifyPaymentChannelClaim(channel));
});
assert.doesNotThrow(() => verifyPaymentChannelClaim(channel))
})
it(`verifies valid PaymentChannelClaim w/o optional`, function () {
delete channel.Balance;
delete channel.Amount;
delete channel.Signature;
delete channel.PublicKey;
delete channel.Balance
delete channel.Amount
delete channel.Signature
delete channel.PublicKey
assert.doesNotThrow(() => verifyPaymentChannelClaim(channel));
});
assert.doesNotThrow(() => verifyPaymentChannelClaim(channel))
})
it(`throws w/ missing Channel`, function () {
delete channel.Channel;
delete channel.Channel
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: missing Channel"
);
});
'PaymentChannelClaim: missing Channel',
)
})
it(`throws w/ invalid Channel`, function () {
channel.Channel = 100;
channel.Channel = 100
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: Channel must be a string"
);
});
'PaymentChannelClaim: Channel must be a string',
)
})
it(`throws w/ invalid Balance`, function () {
channel.Balance = 100;
channel.Balance = 100
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: Balance must be a string"
);
});
'PaymentChannelClaim: Balance must be a string',
)
})
it(`throws w/ invalid Amount`, function () {
channel.Amount = 1000;
channel.Amount = 1000
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: Amount must be a string"
);
});
'PaymentChannelClaim: Amount must be a string',
)
})
it(`throws w/ invalid Signature`, function () {
channel.Signature = 1000;
channel.Signature = 1000
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: Signature must be a string"
);
});
'PaymentChannelClaim: Signature must be a string',
)
})
it(`throws w/ invalid PublicKey`, function () {
channel.PublicKey = ["100000"];
channel.PublicKey = ['100000']
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: PublicKey must be a string"
);
});
});
'PaymentChannelClaim: PublicKey must be a string',
)
})
})

View File

@@ -1,141 +1,141 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyPaymentChannelCreate } from "../../src/models/transactions/paymentChannelCreate";
import { verifyPaymentChannelCreate } from '../../src/models/transactions/paymentChannelCreate'
/**
* PaymentChannelCreate Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("PaymentChannelCreate", function () {
let channel;
describe('PaymentChannelCreate', function () {
let channel
beforeEach(function () {
channel = {
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
TransactionType: "PaymentChannelCreate",
Amount: "10000",
Destination: "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
TransactionType: 'PaymentChannelCreate',
Amount: '10000',
Destination: 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW',
SettleDelay: 86400,
PublicKey:
"32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A",
'32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A',
CancelAfter: 533171558,
DestinationTag: 23480,
SourceTag: 11747,
};
});
}
})
it(`verifies valid PaymentChannelCreate`, function () {
assert.doesNotThrow(() => verifyPaymentChannelCreate(channel));
});
assert.doesNotThrow(() => verifyPaymentChannelCreate(channel))
})
it(`verifies valid PaymentChannelCreate w/o optional`, function () {
delete channel.CancelAfter;
delete channel.DestinationTag;
delete channel.SourceTag;
delete channel.CancelAfter
delete channel.DestinationTag
delete channel.SourceTag
assert.doesNotThrow(() => verifyPaymentChannelCreate(channel));
});
assert.doesNotThrow(() => verifyPaymentChannelCreate(channel))
})
it(`missing Amount`, function () {
delete channel.Amount;
delete channel.Amount
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: missing Amount"
);
});
'PaymentChannelCreate: missing Amount',
)
})
it(`missing Destination`, function () {
delete channel.Destination;
delete channel.Destination
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: missing Destination"
);
});
'PaymentChannelCreate: missing Destination',
)
})
it(`missing SettleDelay`, function () {
delete channel.SettleDelay;
delete channel.SettleDelay
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: missing SettleDelay"
);
});
'PaymentChannelCreate: missing SettleDelay',
)
})
it(`missing PublicKey`, function () {
delete channel.PublicKey;
delete channel.PublicKey
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: missing PublicKey"
);
});
'PaymentChannelCreate: missing PublicKey',
)
})
it(`invalid Amount`, function () {
channel.Amount = 1000;
channel.Amount = 1000
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: Amount must be a string"
);
});
'PaymentChannelCreate: Amount must be a string',
)
})
it(`invalid Destination`, function () {
channel.Destination = 10;
channel.Destination = 10
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: Destination must be a string"
);
});
'PaymentChannelCreate: Destination must be a string',
)
})
it(`invalid SettleDelay`, function () {
channel.SettleDelay = "10";
channel.SettleDelay = '10'
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: SettleDelay must be a number"
);
});
'PaymentChannelCreate: SettleDelay must be a number',
)
})
it(`invalid PublicKey`, function () {
channel.PublicKey = 10;
channel.PublicKey = 10
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: PublicKey must be a string"
);
});
'PaymentChannelCreate: PublicKey must be a string',
)
})
it(`invalid DestinationTag`, function () {
channel.DestinationTag = "10";
channel.DestinationTag = '10'
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: DestinationTag must be a number"
);
});
'PaymentChannelCreate: DestinationTag must be a number',
)
})
it(`invalid CancelAfter`, function () {
channel.CancelAfter = "100";
channel.CancelAfter = '100'
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: CancelAfter must be a number"
);
});
});
'PaymentChannelCreate: CancelAfter must be a number',
)
})
})

View File

@@ -1,85 +1,85 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyPaymentChannelFund } from "../../src/models/transactions/paymentChannelFund";
import { verifyPaymentChannelFund } from '../../src/models/transactions/paymentChannelFund'
/**
* PaymentChannelFund Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("PaymentChannelFund", function () {
let channel;
describe('PaymentChannelFund', function () {
let channel
beforeEach(function () {
channel = {
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
TransactionType: "PaymentChannelFund",
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
TransactionType: 'PaymentChannelFund',
Channel:
"C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198",
Amount: "200000",
'C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198',
Amount: '200000',
Expiration: 543171558,
};
});
}
})
it(`verifies valid PaymentChannelFund`, function () {
assert.doesNotThrow(() => verifyPaymentChannelFund(channel));
});
assert.doesNotThrow(() => verifyPaymentChannelFund(channel))
})
it(`verifies valid PaymentChannelFund w/o optional`, function () {
delete channel.Expiration;
delete channel.Expiration
assert.doesNotThrow(() => verifyPaymentChannelFund(channel));
});
assert.doesNotThrow(() => verifyPaymentChannelFund(channel))
})
it(`throws w/ missing Amount`, function () {
delete channel.Amount;
delete channel.Amount
assert.throws(
() => verifyPaymentChannelFund(channel),
ValidationError,
"PaymentChannelFund: missing Amount"
);
});
'PaymentChannelFund: missing Amount',
)
})
it(`throws w/ missing Channel`, function () {
delete channel.Channel;
delete channel.Channel
assert.throws(
() => verifyPaymentChannelFund(channel),
ValidationError,
"PaymentChannelFund: missing Channel"
);
});
'PaymentChannelFund: missing Channel',
)
})
it(`throws w/ invalid Amount`, function () {
channel.Amount = 100;
channel.Amount = 100
assert.throws(
() => verifyPaymentChannelFund(channel),
ValidationError,
"PaymentChannelFund: Amount must be a string"
);
});
'PaymentChannelFund: Amount must be a string',
)
})
it(`throws w/ invalid Channel`, function () {
channel.Channel = 1000;
channel.Channel = 1000
assert.throws(
() => verifyPaymentChannelFund(channel),
ValidationError,
"PaymentChannelFund: Channel must be a string"
);
});
'PaymentChannelFund: Channel must be a string',
)
})
it(`throws w/ invalid Expiration`, function () {
channel.Expiration = "1000";
channel.Expiration = '1000'
assert.throws(
() => verifyPaymentChannelFund(channel),
ValidationError,
"PaymentChannelFund: Expiration must be a number"
);
});
});
'PaymentChannelFund: Expiration must be a number',
)
})
})

View File

@@ -1,43 +1,43 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifySetRegularKey } from "../../src/models/transactions/setRegularKey";
import { verifySetRegularKey } from '../../src/models/transactions/setRegularKey'
/**
* SetRegularKey Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("SetRegularKey", function () {
let account;
describe('SetRegularKey', function () {
let account
beforeEach(function () {
account = {
TransactionType: "SetRegularKey",
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
Fee: "12",
TransactionType: 'SetRegularKey',
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
Fee: '12',
Flags: 0,
RegularKey: "rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD",
} as any;
});
RegularKey: 'rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD',
} as any
})
it(`verifies valid SetRegularKey`, function () {
assert.doesNotThrow(() => verifySetRegularKey(account));
});
assert.doesNotThrow(() => verifySetRegularKey(account))
})
it(`verifies w/o SetRegularKey`, function () {
account.RegularKey = undefined;
assert.doesNotThrow(() => verifySetRegularKey(account));
});
account.RegularKey = undefined
assert.doesNotThrow(() => verifySetRegularKey(account))
})
it(`throws w/ invalid RegularKey`, function () {
account.RegularKey = 12369846963;
account.RegularKey = 12369846963
assert.throws(
() => verifySetRegularKey(account),
ValidationError,
"SetRegularKey: RegularKey must be a string"
);
});
});
'SetRegularKey: RegularKey must be a string',
)
})
})

View File

@@ -1,78 +1,78 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifySignerListSet } from "../../src/models/transactions/signerListSet";
import { verifySignerListSet } from '../../src/models/transactions/signerListSet'
/**
* SignerListSet Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("SignerListSet", function () {
let SignerListSetTx;
describe('SignerListSet', function () {
let SignerListSetTx
beforeEach(function () {
SignerListSetTx = {
Flags: 0,
TransactionType: "SignerListSet",
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
Fee: "12",
TransactionType: 'SignerListSet',
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
Fee: '12',
SignerQuorum: 3,
SignerEntries: [
{
SignerEntry: {
Account: "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
Account: 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW',
SignerWeight: 2,
},
},
{
SignerEntry: {
Account: "rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v",
Account: 'rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v',
SignerWeight: 1,
},
},
{
SignerEntry: {
Account: "raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n",
Account: 'raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n',
SignerWeight: 1,
},
},
],
} as any;
});
} as any
})
it(`verifies valid SignerListSet`, function () {
assert.doesNotThrow(() => verifySignerListSet(SignerListSetTx));
});
assert.doesNotThrow(() => verifySignerListSet(SignerListSetTx))
})
it(`throws w/ missing SignerQuorum`, function () {
SignerListSetTx.SignerQuorum = undefined;
SignerListSetTx.SignerQuorum = undefined
assert.throws(
() => verifySignerListSet(SignerListSetTx),
ValidationError,
"SignerListSet: missing field SignerQuorum"
);
});
'SignerListSet: missing field SignerQuorum',
)
})
it(`throws w/ empty SignerEntries`, function () {
SignerListSetTx.SignerEntries = [];
SignerListSetTx.SignerEntries = []
assert.throws(
() => verifySignerListSet(SignerListSetTx),
ValidationError,
"SignerListSet: need atleast 1 member in SignerEntries"
);
});
'SignerListSet: need atleast 1 member in SignerEntries',
)
})
it(`throws w/ invalid SignerEntries`, function () {
SignerListSetTx.SignerEntries = "khgfgyhujk";
SignerListSetTx.SignerEntries = 'khgfgyhujk'
assert.throws(
() => verifySignerListSet(SignerListSetTx),
ValidationError,
"SignerListSet: invalid SignerEntries"
);
});
});
'SignerListSet: invalid SignerEntries',
)
})
})

View File

@@ -1,71 +1,71 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyTicketCreate } from "../../src/models/transactions/ticketCreate";
import { verifyTicketCreate } from '../../src/models/transactions/ticketCreate'
/**
* TicketCreate Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("TicketCreate", function () {
let ticketCreate;
describe('TicketCreate', function () {
let ticketCreate
beforeEach(function () {
ticketCreate = {
TransactionType: "TicketCreate",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
TransactionType: 'TicketCreate',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
TicketCount: 150,
} as any;
});
} as any
})
it("verifies valid TicketCreate", function () {
assert.doesNotThrow(() => verifyTicketCreate(ticketCreate));
});
it('verifies valid TicketCreate', function () {
assert.doesNotThrow(() => verifyTicketCreate(ticketCreate))
})
it("throws when TicketCount is missing", function () {
delete ticketCreate.TicketCount;
it('throws when TicketCount is missing', function () {
delete ticketCreate.TicketCount
assert.throws(
() => verifyTicketCreate(ticketCreate),
ValidationError,
"TicketCreate: missing field TicketCount"
);
});
'TicketCreate: missing field TicketCount',
)
})
it("throws when TicketCount is not a number", function () {
ticketCreate.TicketCount = "150";
it('throws when TicketCount is not a number', function () {
ticketCreate.TicketCount = '150'
assert.throws(
() => verifyTicketCreate(ticketCreate),
ValidationError,
"TicketCreate: TicketCount must be a number"
);
});
'TicketCreate: TicketCount must be a number',
)
})
it("throws when TicketCount is not an integer", function () {
ticketCreate.TicketCount = 12.5;
it('throws when TicketCount is not an integer', function () {
ticketCreate.TicketCount = 12.5
assert.throws(
() => verifyTicketCreate(ticketCreate),
ValidationError,
"TicketCreate: TicketCount must be an integer from 1 to 250"
);
});
'TicketCreate: TicketCount must be an integer from 1 to 250',
)
})
it("throws when TicketCount is < 1", function () {
ticketCreate.TicketCount = 0;
it('throws when TicketCount is < 1', function () {
ticketCreate.TicketCount = 0
assert.throws(
() => verifyTicketCreate(ticketCreate),
ValidationError,
"TicketCreate: TicketCount must be an integer from 1 to 250"
);
});
'TicketCreate: TicketCount must be an integer from 1 to 250',
)
})
it("throws when TicketCount is > 250", function () {
ticketCreate.TicketCount = 251;
it('throws when TicketCount is > 250', function () {
ticketCreate.TicketCount = 251
assert.throws(
() => verifyTicketCreate(ticketCreate),
ValidationError,
"TicketCreate: TicketCount must be an integer from 1 to 250"
);
});
});
'TicketCreate: TicketCount must be an integer from 1 to 250',
)
})
})

View File

@@ -1,68 +1,68 @@
import { assert } from "chai";
import { assert } from 'chai'
import { ValidationError } from "xrpl-local/common/errors";
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyTrustSet } from "../../src/models/transactions/trustSet";
import { verifyTrustSet } from '../../src/models/transactions/trustSet'
/**
* TrustSet Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("TrustSet", function () {
let trustSet;
describe('TrustSet', function () {
let trustSet
beforeEach(function () {
trustSet = {
TransactionType: "TrustSet",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
TransactionType: 'TrustSet',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
LimitAmount: {
currency: "XRP",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "4329.23",
currency: 'XRP',
issuer: 'rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX',
value: '4329.23',
},
QualityIn: 1234,
QualityOut: 4321,
} as any;
});
} as any
})
it("verifies valid TrustSet", function () {
assert.doesNotThrow(() => verifyTrustSet(trustSet));
});
it('verifies valid TrustSet', function () {
assert.doesNotThrow(() => verifyTrustSet(trustSet))
})
it("throws when LimitAmount is missing", function () {
delete trustSet.LimitAmount;
it('throws when LimitAmount is missing', function () {
delete trustSet.LimitAmount
assert.throws(
() => verifyTrustSet(trustSet),
ValidationError,
"TrustSet: missing field LimitAmount"
);
});
'TrustSet: missing field LimitAmount',
)
})
it("throws when LimitAmount is invalid", function () {
trustSet.LimitAmount = 1234;
it('throws when LimitAmount is invalid', function () {
trustSet.LimitAmount = 1234
assert.throws(
() => verifyTrustSet(trustSet),
ValidationError,
"TrustSet: invalid LimitAmount"
);
});
'TrustSet: invalid LimitAmount',
)
})
it("throws when QualityIn is not a number", function () {
trustSet.QualityIn = "1234";
it('throws when QualityIn is not a number', function () {
trustSet.QualityIn = '1234'
assert.throws(
() => verifyTrustSet(trustSet),
ValidationError,
"TrustSet: QualityIn must be a number"
);
});
'TrustSet: QualityIn must be a number',
)
})
it("throws when QualityOut is not a number", function () {
trustSet.QualityOut = "4321";
it('throws when QualityOut is not a number', function () {
trustSet.QualityOut = '4321'
assert.throws(
() => verifyTrustSet(trustSet),
ValidationError,
"TrustSet: QualityOut must be a number"
);
});
});
'TrustSet: QualityOut must be a number',
)
})
})

View File

@@ -1,30 +1,30 @@
import { assert } from "chai";
import { assert } from 'chai'
import { isFlagEnabled } from "../../src/models/utils";
import { isFlagEnabled } from '../../src/models/utils'
/**
* Utils Testing.
*
* Provides tests for utils used in models.
*/
describe("Models Utils", function () {
describe("isFlagEnabled", function () {
let flags: number;
const flag1 = 0x00010000;
const flag2 = 0x00020000;
describe('Models Utils', function () {
describe('isFlagEnabled', function () {
let flags: number
const flag1 = 0x00010000
const flag2 = 0x00020000
beforeEach(function () {
flags = 0x00000000;
});
flags = 0x00000000
})
it("verifies a flag is enabled", function () {
flags += flag1 + flag2;
assert.isTrue(isFlagEnabled(flags, flag1));
});
it('verifies a flag is enabled', function () {
flags += flag1 + flag2
assert.isTrue(isFlagEnabled(flags, flag1))
})
it("verifies a flag is not enabled", function () {
flags += flag2;
assert.isFalse(isFlagEnabled(flags, flag1));
});
});
});
it('verifies a flag is not enabled', function () {
flags += flag2
assert.isFalse(isFlagEnabled(flags, flag1))
})
})
})